当前位置: 首页 > 编程日记 > 正文

aws lambda_为什么我会自动删除所有旧的推文以及我用来执行此操作的AWS Lambda函数...

aws lambda

From now on, my tweets are ephemeral. Here’s why I’m deleting all my old tweets, and the AWS Lambda function I’m using to do all this for free.

从现在开始,我的推文只是短暂的。 这就是为什么我删除所有旧的推文,以及免费使用所有这些功能的AWS Lambda函数的原因。

东西和意见 (Stuff and opinions)

I’ve only been a one-bag nomad for a little over a year and a half. Before that, I lived as most people do in an apartment or a house. I owned furniture, more clothing than I strictly needed, and enough “stuff” to fill at least a few moving boxes. If I went to live somewhere else, moving for school or family or work, I packed up all my things and brought them with me. Over the years, I accumulated more and more stuff.

我只是一个袋装的Nomad民族 ,已经有一年半了。 在那之前,我像大多数人一样住在公寓或房屋中。 我拥有家具,比我绝对需要的衣服还要多的东西,以及足够的“东西”来填充至少几个移动的盒子。 如果我去别的地方,为了学校,家庭或工作而搬家,我会把所有东西收拾好,带上去。 这些年来,我积累了越来越多的东西。

Adopting what many would call a minimalist lifestyle has rapidly changed a lot of my longstanding views. Giving away all my stuff (an idea I once thought to be interesting in principle but practically a little bit ridiculous) has become normal. It’s normal for me, now, to not own things that I don’t use on a regular basis. I don’t keep wall shelves packed with old books or dishes or clothing or childhood toys because those items aren’t relevant to me anymore. I just keep fond memories, instead.

采用许多人所谓的极简主义生活方式Swift改变了我许多长久以来的观点。 放弃我所有的东西(这个想法我曾经认为原则上很有趣,但实际上有点荒谬)已成为常态。 现在,不拥有我不定期使用的东西对我来说是正常的。 我不会在墙上的架子上堆满旧书,碗碟,衣服或童年玩具,因为这些物品不再与我相关。 我只是保持美好的回忆。

Imagine, for a moment, that I still lived in a house. Imagine that in that house, on the fridge, is a drawing I made when I was six-years-old. In the bottom right corner of that drawing scribbled in green crayon are the words “broccoli is dumb — Victoria, Age 6.”

想象一下,我仍然住在一所房子里。 想象一下,那是我六岁时在那间房子的冰箱上绘制的一幅画。 在用绿色蜡笔涂鸦的那幅画的右下角,写着“西兰花很笨-维多利亚,6岁”。

If you were in my house and saw that drawing on the fridge, would you assume that the statement “broccoli is dumb” comprised an accurate and current account of my opinions on broccoli? Of course not. I was six when I wrote that. I’ve had plenty of time to change my mind.

如果您在我家中看到冰箱上的图画,您是否认为“西兰花很笨”的说法是对我对西兰花的看法的准确和最新的记载? 当然不是。 我写那本书的时候只有六岁。 我有很多时间改变主意。

社交媒体不是社交媒体 (Social media isn’t social)

I have a friend whom I’ve known since we were both in kindergarten. We went through grade school together, then spoke to and saw each other on infrequent occasions across the years. We’re both adults now. Sometimes when we chat, we’ll recall some amusing memory from when we were younger. The nature of memory being what it is, I have no illusion that what we recall is recounted with much accuracy. Our impressions of things that happened — mistakes we made and moments of victory alike — are coloured by the experiences we’ve had since then, and all the things we’ve learned. An awkward moment at a school colleague’s birthday party becomes an example of a child learning to socialize, instead of the world-ending moment of embarrassment it probably felt like at the time.

自从我们俩都上幼儿园以来,我就有一个认识的朋友。 这些年来,我们一起上了小学,然后互相交谈,彼此见面。 现在我们都是大人。 有时,当我们聊天时,我们会想起年轻时的一些有趣记忆。 内存的本质就是它的本质,我不幻想我们回忆的内容可以准确地重述。 从那时以来的经历以及我们学到的所有东西,我们对发生的事情的印象-我们犯的错误和胜利时刻-都会给人留下深刻的印象。 在学校同事的生日聚会上尴尬的时刻成为孩子学习社交的一个例子,而不是当时世界感觉尴尬的时刻。

This is how memory works. In a sense, it gets updated, as well it should. People living in small communities remember things that their neighbour did many years ago, but recall them in the context of who their neighbour is now, and what their current relationship is like. This re-colouring of history is an important part of how people heal, make good decisions, and socialize.

这就是内存的工作方式。 从某种意义上说,它也会得到更新。 生活在小社区中的人们会记住他们邻居多年以前所做的事情,但会在他们现在是谁以及当前的关系是什么样的背景下回忆他们。 历史的重彩是人们如何治愈 , 做出正确的决策以及进行社交的重要组成部分。

Social media does not do this. Your perfectly preserved tweet from five days or five years ago can be recalled with absolute accuracy. For most people, this is not particularly worrying. We tend to tweet about pretty mundane things — things that pop into mind when we’re bored and want someone to notice us. Individually, usually, our old tweets are pretty insignificant. In aggregate, however, they paint a pretty complete picture of a person’s random, unintentionally telling thoughts. This is the problem.

社交媒体不这样做。 您可以精确地召回五天或五年前保存完好的推文。 对于大多数人来说,这并不特别令人担忧。 我们倾向于发布一些非常平凡的东西,这些东西在我们无聊的时候会突然出现,并希望有人注意到我们。 通常,通常来讲,我们的旧推文微不足道。 总体而言,它们描绘了一个人随机,无意间说出的想法的完整画面。 这就是问题。

The assumption made of things written in social media and on Twitter specifically is a very different assumption than you might make about someone’s notepad scribble from last week. I’m not endeavoring to speculate why — I’ve just seen enough cases of someone getting publicly flogged for something they posted years ago to know that it does happen. This is weird. If you wouldn’t assume that a notepad scribble from last week or a crayon drawing from decades ago reflects the essence of who someone is now, why would you assume that an old tweet does?

与社交媒体和推特上写的东西有关的假设与上周关于某人的记事本涂鸦的假设完全不同。 我不努力推测原因-我刚刚看到足够多的情况,某人在几年前公开迷恋他们发布的内容,以知道它确实发生了。 真奇怪 如果您不认为上周的记事本涂鸦或几十年前的蜡笔画反映了现在的人的本质那么您为什么要假设一条旧推文呢?

You are not the same person you were last month — you’ve seen things, read things, understood and learned things that have, in some small way, changed you. While a person may have the same sense of self and identity through most of their life, even this grows and changes over the years. We change our opinions, our desires, our habits. We are not stagnant beings, and we should not let ourselves be represented as such, however unintentionally.

您与上个月的人不一样-您看到的东西,阅读的东西,理解和学习的东西在某种程度上改变了您。 尽管一个人一生中可能都有相同的自我意识和身份感,但随着时间的推移,这种自我感和身份感会不断增长和变化。 我们改变意见,欲望和习惯。 我们不是死气沉沉的人,我们不应该无意中这样代表自己。

临时推文 (Ephemeral tweets)

If you look at my Twitter profile page today, you’ll see fewer tweets there than you have fingers (I hope). I’m using ephemeral — a lightweight utility I wrote for use on AWS Lambda — to delete all my tweets older than a few days. I’m doing this for the same reason that I don’t hang on to stuff that I no longer use — that stuff isn’t relevant to me anymore. It doesn’t represent me, either.

如果您今天查看我的Twitter个人资料页面,那么在那里看到的推文少于手指(我希望)。 我正在使用ephemeral (我写给AWS Lambda使用的轻量级实用程序)删除早于几天的所有推文。 我这样做的原因是,我不再依赖不再使用的东西了-这些东西不再与我相关。 它也不代表我。

The code that makes up ephemeral is written in Go. AWS Lambda creates an environment for each Lambda function, so ephemeral utilizes environment variables for your private Twitter API keys and the maximum age of the tweets you want to keep, represented in hours, like 72h.

组成短暂的代码是用Go编写的。 AWS Lambda为每个Lambda函数创建一个环境,因此临时使用环境变量来存储您的私有Twitter API密钥以及要保留的推文的最长期限,以小时为单位,例如72h

var (consumerKey       = getenv("TWITTER_CONSUMER_KEY")consumerSecret    = getenv("TWITTER_CONSUMER_SECRET")accessToken       = getenv("TWITTER_ACCESS_TOKEN")accessTokenSecret = getenv("TWITTER_ACCESS_TOKEN_SECRET")maxTweetAge       = getenv("MAX_TWEET_AGE")logger            = log.New()
)
func getenv(name string) string {v := os.Getenv(name)if v == "" {panic("missing required environment variable " + name)}return v
}

The program uses the anaconda library. It fetches your timeline up to the Twitter API’s limit of 200 tweets per request, then compares each tweet’s date of creation to your MAX_TWEET_AGE variable to decide whether it’s old enough to be deleted. After deleting all the expired tweets, the Lambda function terminates.

该程序使用anaconda库。 它将获取您的时间轴,直到每个请求的Twitter API限制为200条推文的限制,然后将每个推文的创建日期与您的MAX_TWEET_AGE变量进行比较,以确定其是否足够旧以至于可以删除。 删除所有到期的推文后,Lambda函数终止。

func deleteFromTimeline(api *anaconda.TwitterApi, ageLimit time.Duration) {timeline, err := getTimeline(api)
if err != nil {log.Error("Could not get timeline")}for _, t := range timeline {createdTime, err := t.CreatedAtTime()if err != nil {log.Error("Couldn't parse time ", err)} else {if time.Since(createdTime) > ageLimit {_, err := api.DeleteTweet(t.Id, true)log.Info("DELETED: Age - ", time.Since(createdTime).Round(1*time.Minute), " - ", t.Text)if err != nil {log.Error("Failed to delete! ", err)}}}}log.Info("No more tweets to delete.")
}

Read the full code here.

在此处阅读完整的代码。

For a use case like this, AWS Lambda has a free tier that costs nothing. If you’re any level of developer, it’s an extremely useful tool to become familiar with. For a full walkthrough with screenshots of how to set up a Lambda function that tweets for you, you can read this article. The set up for ephemeral is the same, it just has an opposite function. :)

对于这样的用例,AWS Lambda有一个免费的免费套餐。 如果您是任何级别的开发人员,那么它都是一个非常有用的工具,可以让您熟悉。 有关如何设置推特的Lambda函数的屏幕快照的完整演练,您可以阅读本文 。 临时设置是相同的,只是功能相反。 :)

I forked ephemeral from Adam Drake’s Harold, a Twitter tool that has many useful functions beyond keeping your timeline trimmed. If you have more than 200 tweets to delete at first pass, please use Harold to do that first. You can run Harold with the deletetimeline flag from your terminal.

我从亚当·德雷克(Adam Drake)的Harold (一个Twitter工具)中获得了短暂的收入 ,该工具具有许多有用的功能,而不仅仅是修剪时间线。 如果您第一次删除的推文超过200条,请首先使用Harold进行删除。 您可以从终端使用带有deletetimeline标志的Harold。

You may want to first download all your tweets before deleting them for sentimental value.

您可能需要先下载所有推文,然后再删除它们以获取感性价值。

为什么要使用Twitter? (Why use Twitter at all?)

In anticipation of the question, let me say that yes, I do use Twitter besides just as a bucket for my Lambda functions to fill and empty. It has its benefits, most related to what I perceive to be its original intended purpose: to be a means of near-instant communication for short, digestible pieces of information reaching a widespread pool of people.

在回答这个问题之前,我要说的是,除了使用Lambda函数填充和清空存储桶之外,我还使用Twitter。 它具有其优势,与我最初认为的最初目的最相关:它是一种即时通讯的手段,用于将简短的,易消化的信息传递给广泛的人们。

I use it as a way to keep tabs on what’s happening right now. I use it to comment on, joke about, and commiserate with things tweeted by the people I follow right now. By keeping my timeline restricted to only the most recent few days, I feel like I’m using Twitter more like it was meant to be used: a way to join the conversation and see what’s happening in the world right now — instead of just another place to amass more “stuff.”

我用它来跟踪当前发生的事情 我用它来评论,开玩笑,并对我现在关注的人在推特上发表的事情感到同情 通过将时间范围限制为仅最近几天,我觉得我使用Twitter的方式更像是应该使用的方式:一种加入对话并查看当前世界上正在发生的事情的方式-而不只是另一种方式聚集更多“东西”的地方。

Thanks for reading! If you’d like to hear more about how I make my life better with tech, you can follow me here as well as check out my blog where I explain coding with more poorly-drawn doodles of food: Victoria.dev

谢谢阅读! 如果您想了解有关我如何通过科技改善生活的更多信息,您可以在这里关注我,也可以查看我的博客,在该博客中我用更差的食物涂鸦来解释编码: Victoria.dev

I hope you have a really great day! :)

希望您今天过得愉快! :)

翻译自: https://www.freecodecamp.org/news/why-im-automatically-deleting-all-my-old-tweets-and-the-aws-lambda-function-i-use-to-do-this-6d26ef517ee1/

aws lambda

相关文章:

Topcoder SRM 657DIV2

前言: 像我这样一直在DIV2的弱菜。。不知道说什么了。 A:一定判断有8个‘R’,每行 每列只有一个 B题:大概是 int E,int EM,int M,int MH,int H 然后EM可以给值到E,M,MH可以给值到H,M; 我的做法二分&#x…

微信小程序换行,空格的写法

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文: 1.文本超出部分自动换行,前后对比 实现代码: flex-wrap: warp;white-space: pre-wrap; 2.text 手动添加换行的写法 { text: 12测试换\n行符,测试\…

我是如何在尼日利亚的沃里创立Google Developers Group GDG分会的,并达到了100位成员...

It only takes a spark to get a fire going, and soon all those around can warm up in its glowing. — Kurt Kaiser, Pass It On只需要一点火花就能使火熄灭,周围的所有人很快就会在炽热的火焰中升温。 — Kurt Kaiser,传递下去 I am convinced beyo…

ES6 你可能不知道的事 – 基础篇

ES6 你可能不知道的事 – 基础篇 转载作者:淘宝前端团队(FED)- 化辰 链接:taobaofed.org/blog/2016/07/22/es6-basics/ 序 ES6,或许应该叫 ES2015(2015 年 6 月正式发布),对于大多数…

Android线程之主线程向子线程发送消息

和大家一起探讨Android线程已经有些日子了,谈的最多的就是如何把子线程中的数据发送给主线程进行处理,进行UI界面的更新,为什么要这样,请查阅之前的随笔。本篇我们就来讨论一下关于主线程向子线程如何发送数据,这个用的…

HTML上传excel文件,php解析逐条打印输出

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; phpExcel文件下载 ←跳转地址 demo <!DOCTYPE html> <html lang"zh"><head><meta charset"UTF-8"><title>Title</title>…

javascript编写_如何通过编写自己的Web开发框架来提高JavaScript技能

javascript编写Have you ever asked yourself how a framework works?您是否曾经问过自己框架是如何工作的&#xff1f; When I discovered AngularJS after learning jQuery many years ago, AngularJS seemed like dark magic to me.多年前学习jQuery后&#xff0c;当我发现…

2016ACM/ICPC亚洲区大连站现场赛题解报告(转)

http://blog.csdn.net/queuelovestack/article/details/53055418 下午重现了一下大连赛区的比赛,感觉有点神奇,重现时居然改了现场赛的数据范围,原本过的人数比较多的题结果重现过的变少了,而原本现场赛全场过的人最少的题重现做出的人反而多了一堆,不过还是不影响最水的6题,然…

微信小程序插件新增能力

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; “ 小程序插件能力升级&#xff1a;开放插件登录能力&#xff0c;帮助插件开发者更好地管理用户&#xff1b;支持在插件内使用微信支付能力&#xff0c;便于用户在插件内完成预订、购…

ubutun:从共享文件夹拷贝文件尽量使用cp命令而不是CTRL+C/V

为了方便&#xff0c;VBOX安装的Ubuntu&#xff0c;并在硬盘上创建了一个与Windows的共享文件夹sharefolder方便在两个系统之间传文件 但是经常发现的问题就是从sharefolder中拷贝文件到ubuntu中会出现很多毛病&#xff0c;比如说经常按了CTRLC之后没有拷贝最新的文件&#xff…

影像锐化工具_如何以及为什么要进行工具改造:花在锐化斧头上的时间永远不会浪费...

影像锐化工具by Harshdeep S Jawanda通过Harshdeep S Jawanda 如何以及为什么要进行工具改造&#xff1a;花在锐化斧头上的时间永远不会浪费 (How and why you should tool-up: time spent sharpening your axe is never wasted) There is this old anecdote about two friend…

ListT随机返回一个

/// <summary> /// 随机返回一条数据 /// </summary> /// <param name"list"></param> /// <returns></returns> protected string GetRandomData(List<string> list) {return list.OrderBy(_ > Guid.NewGuid()).First…

微信小程序插件功能页开发详细流程

有问题可以扫码加我微信&#xff0c;有偿解决问题。承接小程序开发。 微信小程序开发交流qq群 173683895 、 526474645 &#xff1b; 正文&#xff1a; 关于新出的微信小程序插件功能页做一下记录&#xff0c;希望能帮到大家 步骤&#xff1a; 1.打开开发者工具&#x…

(拆点+最小路径覆盖) bzoj 2150

2150: 部落战争 Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 518 Solved: 298[Submit][Status][Discuss]Description lanzerb的部落在A国的上部&#xff0c;他们不满天寒地冻的环境&#xff0c;于是准备向A国的下部征战来获得更大的领土。 A国是一个M*N的矩阵&#xff0…

使用Flow检查React,Redux和React-Redux的全面指南

by Fabian Terh由Fabian Terh 使用Flow检查React&#xff0c;Redux和React-Redux的全面指南 (A comprehensive guide to type checking React, Redux, and React-Redux with Flow) This article is divided into 4 sections:本文分为4个部分&#xff1a; Type checking Redux…

微信小程序WebSocket实现聊天对话功能完整源码

相关文章&#xff1a; 1.小程序聊天群&#xff0c;发送语音&#xff0c;文字&#xff0c;图片。 2.微信小程序集成腾讯IM&#xff0c;实现实时音视频通话&#xff0c;1V1聊天 3.云开发微信小程序聊天群 4.接入网易云信IM即时通讯的微信小程序聊天室 5.微信小程序聊天功能 …

codevs 1203 判断浮点数是否相等

1203 判断浮点数是否相等 时间限制: 1 s空间限制: 128000 KB题目等级 : 青铜 Bronze题目描述 Description给出两个浮点数&#xff0c;请你判断这两个浮点数是否相等输入描述 Input Description输入仅一行&#xff0c;包含两个浮点数输出描述 Output Description输出仅一行&…

通过代码自定义cell(cell的高度不一致)

我们知道&#xff0c;在iOS中&#xff0c;自定义cell的方式有两种&#xff1a; 一是通过xib创建 .二是通过代码自定义cell 这里我说下通过代码自定义的cell。 当我们的应用显示的cell比较复杂&#xff0c;显示的行高都不一样&#xff0c;比如新浪微博 这时用系统自带的cell…

通过构建城市来解释HTML,CSS和JavaScript之间的关系

by Kevin Kononenko凯文科诺年科(Kevin Kononenko) 通过构建城市来解释HTML&#xff0c;CSS和JavaScript之间的关系 (The relationship between HTML, CSS and JavaScript explained by building a city) If you have ever visited a walkable city like New York, then you c…

url参数解析 url解析 ?解析成对象

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 代码&#xff1a; // url参数解析 function getUrlkey(url) {var params {};var urls url.split("?");if (urls[1]) {var arr urls[1].split("&");for …

【bzoj1070】[SCOI2007]修车 最小费用流

原文地址&#xff1a;http://www.cnblogs.com/GXZlegend/p/6798411.html 题目描述 同一时刻有N位车主带着他们的爱车来到了汽车维修中心。维修中心共有M位技术人员&#xff0c;不同的技术人员对不同的车进行维修所用的时间是不同的。现在需要安排这M位技术人员所维修的车及顺序…

“Assign Random Colors” is not working in 3ds Max 2015

Go to Customize -> Preferences…-> General (tab) Uncheck “Default to By Layer for New Nodes”转载于:https://www.cnblogs.com/cindy-hu-23/p/4476293.html

计算机编程课程顺序_您可以在6月开始参加630项免费的在线编程和计算机科学课程...

计算机编程课程顺序Six years ago, universities like MIT and Stanford first opened up free online courses to the public. Today, more than 800 schools around the world have created thousands of free online courses.六年前&#xff0c;麻省理工学院和斯坦福大学等大…

卡片右上角三角形效果,按钮点击变色

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 效果图&#xff1a; 实现代码&#xff1a; <view classprivilege_list><view classprivilege_card {{in_right_top1?"bg":""}} bindtapin_card id1&g…

数据挖掘基本任务

数据挖掘基本任务 数据挖掘主要做什么&#xff1f;换而言之&#xff0c;数据挖掘主要解决什么问题呢&#xff1f;这些问题&#xff0c;可以归结为数据挖掘的基本任务。 数据挖掘的基本任务包括分类与预测、聚类分析、关联规则、奇异值检测和智能推荐等。通过完成这些任务&#…

41-First Missing Positive

【题目】 Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses constant space. 【analyze】 1.由于是无序的&#xff0c;所以处理起来…

javascript迭代器_JavaScript符号,迭代器,生成器,异步/等待和异步迭代器-全部简单解释...

javascript迭代器by rajaraodv通过rajaraodv JavaScript符号&#xff0c;迭代器&#xff0c;生成器&#xff0c;异步/等待和异步迭代器-全部简单解释 (JavaScript Symbols, Iterators, Generators, Async/Await, and Async Iterators — All Explained Simply) Some JavaScrip…

jquery总结和注意事项

1、关于页面元素的引用通过jquery的$()引用元素包括通过id、class、元素名以及元素的层级关系及dom或者xpath条件等方法&#xff0c;且返回的对象为jquery对象&#xff08;集合对象&#xff09;&#xff0c;不能直接调用dom定义的方法。 2、jQuery对象与dom对象的转换只有jquer…

第4次作业类测试代码+043+杨晨宇

triangle的代码&#xff1a; package triangle;import java.text.DecimalFormat;public class Triangle {public Triangle() {}/** 判断三角形的类型*/public String triangleshape(int a, int b, int c) {if ((a < 1 || a > 100) || (b < 1 || b > 100) || (c <…

微信小程序让屏幕自动向下滚动

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; wx.pageScrollTo(OBJECT) 基础库 1.4.0 开始支持&#xff0c;低版本需做兼容处理 将页面滚动到目标位置。 OBJECT参数说明&#xff1a; 参数名类型必填说明scrollTopNumber是滚动到…