跳至主要内容

折腾树莓派

作者:王震宇
链接: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 产品随想的博客

Apple's One-Dollar-a-Year Man, By Steve Jobs, 2000

(FORTUNE Magazine) – Now that Steve Jobs has showed his hand on Apple's Internet and system software strategies and dropped the "interim" from his title, other questions loom. He's always denied it, but isn't it true that his old company, Next, did wind up taking over Apple? Will there ever be an encore to the 15-year-old Macintosh? Short of that, does Apple have any plans to jump into the "Internet appliance" fray? Will Apple ever build computers for business people again? And what, pray tell, does Steve think of all these young Internet zillionaires? Let's ask. Practically every technology that your old company, Next, possessed when Apple acquired it in 1997 is now being used by Apple in some strategic way. This must seem like sweet vindication.  The thing about Next was that we produced something that was truly brilliant for an audience that our heart really wasn't into selling to--namely, the enterprise. I suppose if you were wr...

产品爱好者周刊 第26期:PRISM, XKeyscore, Trust No One

  Products Gitea - Git with a cup of tea   https://gitea.io/en-us/ A painless self-hosted Git service. 自建Git服务,避免GitHub隐私侵犯 https://github.com/objective-see/LuLu LuLu is the free macOS firewall 监视Mac的出站流量,且阻断 OverSight   https://github.com/objective-see/OverSight OverSight monitors a mac's mic and webcam, alerting the user when the internal mic is activated, or whenever a process accesses the webcam. 监视是否有应用调用Mac的麦克风、摄像头 Mozilla Hubs   https://github.com/mozilla/hubs The client-side code for Mozilla Hubs, an online 3D collaboration platform that works for desktop, mobile, and VR platforms. 开源的多人虚拟空间,Mozilla打造,企业级VR诉求 数字移民   https://shuziyimin.org 关于内容源、工具的推荐,适合刚接入国际的新人 SimpleLogin   https://simplelogin.io/ 匿名邮箱工具,转发用,Michael Bazzell推荐 Telegram 群组、频道、机器人 - 汇总分享   https://congcong0806.github.io/2018/04/24/Telegram/#机器人-bot https://archive.ph/iJMBj 献给那些将来到Telegram的朋友 Design Patrick Wardle   https://www.instagram.com/patrickwardle/?hl=en 他的IG,摄影也精彩,审美...

巴菲特致股东信-1980年

 笔记: 会计中对于下属股权公司的记账方式有3种: 持股50%以上,全部并入 持续20%--50%,则按持股比例并入 持股20%以下,则以实际收到的利润返还,计入报表 这种会计方式,会导致伯克希尔旗下,不少的企业,未能暴露实际的收益情况 对伯克希尔而言,对盈余的认定并非取决于持股比例是100%,50%,20%,5%或是1%,盈余的真正价值在于其将来再投资所能产生的效益 我们宁愿将所赚的盈余继续交由不受我们控制的人好好发挥,也不希望转由我们自己来浪费 高通货膨胀等于是对投入的资本额外课了一次税 翻译: https://xueqiu.com/6217262310/131837878 https://archive.ph/XMX5n  原文: Buffett’s Letters To Berkshire Shareholders 1980 巴菲特致股东的信 1980 年 Operating earnings improved to $41.9 million in 1980 from $36.0 million in 1979, but return on beginning equity capital (with securities valued at cost) fell to 17.8% from 18.6%. We believe the latter yardstick to be the most appropriate measure of single-year managerial economic performance. Informed use of that yardstick, however, requires an understanding of many factors, including accounting policies, historical ca...

写给大家看的中文排版指南

作者:Hindy 原文地址: http:// zhuanlan.zhihu.com/uici rcle/20506092 前言:很遗憾,我们的周围充斥着大量排版丑陋的文章。我国的字体排印与日本、美国等设计强国差距实在太大。我希望能够做些力所能及的小事,让更多人意识到“设计”的价值和其必要性,创造更美好的视觉环境。本文旨在帮助普及、提升大家对文字排版的认识,让大家在平时的学习工作中能有更专业的文字排版素养。 必看人群: 设计师、编辑、作家、撰稿人、教师、学生 目录: 1. 中文排版 1.1 引号 1.2 省略号与破折号 1.3 行首行尾禁则 2. 西文排版基础 2.1 西文撰写基础 2.2 西文标点相关 2.3 斜体的用法 2.4 大小写的区别 3. 中西文混排 3.1 基础原则 3.2 标点相关 1. 中文排版 1.1 引号 我国国家标准要求弯引号,个人建议使用直角引号。 示例:你竟然喜欢“苹果表”? 引号中再用引号使用双直角引号。 示例:我问他,“你竟然喜欢‘苹果表’?” 当引号表示讽刺、反语暗示时,使用弯引号(用法参考“西文排版”部分)。 示例:说真的,我也很 “喜欢”“苹果表”哦。 1.2 省略号(删节号)与破折号 省略号占两个汉字空间,包含六个点。 正确示例:中国设计还有太长路要走…… 错误示例:中国设计还有太长路要走… 破折号占两个汉字空间。 示例:中国设计还有太长路要走──加油罢。 1.3 行首行尾禁则 点号(顿号、逗号、句号等)、结束引号、结束括号等,不能出现在一行的开头。 错误示例: 排版时注意某些 符号不能在行首 ,别弄错了。 正确示例: 排版时注意某些 符号不能在行首, 别弄错了。 开始引号、开始括号、开始双书名号等,不能出现在一行的结尾。 错误示例: 她对我们说:“ 这书太赞了。” 正确示例: 她对我们说: “这书太赞了。” 2. 西文排版基础 2.1 西文撰写基础 句首字母大写。 单词间留空格。 示例:Have a question? 2.2 西文标点相关 点号后加一个空格(如逗号、句号等)。 示例:Hello everyone! Welcome to my blog....

产品随想 | 周刊 第130期:集结信徒,而非官僚

On Dyson, techno-centric design and social consumption   https://2earth.github.io/website/20250707.html 如何創造偉大的事物   https://ryolu.notion.site/1610a94b9c108079a95be4362afd4a26 集結信徒,而非官僚 Reflections on OpenAI   https://calv.info/openai-reflections 创业架构 Shui   https://github.com/rock-zhang/Shui 好好喝水 https://www.ghibli.jp/works/ 吉卜力作品的高清图 From Skeuomorphic to Liquid Glass: Apple's Strategic Bet on the Post-Touch Future   https://omc345.substack.com/p/from-skeuomorphic-to-liquid-glass 迄今为止关于苹果Liquid Glass变革的解读,最好的一篇 The Nueva School   https://en.wikipedia.org/wiki/The_Nueva_School?useskin=vector 看起来是很酷的一个学校 The Barbican   https://arslan.io/2025/05/12/barbican-estate/ 史蒂夫·乔布斯希望你阅读的 9 本书   https://www.douban.com/doulist/147158849/ 《禅者的初心》里有句话:“做任何事,其实都是在展示内心的天性,这是我们存在的唯一理由。” Chuck Feeney was one of the greatest philanthropists ever   https://www.gatesnotes.com/Remembering-Chuck-Feeney 慈善家 My new deadline: 20 years to give away virtually all my wealt...

A Sister’s Eulogy for Steve Jobs

I grew up as an only child, with a single mother. Because we were poor and because I knew my father had emigrated from Syria, I imagined he looked like Omar Sharif. I hoped he would be rich and kind and would come into our lives (and our not yet furnished apartment) and help us. Later, after I’d met my father, I tried to believe he’d changed his number and left no forwarding address because he was an idealistic revolutionary, plotting a new world for the Arab people. Even as a feminist, my whole life I’d been waiting for a man to love, who could love me. For decades, I’d thought that man would be my father. When I was 25, I met that man and he was my brother. By then, I lived in New York, where I was trying to write my first novel. I had a job at a small magazine in an office the size of a closet, with three other aspiring writers. When one day a lawyer called me — me, the middle-class girl from California who hassled the boss to buy us health insurance — and said his cl...

Steve Jobs: `There's Sanity Returning', 1998

Nobody can doubt the charisma of Steven P. Jobs. The interim CEO of Apple Computer Inc., who returned to the company last July after his ignominious 1985 ouster, has brought back his legendary vision, impatience, and infectious passion for the Macintosh. Jobs spoke to Business Week Correspondent Andy Reinhardt in Apple's stark, fourth-floor boardroom, just after the company rolled out its new software strategy on May 11. Note: This is an extended, online-only version of the Q&A that appears in the May 25, 1998, issue of Business Week. Q: Now that you've introduced the new, bold-looking iMac, are you going to do some radically different products? A: There's a lot of talk about such things -- about handhelds, set-top boxes. A lot of computer companies have been searching for a consumer product. My view is that the personal computer has been the most successful consumer product of the last 10 years. What we have to do, what the industry stopp...

产品随想 | 周刊 第127期:晨光只开一刻钟,但比千年松,并无甚不同

Cherry Studio   https://github.com/CherryHQ/cherry-studio Cherry Studio is a desktop client that supports for multiple LLM providers. Support deepseek-r1 Aalto Repository beta   https://repo.aalto.fi/ Images, sounds and videos from Aalto University 这个系列,价值极高 Nokia Design Archive   https://nokiadesignarchive.aalto.fi/ 芬兰这个国家很了不起 对话影石刘靖康:两代未出现划时代的产品,就会沦为平庸的品牌   https://www.geekpark.net/news/308996 还挺喜欢这个创始人的,有一种海盗的内涵 从哈佛、明星创业者到酷家乐副总裁,苏奇的传奇   https://app.modaiyun.com/mdy/article/3FO4K4W0M259 WHO关于猫狗咬伤、抓伤的处理建议 动物咬伤: https://www.who.int/zh/news-room/fact-sheets/detail/animal-bites 狂犬病: https://www.who.int/zh/news-room/fact-sheets/detail/rabies 关于狂犬病的10个事实: https://www.who.int/zh/news-room/facts-in-pictures/detail/rabies INDIGO 新年直播(2025)   https://www.youtube.com/live/ZIgPvSDGAfY 对2024年AI发展的回顾部分特别好 Artab   https://github.com/get-artab/artab Get Inspired by the World's Greatest Artworks Every Time You Open a New Tab. Extension Available for Chrome, Edge, and...

《Becoming Steve Jobs》Chapter 16 Blind Spots, Grudges, and Sharp Elbows

Steve could be pretty thin-skinned when someone prominent criticized the aesthetics of his products. He took great umbrage that Neil would, as Steve put it, “pop off in public like that without coming to talk to us about his technical concerns first.” From that point on he had rebuffed all of Neil’s attempts to smoke the peace pipe. 有趣 He had blind spots, grating behavioral habits, and a tendency to give in to emotional impulse that persisted his entire life. These characteristics are often used to make the case that Steve was an “asshole” or a “jerk,” or perhaps simply “binary”—that odd adjective often used to convey the sense that he was half asshole/half genius from birth to death. These aren’t useful, interesting, or enlightening descriptions. What’s more illuminating is to take a look at the specific ways in which Steve failed to do an effective job of tempering some of his weaknesses and antisocial traits, and to consider how, when, and why some of them continued to flare up even...

黑客技术论坛推荐

原文来自知乎, 世界各大黑客技术论坛TOP排行榜 ,表示感谢 这份名单基本上囊括了目前世界上各大最佳黑客技术论坛。