根据维基百科咖啡是采经过烘焙过程的咖啡豆(咖啡属植物的种子)所制作冲泡的饮料,是人类社会流行范围最为广泛的饮料之一。咖啡中咖啡因对人体有刺激的作用,人们在学习、阅读和思考等脑力活动时经常用来提神。大部分的研究建议,适度饮用咖啡是有益的,甚或有利于健康的成年人。

咖啡的种植首次发现于非洲埃塞俄比亚,最早的可信证据出现于 15 世纪也门的伊斯兰教苏菲派(Sufism),在非洲之角及也门,咖啡被用于当地的宗教仪式。17世纪咖啡的种植和生产一直为阿拉伯人所垄断,在欧洲价格不菲,只有欧洲上层人物才能饮用咖啡。大航海时代由欧洲殖民者扩散到东南亚与南美洲殖民地,因大量生产而价格下降的咖啡开始成为欧洲人的重要饮料。

简介完毕,下面分别讲讲各种常见的咖啡形式。

Read More

When you want to setup proxy to debug network traffic as you do in developing native apps, you will find there’s no traffic comming through. The reason why this happens is that the proxy configuration in Andorid or iOS Wifi network settings don’t affect Flutter.

So we have to set up the proxy in our Flutter app. Luckly it’s just a piece of cake with the code below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class MyProxyHttpOverride extends HttpOverrides {

String _ipAddress;

MyProxyHttpOverride(String ip, String port) {
_ipAddress = '$ip:$port';
}

@override
HttpClient createHttpClient(SecurityContext context) {
return super.createHttpClient(context)
..findProxy = (uri) {
return "PROXY $_ipAddress;";
}
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
}
}

void main() {
HttpOverrides.global = MyProxyHttpOverride("192.168.1.xxx", "8888");
runApp(MyApp());
}

Important things to know:

  1. HttpOverrides.global must be set before using any HTTP methods
  2. If proxy configuration (IP or port) is changed during using, the app has to be killed and relaunched for the new configuration to take effect
  3. For HTTPS, certificates are loaded from the OS, same as native apps

When you are searching for AWS Cognito SDK that can be used in Flutter, you will soon be shocked that there’s no official support yet. According to a thread in AWS forum, one guy says:

I work on the AWS SDK team. I am not aware of any plans to support Flutter at this point. I will take this to my team as a feature request and will post back on this thread/or through a general forum announcement if our plans change in the future.

This is still true as of TODAY (October 2019).

So there are two community packages out there, which are amazon_cognito_identity_dart and flutter_cognito_plugin. The former is a pure Dart one translated from AWS official Javascript SDK, with good examples, but last active date was 7 months ago. The latter uses native Android and iOS AWS SDK by wrapping them into MethodChannels, still activily in development.

TL;DR

I chose amazon_cognito_identity_dart out of its pureness in Dart, the first try was successful. But later on found 2 major issues, all fixed in my fork. If you are not interested in the details, you can check that out and follow the usage there.

Read More

Situation: I have an existing iOS app and an Android counterpart, and will be moving to Flutter to leverage the cross-platform ability. But there’s a new feature has to be added on time, is there a future-proof solution that I can avoid re-writing the same feature later on?

The answer is YES, IF it does not rely too much on communication with existing apps. So we can do:

  • Develop the new feature using Flutter
  • Add the new Flutter module into existing native Android and iOS apps
  • Write platform specific code in Flutter, and/or add bridging code to Flutter and/or native apps as required
  • Reuse this Flutter module in the future unified Flutter app

Read More

宝宝出生对每个家庭来说都是一件大事,新手爸妈没有经验更可能手忙脚乱不知所措。这里预习一下在新西兰的医院生孩子的流程是啥,从中也能看看西方发达国家的一些人性化的关怀。

怀孕前期

怀孕前三个月归家庭医生 GP 管,平时看家庭医生是需要一定费用的,有的便宜诊所可能十几刀,贵的有六七十刀,但是怀孕期间完全免费。一般自己在家里用验孕棒两个星期左右都是阳性就可以确定怀孕,这时可以预约家庭医生,医生会做一些基本检查,还有告诉你简单的怀孕期间需要注意的事项,特别是食品安全方面的;告诉你要找助产士,怀孕 3 个月以后主要由助产士负责。还会给你一个本地 bounty.co.nz 怀孕知识网站赠送的怀孕小礼包,主要有一本书按怀孕周数写着实用小知识的手册 Your Pregnency,还有产后妊娠纹修复霜(palmer’s)、宝宝屁屁霜(sudocrem)的试用装。

Read More

UPDATED: Updated for Flutter v1.9.1.

TL;DR: this guide gives a real example (which is a minimized version that comes from our real project) when you follow the Official wiki: Add Flutter to existing apps, covering some common issues you might have. Check out the full FlutterHybridExample in Github to see what it looks like when done.

Consider this situation, you have an app that works for both Android and iOS platforms, you developed them in a native way to get the best performance and user experience possible. Then one day you need to add a new feature to make it more attractive, which means the same thing has to be done twice, one for each platform. You heard of fancy and shinny stuff - Flutter that promises to work for both platforms and claims to bring native performance. But you can’t afford the time in totally rebuild the app, you still need to keep things running for existing users, just like doing an open heart surgery. So my answer is:

  • Develop the new feature using Flutter
  • Add the new Flutter module into existing native Android and iOS apps
  • Write platform specific code in Flutter, and/or add bridging code to Flutter and/or native apps as required

Read More

总评分:4.5/5 设定合理,剧情紧凑、一波三折,主角神演技,镜头构图佳

社畜友好指数:5/5 看完充满正能量,搬砖力量+10086

鸡汤指数:5/5 营养全面,纯天然鸡血不尴尬

《陆王》是日本商业小说家池井户润的一部小说,故事开头是老年企业家在时代大潮下原来从事的行业越来越不景气,导致员工流失、订单不断减少、银行融资断绝,不得不再次裁员……

池井户润早年在日本最大之一的三菱银行工作,所以对金融、银行有比较深的了解,善于包装金融知识融入小说剧情中,有些甚至来源于真人真事,能做到保持一定合理性的同时有很强的戏剧性。代表作是《半泽直树》系列,特点是结局一定是喜剧,但过程绝对一波三折,跌宕起伏,明知他是套路你却有欲罢不能,最适合社畜阅读解气,剧中名句是“加倍奉还”。

1. 老年危机悄然降临

主角宫泽紘(hong2)一是一个五十多岁的大叔,有一个大学刚毕业的儿子和一个还在读高中的女儿。经营着一家有着 20 名员工的小型乡镇家族企业——小钩屋,比起全盛时期 200 名员工仅余十分之一,作为百年老店的第三代继承者的宫泽大叔生意一直没什么起色,仅仅是勉强维持生计。而且公司产品足袋,也就是日式二趾袜,是一种传统商品,年轻消费者嫌老土,销量逐年下降。就像温水煮青蛙,危机一步一步的开始降临这家百年老店;公司独特的合脚缝纫技术也无用武之地,如同石器时代结束不是因为石头采光,而是不在需要石头了。主角也就等待着企业在自己这一代慢慢凋零,甚至让自己儿子不要继承家业,自己出去闯荡。要知道日本人对家业看得很重,当作是自己家族荣耀的。

社长奔跑的背影贯穿全剧,一直在救火一直在奔走

Read More

The problem

Starting from at least version 3.1.3 of Android Sutdio, the local jar/aar library refresh mechanism seems to be broken.

The situation is I have a local aar library named my-lib.aar, which is my product, placed under $project_root/app/libs. Whenever I change the code I will compile a new aar library and replace the old one with the new. It was awesom before Android Studio 3.0.0, the IDE can recognize the library has changed and load it automatically, so what I need to do is just hiting the run button then a new app with my new library will get built and run. However, with 3.1.3 and it is still broken in the latest 3.1.4 released August 2018, the aforementioned process will end up with the app built with the old library.

The fix

After experimenting a while, the easiest workaround is to delete the IDEA cache config file for that library, which is $project_root/.idea/libraries/Gradle__your_package_name_version.xml. Optinally, you can also delete cache file at ~/.gradle/caches/transforms-1/files-1.1/your_lib_name.aar, which just eat up a bit of your storage but won’t mess up your build. Tested with MacOS, should also work for Linux OS.

关于新西兰的信息有点割裂,用现在的话说是“精分现场”。在来之前查到的移民、留学介绍说得像天堂一样美好,什么“从摇篮到坟墓的福利”,免费医疗、免费教育不用花一分钱,还有各种福利补贴。等到过来后直呼上当,当地自媒体微信公众号总是渲染医疗又贵又慢、医生技术差,到处都有劫匪抢劫,学校教育懒散等等。前后描述的似乎不是同一个地方。这是因为前者为了做成生意,夸大宣传,故意隐瞒了领取福利的条件;后者为了吸引眼球骗点击,故意渲染事件严重性,把个案说成普遍现象,一直看这种媒体会有种吃枣药丸的感觉。其实这两个极端的信息都是不准确的,对于真正有困难的人来说,例如残疾、孩子特别多的家庭,福利确实比国内好很多;而对于勤劳工作的普通中产阶层,福利接近于无

其实问题核心是权利和义务对等,常识是一个国家福利水平高那税收肯定也高,所谓取之于民用之于民;福利低的国家税收也低,更有利于人民发挥创造力,谋求个人发展。就算不考虑贪污腐败,如米尔顿·弗里德曼所说,“拿自己的钱替自己办事,最为经济;拿自己的钱替别人办事,最为有效(注:例如送礼给人总倾向于送好的,经常超出接收人需求);拿别人的钱替别人办事,最为浪费”,政府属于最浪费那种“拿别人的钱替别人办事”中间还要收佣金。对于信奉自由派市场主义观点的人来说,福利来源于你我缴纳的税,低福利才是符合常识的,意味着更低的税负水平,但同时遇到意外变故时又有基本的有尊严的生活保障。

Read More

What you should do after moving into your shiny newly built house in New Zealand? Get it connected!

Post office

The new address usually is not added into post office’s internal address book immediately, which will cause inconveniences to us. For example, letters can not be sent to our new address simply because there’s no such on in the system! Also we won’t be able to receive credit card statements, utility bills etc.. What’s worse, a lot of third parties rely on post office’s system, so they won’t be able to provide service! For example, if you want to order a household garbage bin from companies like Waste Management, they won’t serve you until the address is added.

Usually it takes several weeks for the post office to recongnize your new address, what we can do here it to report the address to speed up the process. They will send a postman to investigate to see if such an address exists or not, then update their address book accordingly.

Read More

总有那么一首歌,总会是不是的触动人心底最柔软的心,对于离开家乡在外打拼、一年甚至几年才能回家看望父母家人一次的游子来说,《ありがとう(谢谢)》就是这么一首歌。旋律优美、歌词平白如开水,却又能让你品尝出各种滋味,甜美又苦涩。其实这不是开水的味道,而是自己人生的百味。这首歌不忍多听,容易勾起乡愁;但是放下一段时间,无意中在深夜里随机播放的播放器中想起,总能轻易的穿透人们名为懂大局、识大体、分轻重、看长远的厚重装甲。然后只能关上灯,只为看不到自己流泪的样子。我是一个理性神经异常发达的人,从不发怒,以为理性沟通远比情绪宣泄更能达成合作,但是对这首歌却完全没有免疫力。以为自己已经习以为常了,许久不听再次面对着熟悉的旋律还是猝不及防。

下面是自己歌词翻译(网上能找到的翻译包括网易云音乐的版本感觉翻译有点机械,所以重新翻译一遍):

Read More

声明:下面包含大量《三体》剧透

《三体2》中罗辑终于找到了与三体这个科技远比人类发达的文明博弈的筹码——宇宙广播,一旦触发基于黑暗森林法则,宇宙中更先进的文明一定会灭掉三体文明,但同时不久后地球也必然遭到同样的毁灭性打击。这是一种恐怖平衡,博弈成立的关键在于执剑人——罗辑是否有决心触发广播,一旦三体人确信执剑人没有同归于尽的觉悟,那么三体人一定会向地球发动攻击。这真是一个微妙的位置,为了两个文明和平共处,必须有同时毁灭两个文明的觉悟。

罗辑的威慑力建立在三体人看不透他,吊儿郎当、玩世不恭,心里全然没有人类命运这些宏大的东西,只想过好自己当前的生活。作为面壁者的时候也是,一心隐居和心爱的人过着小日子。正是因为他没有这种对全人类的大爱,才让他有能力当好执剑人,一旦三体人轻举妄动他会毫不犹豫的触发广播。面对这个看不透、不知底牌的对手,三体人始终没有机会下手。

到《三体3》人类度过数十年和平的日子后,危机感已经完全消退,没几个人真心相信会和三体人再发生冲突,放弃掉自己唯一的博弈筹码。在这个背景下,程心成为了第二任执剑人。三体人看在眼里,马上对地球发动攻击摧毁了所有威慑广播设施,大家这才明白三体人一刻也没有停止入侵计划,苦等数十年就是为了这一刻。

Read More

有线与无线

有线工具需要连接插座,体积较大、不方便移动,但胜在价格便宜、动力强劲,不常用的可以买有线。无线的就是锂电池驱动,主要分 10-12V 和 18-20V 两种,更低电压的力量不足只能上螺丝(例如组装宜家家具);更高电压的 36V 甚至 54V 重量太大一般是专业人士用来替代有线工具的,价格昂贵。

12V 电钻带电池一般只有 1 公斤,可以打 10mm 以下的孔、上螺丝,可作为第一把电钻购买,更低电压的就没必要购买了。个人 DIY 主力是 18V 电动工具,带 2.5Ah 小电池一般 1.5 公斤左右,比 12V 重了不少,但钻孔能力已经可以和有线媲美,可使用 13mm 以下直径的钻头。

12V Bosch GSR120-LI 18V Ryobi
夹头尺寸 10mm 13mm
金属钻孔能力 10mm 13mm
重量 1kg(1.5Ah电池) 1.5kg(2.5Ah以下薄电池)
最大扭力 20Nm 45Nm
套装价格 ¥399RMB(带1.5Ah电池x2,充电器) $198NZD(带2.5Ah电池x2,充电器)

无线电动工具就像单反相机与镜头一样,看中的是系统完整程度,同一个系统的电池可互换,所以充电器、电池买一套,以后就能用在各个电动工具上,完整的系统都会包含 Drill, Impact drill, Impact driver, Impact wrench, Circular saw,甚至还有 Line trimmer,手持吸尘器等数十种工具。

Read More

KiwiSaver 是什么

KiwiSaver

新西兰永久居民所享有的政府养老金仅相当于目前最低工资的 70% 左右。具体说按照 2017 年颁布的标准,单身独居的个人每周税后可领 $390.20,所以要想过得宽裕就要依靠自己的储蓄。KiwiSaver 就是政府推出的补充养老金储蓄投资计划,类似于美国的 401k 计划,让你每个月定期存款进行投资,等退休时你的存款加上投资的回报应该会对生活有很大的帮助。

那么和自己投资买股票有什么区别吗?干嘛要把钱交给官僚机构管理?

Read More

这篇文章说说在大农村新西兰买房后如何添置家电,介绍家电基本知识、知名品牌和价格,也会穿插介绍当地一些生活习惯。

前言

年轻的时候整天看牛刀时寒冰之流的文章,当年踮踮脚就能够得着深圳房价的时候没有入手。也不能怪人家写文章的,人家不骗不抢又没问你要钱,是自己投资理财观念没有建立起来,所以 2016 年初顺利定居新西兰后第一件事就是买房。以前老是被媒体文章欺骗,其实国外很多地方房子挺贵的,例如新西兰最大城市奥克兰房价中位数就在 500 万左右(所有价格按当前汇率 4.7 折算,下同),好在首付只要 20% 加上房价已含精装修及基本厨房家电,只要添置少量家电和家具就能入住,所以首付的压力比在深圳小一点,而且不用管装修那些烦心事。

建房流程

Read More