跳至主要内容

折腾树莓派

作者:王震宇
链接:https://www.zhihu.com/question/20859055/answer/54734499
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

我两年前买的(约2013年),上面搭了十来种服务,比如:
  • 一个个人网站,虽然我在国外买了专业的网站空间,但是在自己家里搭建一个,放些好玩的东西,也蛮有意思的,更新起来也不需要FTP了,直接拷贝就可以了。服务器上顺便搭建了一个家庭相册,由于是局域网,速度很快。
  • 一个Git服务器,用来存放自己的部分代码,比如有些代码不想放在github上的,可以放在这里
  • 一个BT下载机(transmission),可以远程操作,随时随地的下载。
  • 家庭NAS,把所有的文档、电影、音乐、照片都放在这里,共享出来,家里的所有设备(手机、平板、电视盒子、电脑)都可以随意存取,再也不用担心iPhone,iPad的空间不够了,随时可以看在线电影。
  • 一个AirPlay服务,可以把苹果设备的音乐无线投放到树莓派上的音箱,用的是ShairPort
  • 一个私有云服务ownCloud,可以在任何地方,包括用手机,上传下载文件,同步日历等。这个服务比较慢,是唯一一个让我有购买新版Pi的理由。
  • 一个闹钟,整点会报时(早上第一次报时是女儿喊大家起床的录音),用Cronjob设置,顺便把当前的温度,AQI,PM2.5指数都报出来,本来用的是Google的翻译引擎在线翻译,后来Google翻译挂了,就把翻译好的音频文件下载下来,也可以用。
  • 用Cronjob在每周和每天不同的时间段,播放不同的儿歌,三字经,百家姓什么的,给家里的小朋友听,会不由自主的跟着学。
  • 一个语音信箱,发送邮件到一个指定的邮箱,邮件的内容就会被转换成语音,从树莓派的音箱播放出来。这个服务目前已经挂了,因为不能访问Google。有离线的TTS引擎,我也装了,叫做espeak,声音太烂了,难听,可能百度也有类似服务,没有研究过
  • 一个Twitter机器人,每天定时把当地的天气情况发送到twitter,居然还有人follow它。
  • 网络收音机,用的不多,因为找不到好的广播流地址
  • 一个邮件同步器,把我常用的邮箱定时同步到本地,用的是offlineimap,然后用mutt收发,由于我的常用邮箱是Gmail,目前此功能也挂了
  • 自动上传视频文件到百度盘,我用iPhone或者小米运动相机拍摄的视频,我只要把它拖到NAS的一个目录里面,脚本就会自动把这些视频重新命名,把文件名改成日期和时间,方便以后查找,然后自动上传到百度云,同时自动按日期分类
  • 一个网络跳板,我可以远程操作家里的电脑,只要家里的电脑主板支持WAKE-ON-LAN都可以。这个和前面的几个功能一样,得要求你的宽带有公网IP,登录到树莓派后,执行命令激活其他电脑。
  • 一个网站资源下载器,比如文章、图片。可以写一些脚本去解析你常去的网站论坛,自动下载图片:汽车、风景、人文、美女等等。用SQLite,保存文件的MD5,小文件,重复文件自动删除。程序中把User Agent设置为知名浏览器,比如Chrome, IE等,否则可能会被拒绝下载
  • 一个dnsmasq服务,用来做内网的DNS服务器,彻底解决了女儿看优酷动画片上瘾的问题,cronjob定时把youku.com解析到127.0.0.1,只有规定的时间可以看优酷。这个服务还可以用来解决另外两个问题:过滤广告网站、访问被ISP通过DNS解析过滤的网站,比如Google,Gmail什么的,家里的设备无须安装任何软件,也不需要做设置。
  • 一组Yeelink的脚本,用来同步Pi的性能指标(比如CPU利用率等)到云端,用于在手机上显示。并且还可以用手机去控制Pi上面跑的程序,目前我只写了一个用来控制BT程序的开和关。有兴趣的可以移步这里:Yeelink - 连接世界到云端,专注物联网云服务去看看他们的教程。
补充:
  • 我的Pi是有自己的域名的,由于电信的公网IP会变,所以Pi里面有个脚本,定时检查自己的IP是不是变了,如果变了,就通过DNS服务商的API,自动更新域名解析,没有这个设置的话,万一IP变了,无法从外面访问。
  • Pi外接的是笔记本上拆下来的硬盘,居然连续跑了两年多还没有坏,24x7,实在是让我惊讶。除了偶尔几次接口莫名其妙的接触不良,重新插拔一下就好了。
  • 对于上面提到的几个基于Google的服务,如果不做任何设置,是不可以使用的。实际上我还是可以用,比如translate.google.com或者offlineimap。方法是:定期把可用的Google IP更新到dnsmasq里面。IP失效后,再换一个就可以了。
  • 上面提到的各种应用,其实都可以在一个安装了Linux的普通PC上实现,但是Pi特别的地方,就是它的尺寸小,不耗电,无噪音,价格低。大部分人不会把一台PC放在家里24小时的开着,却可以接受Pi这样24x7的开着。
虽然买了两三年,至今觉得用起来挺好的,就那么安静的躺在角落里,省电绿色环保。至于普通人能不能这么玩,我觉得只要有些许编程基础,完全可以玩,去网上搜搜,找些现成的代码,改改就可以了。当然如果一点编程基础都没有,搞些简单的还是可以的。按照网络教程来就可以了。
---分割线,以上是树莓派一代的应用,下面是三代的应用---
最近买了树莓派3,性能大大的提高了,一代还在服役,没有任何问题。我把一些应用分散到两个Pi上了,为了负载均衡。
  • 一个视频编辑工作站,安装了avconv和ffmpeg,用来做视频的编辑,我主要用来做视频分割。比如,运动相机或者iPhone拍出来的视频,首尾有些被手挡住的镜头,可以用avconv切割掉,视频多了才能看出效果,因为视频编辑比较耗时,可以把时间点写的脚本里,让它慢慢跑。也可以做其他的视频编辑,比如转码什么的。
  • 一个个人开发环境,给vim安装了一堆常用的插件,又安装了MySQL,Redis等等。这样,你可以在任何时候登录上来做开发,无论你在家里、公司还是别处,一句话:你熟悉的开发环境触手可及。
  • 升级版的电视儿童锁,Youku被定时屏蔽,可是她摸索了后,转而去看本地下载过的动画片,于是我把电视接在小米智能插座上,定时给电视断电,结果被她发现断电后,再去重启插座就可以了(按那个白色按钮,她的原话)。所以再追加了一个脚本,定时把下载过的动画片的目录的execute权限去掉,这样小米盒子就无法读取了。
  • 准备在上面跑一个Volunteer Computing Project,具体项目在这里(BOINC),最近比较忙没有时间捣鼓,等空了再弄吧。

Popular posts from 产品随想的博客

Interview at the All Things Digital D5 Conference, Steve and Bill Gates spoke with journalists Kara Swisher and Walt Mossberg onstage in May 2007.

Kara Swisher: The first question I was interested in asking is what you think each has contributed to the computer and technology industry— starting with you, Steve, for Bill, and vice versa. Steve Jobs: Well, Bill built the first software company in the industry. And I think he built the first software company before anybody really in our industry knew what a software company was, except for these guys. And that was huge. That was really huge. And the business model that they ended up pursuing turned out to be the one that worked really well for the industry. I think the biggest thing was, Bill was really focused on software before almost anybody else had a clue that it was really the software that— KS: Was important? SJ: That’s what I see. I mean, a lot of other things you could say, but that’s the high-order bit. And I think building a company’s really hard, and it requires your greatest persuasive abilities to hire the best ...

产品随想 | 周刊 第43期:历史上的今天

Products Huberman Lab   https://hubermanlab.com/ 一款聚焦于健康的播客 今日热榜   https://tophub.today/ 聚合展示,国内各热门榜单,对跟进热点非常有帮助,热点运营的好帮手 SketchyBar   https://github.com/FelixKratz/SketchyBar A highly customizable macOS status bar replacement Mac菜单栏定制 自定义程度很高,看作者展示的案例,暂时没想出这样的好处(不过应用本身的编辑,确实也没啥意义)生命在于折腾吧! Thanks-Mirror   https://github.com/eryajf/Thanks-Mirror 整理记录各个包管理器,系统镜像,以及常用软件的好用镜像,Thanks Mirror。 Musicn   https://github.com/zonemeen/musicn 一个下载高品质音乐的命令行工具,音乐来源: 咪咕 Planet Minecraft A creative Minecraft community fansite sharing maps, minecraft skins, resource packs, servers, mods, and more. 里面有很多动人的故事 可能是世界上最大的Minecraft社区,从2010年至今 The Uncensored Library   https://www.uncensoredlibrary.com/en blockworks   https://www.blockworks.uk/ "Distinctive maps for Minecraft that have educated players and risen to the level of art" 游戏也可以让人有更高的实现,而不仅仅是沉迷其中,国外游戏厂商比我们做的好太多 Minecraft_Memory_Bypass_GUI   https://github.com/xingchuanzhen/Minecraft_Memory_Bypass_GUI 绕过Minecraft...

巴菲特致股东信-1976年

 笔记: 为什么选择轻资产行业:当竞争疯狂时,不会强迫加入降价大战 最终选择了费雪的思想,选择能理解的优秀企业,以合理的价格买入并长期拥有 翻译: 雪球:https://xueqiu.com/6217262310/131440258 备份:https://archive.ph/XLK0S 原文: To the Stockholders of Berkshire Hathaway Inc, After two dismal years, operating results in 1976 improved significantly. Last year we said the degree of progress in insurance underwriting would determine whether our gain in earnings would be "moderate" or "major." As it turned out, earnings exceeded even the high end of our expectations. In large part, this was due to the outstanding efforts of Phil Liesche's managerial group at National Indemnity Company. In dollar terms, operating earnings came to $16,073,000, or $16.47 per share. While this is a record figure, we consider return on shareholders' equity to be a much more significant yardstick of economic performance. Here our result was 17.3%, moderately above our long-term average and even further above the average o...

Commencement Address at Stanford University--“Stay hungry. Stay foolish.”

I am honored to be with you today for your commencement from one of the finest universities in the world. Truth be told— I never graduated from college. This is the closest I’ve ever gotten to a college graduation. Today I want to tell you three stories from my life. That’s it. No big deal. Just three stories. The first story is about connecting the dots. I dropped out of Reed College after the first six months but then stayed around as a drop-in for another eighteen months or so before I really quit. So why did I drop out? It started before I was born. My biological mother was a young, unwed graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided at the last minute that they really wanted a girl. So my parents, who were on a waiting...

巴菲特致股东信-1975年

 笔记: 华盛顿邮报已成为伯克希尔第一重仓股 翻译: 雪球:https://xueqiu.com/6217262310/131409324 备份:https://archive.ph/4hgK3 原文: To the Stockholders of Berkshire Hathaway Inc.: Last year, when discussing the prospects for 1975, we stated “the outlook for 1975 is not encouraging.” This forecast proved to be distressingly accurate. Our operating earnings for 1975 were $6,713,592, or $6.85 per share, producing a return on beginning shareholders ’ equity of 7.6%. This is the lowest return on equity experienced since 1967. Furthermore, as explained later in this letter, a large segment of these earnings resulted from Federal income tax refunds which will not be available to assist performance in 1976. On balance, however, current trends indicate a somewhat brighter 1976. Operations and prospects will be discussed in greater detail below, under specific industry titles. Our expectation is that significantly better results in textiles, earnings added from recent acquisitio...

产品随想 | 周刊 第90期:史家之绝唱,无韵之离骚

Why AI Will Save the World   https://a16z.com/2023/06/06/ai-will-save-the-world/ Marc Andreessen的雄文,十分有說服力,邏輯清晰 辯證了現今AI監管拋出的5個可能的AI問題 讀的過程中,腦海裏浮現的都是編程隨想那篇文章 为什么马克思是错的?——全面批判马列主义的知名著作导读   https://program-think.blogspot.com/2018/09/Book-Review-The-Errors-of-Marxism-Leninism.html 兩者的思維鏈條、敘事方式,非常相似 人民聖殿教   https://zh.wikipedia.org/zh-hk/人民圣殿教?useskin=vector 瓊斯自稱是神的化身,幾千年前轉世為釋迦牟尼,創建了佛教;後來又轉世為耶穌基督,創建了基督教;之後短期化身轉世為巴孛,建立巴哈伊信仰;最後轉世為列寧,將社會主義發揚光大。 邪教徒聲稱自己轉世成了列寧,這說明了什麼? Apple Vision   https://stratechery.com/2023/apple-vision Omnivore   https://github.com/omnivore-app/omnivore Omnivore is a complete, open source read-it-later solution for people who like reading. How the YouTube Algorithm Works in 2023: The Complete Guide   https://blog.hootsuite.com/how-the-youtube-algorithm-works/#A_brief_history_of_the_YouTube_algorithm 外人眼中的YouTube推薦算法變遷 Histography   https://histography.io/ “Histography" is interactive timeline that spans across 14 billion years of history, f...

巴菲特致股东信-1973年

 笔记: 在上一年度预测的今年竞争加剧导致利润下滑,真的发生了 翻译Link: 雪球:https://xueqiu.com/6217262310/131257618 备份:https://archive.ph/KIfdT 原文: To the Stockholders of Berkshire Hathaway Inc.: Our financial results for 1973 were satisfactory, with operating earnings of $11,930,592, producing a return of 17.4% on beginning stockholders' equity. Although operating earnings improved from $11.43 to $12.18 per share, earnings on equity decreased from the 19.8% of 1972. This decline occurred because the gain in earnings was not commensurate with the increase in shareholders' investment. We had forecast in last year's report that such a decline was likely. Unfortunately, our forecast proved to be correct. Our textile, banking, and most insurance operations had good years, but certain segments of the insurance business turned in poor results. Overall, our insurance business continues to be a most attractive area in which to employ capital. Management'...

Steve Jobs introduced the iPhone on January 9, 2007.

This is a day I’ve been looking forward to for two and a half years. Link Every once in a while, a revolutionary product comes along that changes everything. And Apple has been— well, first of all, one’s very fortunate if you get to work on just one of these in your career. Apple’s been very fortunate. It’s been able to introduce a few of these into the world. In 1984, we introduced the Macintosh. It didn’t just change Apple, it changed the whole computer industry. In 2001, we introduced the first iPod, and it didn’t just change the way we all listen to music, it changed the entire music industry. Well, today, we’re introducing three revolutionary products of this class. The first one is a widescreen iPod with touch controls. The second is a revolutionary mobile phone. And the third is a breakthrough internet communications device. So, three things: a widescreen iPod with touch controls; a revolutionary mobile phone; and a breakthrough internet communicat...

犀流研习班第十期001-2讲听课笔记

一. 杂谈   1. Max  逼真的效果图和视频   2. SU  显示模式,费力可以作出好看的效果图   3. Maya  支持Nurbs,但不快捷,对CAD导出也不方便

产品随想 | 周刊 第69期:Do not go gentle into that good night

Products Windows Apps That Amaze Us   https://amazing-apps.gitbook.io/windows-apps-that-amaze-us/ 令人精细的Windows App 文物出版社   https://book.douban.com/press/2456/ 这是一个宝藏出版社,出品书籍质量非常高,大开眼界 blind   https://www.teamblind.com/ 老外的匿名职场社交工具,挺有意思,看看硅谷的meme 中国科学技术大学测速网站   https://test.ustc.edu.cn/ 看着还不错,挺靠谱的 底层代码是LibreSpeed   https://github.com/librespeed/speedtest 能不能好好说话?   https://github.com/itorr/nbnhhsh 也是我的一个痛点 Tree Style Tab (aka TST)   https://github.com/piroor/treestyletab 一个超强的浏览器扩展插件,树状呈现浏览器标签 Failory Pitch Decks   https://www.failory.com/pitch-deck 超级多的融资计划投资板,Pitch Book AutoCut   https://github.com/mli/autocut 用文本编辑器剪视频 全网漫游指南   https://tagly.notion.site/tagly/a333efd8c3e54e12b123acd541e8d3e6 数字时代的指引,希望他们成功 IT eBooks   https://it-ebooks.info/ IT书籍下载 ToastFish   https://github.com/Uahh/ToastFish 一个利用摸鱼时间背单词的软件。 利用Win10通知栏,出现、背单词 Ideas 沈向洋:IDEA 如何找到创新的「甜区」   https://mp.weixin.qq.com/s/OlI5VUxQKU_ijWZClQCG0Q AIGC How Did Nor...