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

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

  1. Android应用被卸载后,自动使用 浏览器打开指定连接(或编写C代码执行其他操作)

    本文,提供"Android应用被卸载后,自动使用 浏览器打开指定连接"的方法. 原理:在安卓程序中某处,基于JNI调用C代码开启一个子进程监控应用在系统中的文件目录,一旦应用被卸载 ...

  2. 批量删除推文_如何搜索(和删除)您的旧推文

    批量删除推文 "The internet never forgets" is an aphorism that isn't entirely true, but it's wort ...

  3. linux mint回收站,Autotrash:定时自动删除旧垃圾的命令行工具

    Autotrash 用于自动删除旧的垃圾文件,它是一个命令行工具,通过 Autotrash 可以删除超过指定时间在回收站的文件,有了它,你不需要清空回收站或者是执行 SHIFT+DELETE 以清除文 ...

  4. Oracle数据泵自动删除,Oracle数据库定时备份并删除旧文件

    1.创建一个expdp导出bat批处理任务,自动删除30天之前备份文件: @echo off rem set backupfile=f_database_%date:~0,4%-%date:~5,2% ...

  5. aws lambda_它会融合吗? 或如何在AWS Lambda中运行Google Chrome

    aws lambda Yes, you read that right: this article is about running Google Chrome (the browser) in AW ...

  6. 【译】Remove Old Kernels in Ubuntu手动删除Ubuntu旧的内核

    I've written a new post that shows a bash one-liner command that will remove the old kernels from yo ...

  7. aws lambda_在AWS Lambda上进行无服务器我的线性回归api

    aws lambda About a year ago, I had a fun idea for a small side project. I wanted to build an API to ...

  8. altium designer布线调整时不自动删除旧线

    在布线修改时,往往采用在原来布线基础上再重新走线的方法.可是有时候altium designer会出现,新走的线连好后,旧的线altium designer不自动删除的情况. 这时就要,在拉线中按Ta ...

  9. 为什么文件会自动恢复成旧文件? -- windows server 2003

    cjq001 (威猛先生 noteu.net) 等 级: 结帖率:98.15% 楼主发表于:2009-01-04 08:53:15 我编辑了我公司服务器上的文件,服务器安装的是windows serv ...

最新文章

  1. 【每日一算法】二叉树中所有距离为 K 的结点
  2. python的集合运算和set相关操作
  3. Leetcode 106. 从中序与后序遍历序列构造二叉树 解题思路及C++实现
  4. Java学习笔记——局部变量和成员变量
  5. python ssh登陆模块_Python sshh包_程序模块 - PyPI - Python中文网
  6. 51nod 1557 两个集合 (严谨的逻辑题)
  7. OBJ可视化——UV还原(修正)
  8. 【Java】JDBC连接MySQL/SQLServer/Oracle三种数据库
  9. openeuler学习指南
  10. voip语音中转服务器,基于VoIP的语音应用服务器的设计与实现
  11. JavaWeb实现记住密码功能(使用Cookie)
  12. 软件测试项目案例哪里找?【银行/教育/商城/金融/等等....】
  13. ERROR 1018 (HY000): Can‘t read dir of ‘.‘ (errno: 13 - Permission denied)
  14. 各利不同网站的盈利模式
  15. 使用ffmpeg合并多个视频文件
  16. Unity3d 场景搭建 基础 学习
  17. 高校wifi认证登录
  18. 现在买笔记本电脑要注意哪些方面? 哪些比较好?
  19. 特斯拉看位置说服务器错误,特斯拉App惊现大面积宕机!车主集体发飙,官方处理太弱智了...
  20. linux下进入隐藏文件夹命令,Linux命令-----grep不查找隐藏文件夹的方法

热门文章

  1. 如何获取URL中的参数
  2. 实验 5   数据的完整性管理
  3. OpenCV 图像加载和显示
  4. 一些零碎知识(域名、DNS、浏览器、动态静态页面、web应用系统工作原理)
  5. python3.9.0 print_关于 Python 3.9,那些你不知道的事
  6. TextKit及应用
  7. Linux下Shell日期的格式
  8. Docker学习笔记_安装ActiveMQ
  9. [ExtJS5学习笔记]第五节 使用fontawesome给你的extjs5应用添加字体图标
  10. 记一次CentOS7内核kernel的删除重装