FireFox for Mac中文字体粗细大小不一的解决办法(默认英文)

我的Firefox for Mac 一直有这个问题,某些中文网站字体显示粗细大小不一。如图:

困扰我很久,参考知乎的答案:
https://www.zhihu.com/question/19586802

答案中的用户把中文zh放在了en之前,结果访问很多国外网站比如Airbnb, Kayak时,它们默认我来自中国(因为zh-cn排第一嘛)。把界面,货币等都默认为中国,对于在海外学习生活的我们不是很方便。

解决办法是:把en-US(如果在美国),en放在zh-cn之前。

这样访问英文网站没问题,中文字体也没问题。效果如下图:

设置Firefox / Preferences / Content / Languages

你也可以加入zh-hk,zh-tw以便访问这些地区的繁体网站。如图:

Seasons of Los Angeles 洛城四季

最后的叶子落下的时候 When last leaf falls
你和冬天一起来到我身边 Along with Winter you come to me
海都不动了 Ocean remains still
我把蓝天给了你 I give you sky
把蓝色留给自己 Leaving myself the blue

第一朵蓝花楹绽开的时候 When first Jacaranda blooms
你和春天一起拂过窗前 Along with Spring you pass my window
星都不闪了 Stars no longer glow
我把雪山给了你 I give you snow peaks
把冰川留给自己 Leaving myself the ice

排排棕榈摇曳的时候 When palm trees waver
你和夏天一起漫过沙滩 Along with Summer you rush to shore
鸥都唱累了 Seagulls tired of singing
我把浪花给了你 I give you breakers
把涛声留给自己 Leaving myself the tides

满树桔子红了的时候 When oranges turn yellow
你和秋天一起掠过山林 Along with Autumn you glide across ridges
大地都燃烧了 Land is burning
我把晚霞给了你 I give you sunset
把暮光留给自己 Leaving myself the twilight

最初的雪花融化的时候 When first snowflake melts
你走过四季回到我身边 Through four seasons you back to me
心稳稳在跳 Heart goes on beating
我把生命给了你 I give you my life
把意义留给自己 Leaving myself the meaning

——
第一段是本科时候在网上闲逛偶遇某人签名档,当时抄下来,作者无从查起。
后面四段扩写 作于 2018.2.10 洛杉矶

Template rendered html email for Web2py email verification and password reset

For discussion about this old problem, read Google group thread here.

I ended up modifying gluon/tools.py. It is probably not a good practice. But it is the easiest solution.

I edit register() and email_reset_password()

modifying something like (depends on which one)

message=self.messages.verify_email % d

to

message=('',response.render('email/template.html', d))

Be careful with the ending parentheses, the two functions need different number of them due to context codes.

It is important to use a 2-tuple or 2-list to pass the second item to html in the email, the empty '' will go to text. Otherwise, it will likely be sent as plain text, especially if you have <!DOCTYPE as start in your template.

for email_reset_password(), you also need:

response = current.response

Then you need to delete tools.pyc and restart web2py to take effect.

Make sure you modify tools.py and delete tools.pyc every time you update web2py.

Hope this save some other people’s time.

Force SSL/HTTPS and non-www in web2py

Update 02.08.2018: Code is updated to use just one line to force https:

request.requires_https()

=======

I read this

https://groups.google.com/forum/#!topic/web2py/RzJ4pYtAWF4

and

https://stackoverflow.com/questions/26802850/pythonanywhere-web2py-redirect-to-https

then I realized “cronjob” problem described in these answers are no longer relevant since `scheduler` has long since replaced `cron`

I created a new model secure.py and add:

########## FORCED SSL non-www ##########
session.secure()
if not request.is_https:
    redirect(URL(scheme='https', args=request.args, vars=request.vars))
request.requires_https()
if request.env.http_host.startswith("www."):
    redirect(URL(host=request.env.http_host[4:]))
#####################################

I skipped the cron part since scheduler has long since replaced cron in web2py.

I created separated model so I can specify only to have it on my server, not on my local macbook, using .gitignore (see #2 below)

2. I need only to use https at server, not local development environment (127.0.0.1:8000), so I put models/secure.py into my .gitignore

Hope this helps!

China Vibe

Vined / Pixabay

Original: Walk Off The Earth – Summer Vibe
Adapted by Yi Liu

EH-O, EH-O, EH-O, BOP BOP AWAY-O

China vibe, China vibe
I’m looking for a China vibe, got me boarding Hainan Airlines, I gotta mute those twits
Jet lag all day, trying to stay awake, wishing these smog away
I wander around Hou Hai, visit royal palace
Take a walk in Peking U, with nothing else to do
But sitting by Weimin Lake, reading a book, off the girls keeping my eyes
Taking my time

With you by my side
A Mobike ride
Cycling with the girls
Street food at night
China vibe
Looking for a China vibe

Friends paid my meals
No reason to be shamed
Bragging on the table, just listening to you
China vibe
Looking for a China vibe

I’m jonesing for clean fresh air, High Speed Rail all down to HangZhou, I’ll find friend’s place to stay
Gonna somehow, find a public square, dance this old night away
We’re drinking LongJing at Farmer’s House, tea trees all up on the hills, under the bluesky
Taking my time

With you by my side
A wood boat ride
Paddling with the girls
West Lake moonlight
China vibe
Looking for a China vibe

Kid paid our dues
With award she earned at school
Riding on dad’s back, just staring at you
China vibe
Looking for a China vibe

And the train arrives home
But I’ll leave again tomorrow
Oh
EH-O, EH-O, EH-O BOP BOP AWAY-O

With you by my side
A Didi ride
Jamming with the girls
Karaoke all night
China vibe
Looking for a China vibe

Love my parents
Got nothing to prove
Sitting by your side, just listening to you
China vibe
Looking for a China vibe

EH-O, EH-O, EH-O BOP BOP AWAY-O
China vibe, China vibe

EH-O, EH-O, EH-O BOP BOP AWAY-O
China vibe, looking for a China vibe

Securing Web2py with Let’s Encrypt / Certbot

In case anybody wondering the same question about using certbot/let’s encrypt and web2py: how do you serve the .well-known folder for certification, when all the request goes to wsgi handler?

1. use `–standalone` as David advised. But you have to stop the web server every time you renew.

2. instead, you can use the standard `–webroot` method. Here, you need to edit your vhost file be it apache or nginx, add a location block:

Using nginx for example:

location /.well-known {
    root /home/www-data/web2py;
}

This way, nginx will server the .well-known and skip passing it onto uwsgi/web2py. Make sure you restart nginx after making this server conf change and use

sudo certbot certonly/renew --webroot -w /home/www-data/web2py -d example.com -d www.example.com

Passenger WSGI setup with pyenv on Dreamhost for Web2Py

I have been using fastcgi+flup (link) to run my web2py apps on shared Dreamhost hosting. But the speed was really mediocre. Dreamhost recommends Passenger WSGI for python application.

After hours of research and testing, I would like to share my experience using pyenv + passenger wsgi + web2py on Dreamhost shared hosting as of 08.2017

What I did differently than most guides online is that I only have to edit .htaccess file (in domain root folder) with: (Credit: ASO)

PassengerEnabled on
PassengerAppRoot /home/%USER%/
PassengerPython /home/%USER%/.pyenv/shims/python

Most importantly and strangely, I didn’t need to modify passenger_wsgi.py (handlers/wsgihandler.py) at all. Most guides online (this; this; and many others) require adding two lines after import os, such as this one:

INTERP = "/home/%USER%/.pyenv/shims/python"
#INTERP is present twice so that the new Python interpreter knows the actual executable path
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)

But I couldn’t make it work if I modify passenger_wsgi.py. It seems .htaccess is sufficient to specify pyenv environment.

Some guides also suggest make a pyenv “virtualenv” within app folder, I found it is not required.

Assuming you already know:

  1. how to use web2py
  2. how to use pyenv on Dreamhost
  3. Read about Passenger on Dreamhost

This is what I did:

  1. Enable passenger on Dreamhost panel. A folder public will be created. Don’t worry.
  2. Put web2py files into your domain root folder, which is parent folder of public
  3. cp handlers/wsgihandler.py passenger_wsgi.py
  4. Create/modify .htaccess in domain root folder as described above.
  5. Created tmp/ folder under my web root folder, did a touch restart.txt to get passenger to reload

Your web2py site should now load in your browser. If you use free “Let’s Encrypt” SSL from Dreamhost panel, you should be able to verify your pyenv python environment from admin interface by accessing https. I did verify mine.

I am not sure ssh tunnel method could serve as verification, because you are serving admin from a separate web2py instance running from your shell.

Hope this will help fellow web2py users. Thank all the web2py team for providing web2py.

Add Bluetooth or Inline Remote Mic Cable to Koss KSC75 Headphone

Koss KSC75 is a legendary on-ear clip headphone. It provides stunning high-fidelity sound with unbeatable price. All the 5 star reviews say it all.

I have two of these. One had a wire problem near the plug. I need to replace the cable. I always want to add inline remote and mic to the KSC75 so I can use the headphone more conveniently with my smartphone.

For the other one, which is still perfectly working, I want to convert to a bluetooth headphone. Here is what I have after some simple sodlering.

Opening KSC75:


You carefully remove the ear clip and plastic cover to reveal the solder points.

Inline remote and mic cable KSC75:

I bought this DIY inline remote and mic cable from AliExpress for less than $3.

Bluetooth KSC75:

I bought this DIY bluetooth cable from AliExpress for about $11. It is bluetooth 4.0. Now I have both the convenience of Bluetooth and superior sound of KSC75.

怎样办一个交流型读书会

Book Club by J. Bedford @ Flickr https://flic.kr/p/387xxz

rev.2017.08.08

为什么?

在张罗怎么办一个读书会之前,先要思考下为什么要办读书会。不同于学校图书馆书店等机构办的讲座型读书会,草根的交流型读书会至少有三个好处:

  1. 接触了解更多的书。好书很多:有些书你知道好但没时间读,有些书你知道但不知道它的好,有些好书你完全不知道。在读书会平台下,分享者可以用三十分钟的时间帮你概括一本书。
  2. 接触了解更多的爱书之人。和吃饭打牌插科打诨不同,对书的交流,能更深的了解一个人的价值观和思想层次。

你如今的气质里,藏着你曾走过的路,读过的书和爱过的人。

  1. 锻炼组织领导能力。如何依规管理,如何听取意见,如何让每个人发挥特长,如何营造团结融洽的关系,这些都可以得到锻炼。

要申明一下,我们的交流型读书会不是通常的大家一起读一本书之后交流心得。此种规定太死的读书会有一些问题:

  1. 不是每个人都喜欢规定的书。
  2. 不是每个人都喜欢在规定的状态下读书。
  3. 不是每个人都能在规定的时间内读完。
  4. 不是每个人都能深切体会和表达一本规定给自己的书。

这些限制导致了常见的book club failure — 读书会魔咒。我们的交流型读书会希望5位分享者各带一本自己最喜欢的书,从而真正达到“交流”的目的。

Ref: Why Should You Host a Book Club?: INFOGRAPHIC

要素

核心价值

读书会的核心价值是“书”。读书会的活动应该围绕“书的交流”展开。作为组织者,要防止讨论跑偏,活动沦为吃饭聊天打牌。即使因为节日等需要吃喝玩乐,也要穿插跟书有关的活动。

以人为本

高质量的读书会,离不开高素质的爱书之人。读书会的规则制定,活动管理,友谊交流都要以“去伪存真”为目的。让不合适的人进来有如下坏处:

  1. 浪费参与名额
  2. 拉低活动质量
  3. 驱离高质量的参与者
  4. 增加组织者管理成本

另一方面,一旦有了高素质的群体。“二十一世纪最重要的是人才。” 在规则下,给大家自由空间,放手让大家发挥,你会发现自然而然读书会就迸发出思想碰撞迷人的火花。

依托平台

如果你目前还没有一个爱读书的群体,或者你办的是一个面向公众开放的读书会,你需要找到一个平台来进行推广。

我开始办的时候先从朋友里面找,发现个人的社交圈有限。首先读书的人是少数,其次不是每位读书的朋友都愿意来分享,愿意来分享的也不一定正好有时间。所以,你需要一个足够大的社区来支持。

于是我把读书会办在了Hiking+U大洛杉矶区登山俱乐部旗下。这个平台覆盖了本地1000+热爱户外活动充满正能量的华人群体。

另外,我把参加过活动的组成一个Alumni微信群。参加过的人已经用分享和赞助费证明了他们的积极性,并且对活动规则和其他会员相对熟悉。优先让alumni报名可以保证活动的连续性,避免对活动缺乏了解的新人过多。

合理收费

如果你的读书会是一个开放的读书会,从一开始就必须收费。免费活动坏处多:

  1. 免费活动的放鸽子率高达40%。
  2. 免费活动吸引错误的人群。
  3. 免费活动劣币驱逐良币。
  4. 免费活动很难传播组织推广。
  5. 免费活动很难在经济上持续。

详见这篇文章:
To charge or not to charge? The psychology of free vs. paid events

分享者名额重要,我收取$20押金。迟到扣$10, 迟到一刻钟全扣。按时参会退还。

旁听者因为没有分享贡献,收取$10赞助费用。

收上来的费用,主要用于奖励最佳分享者,也可以用于准备食物茶水。我办的读书会全部费用拿来奖励。食物茶水是我个人对大家分享讨论的感谢。

依法治会

制定规则。所有人必须按规则行事,才能有效管理组织。这里特别考验组织者的能力:如何严格执行规则不受他人影响?如何虚心听取建设性的意见?我的心得是:“一切为了读书会”。

严格执行。一部得不到执行的规则是没有意义的。例如,到了点就开始,不能等。

适度调整。根据实际运作的情况和大家的反馈可以调整规则。比如我一开始限制必须是non-fiction非虚构类书籍。后来尝试每次一本fiction,发现fiction也可以结合背景知识展开讲得很精彩。我们就放宽了对fiction的限制。

标准操作规程

通告报名

提前3周的时候,在alumni群(过去参加过活动的成员群)里宣布下期活动的时间地点,征集报名。给alumni群两到三天的deadline. 过之后把剩余的名额放到外部大群中,征集新人报名。

活动时间:

  1. 应选在相对固定的日期。这样大家能够合理的预期并安排自己的日程。我们读书会基本是在每月第二个周日,这个日子和美国的节日冲突较少。若碰到新年、老兵节假期或其他原因报名情况不佳,可以相应调整时间。
  2. 最好选择上午9-12点。
  3. 和普通聚会通常在晚上不同,读书会需要举办在头脑清醒高效的时段。
  4. 把读书会办成早上第一件事,可以避免因其他事情延误导致的迟到。
  5. 办在早上需要早起。可以自然地把动力不足的人筛选掉。肯早起参加的都是真心想来的人。

地点:

选在大家方便的地点即可。设施满足10个人3-4小时的交流。可以在学校公司小区的会议室,也可以轮流办在会员的家里。

人数:

社会学研究表明,为保证高效的群体交流,群体的最佳人数应控制在7±2 也就是 5-9人。相应的,我把读书会的分享者定为5人,旁听4-5人。根据我的经验,经常会有一人出现紧急情况无法赴会。

参考:
The Magic Number For Meeting Attendees
The right size for any party

每次聚会的人数之外,还有一个总群体的人数。这个比较难控制,我们还在摸索阶段。可以参考:

What is the right size for a book club?

收费:

用常用的平台收取押金和赞助费用。作用见上述“要素-合理收费”部分。

书目

报名分享的人应尽快确定所分享书目并告知活动组织者。

准备:

分享者需要准备的内容:

30min is your show time. You decide how to present it. A few examples:
• Read an excerpt (highly encouraged)
• Tell a summary
• Background info about author
• Your reflection
• Online reviews
• Powerpoint slides
• Ask audience questions

分享者水平会高低不齐,大家都能理解。每个人都有一个学习提高的过程。要求分享者提前做一些准备,自己梳理一下书的背景信息,分享内容,主次重点,逻辑条理,主要结论,你的发散思考,还有和听众的互动等。把分享的半小时作为一个锻炼自己public speaking的机会。每一位勇于分享的同学都值得嘉奖,相信适当的准备能让你更有收获!

组织者需要做的准备:

  1. 食物:水果糕点茶水。用来润喉、补充能量。
  2. 制作program。Program用来通知大家分享活动的流程,交通信息等参加活动的注意事项。至少提前一天发给所有人。
  3. 制作award。制作奖状给最佳分享者,名字空出来。等活动末尾选出来之后手写填上最佳分享者名字。
  4. 设好投票。用doodle或类似的投票平台。

活动当天

  1. 到达。不要等迟到的人。一旦等了,以后迟到的会越来越多。
  2. 开场。大家简要的自我介绍。
  3. 上半场。每个人半小时的分享时间。
  4. 休息。
  5. 下半场。
  6. 讨论与主持人的作用。在讨论的过程中,由分享者主导话题。当分享者对讨论失去控制时,主持人要果断介入。比如:1) 讨论偏题或无关话题 2) 讨论单个人用时太长,喧宾夺主,或言之无物 3) 半小时快用完。
  7. 投票选出最佳分享者2人左右,颁奖,合影。

活动之后

  1. 聚餐交流。正式的活动之后已中午。大家可以一起去附近吃饭,在更轻松的氛围下交流下今天的心得或朋友们的近况。
  2. 总结。写一下本次活动的札记,以备存档,公开发布或将来参考。
  3. 下次活动预备。讨论下次活动的备选时间地点和分享主题。
  4. 退还押金给分享者,发放奖金给最佳分享者。

读书会之外

猜书名游戏

  1. 节选段落猜书名:可以完全不给提示,可以口头给提示,可以给选项连线。
  2. 封面、插图猜书名:示例一:封面示例二:插图
  3. 书名谜语
  4. 场景对诗

朗诵会

静默读书会

只读书,不交流,无压力。可以在酒吧,咖啡厅,茶馆和公园进行。

参考 SilentBook.club

 

上面是我办Hiking+U读书会的一点心得,欢迎大家多提宝贵意见。

愿大家都来读书,办读书会,在读书会中以书会友!