Remap right Option key as Ctrl on MacBook

Right Option key is almost useless for me and the built-in keyboard lacks a right Ctrl key.  I find Karabiner. It works perfectly!

[2014.9.25 update] I find Karabiner could alter behavior of  USB mouse. As we know, ‘Scroll direction: natual’  is really nature for MacBook’s trackpad, but not that nature for mouse wheel.  Karabiner could retain normal wheel behavior while keeping trackpad ‘natural’

My setting is attached

Screen Shot 2014-09-25 at 10.53.48 PM

Firefox多个用户配置文件(Profile)的设置

工作后,在同一个浏览器里同时浏览工作内容和私人内容多有不便。Firefox提供了启动时选择Profile的选项。以OS X为例

$ /Applications/Firefox.app/Contents/MacOS/firefox-bin -P personal -no-remote

这样在启动时可以直接选择personal这个profile。不同profile的插件、浏览记录等完全互相独立。

还可以把这行脚本简单包装成一个OS X的App。细节如下。Info.plist拷贝自/Applications/Firefox.app/Contents/Info.plist并作简单修改(粗体标出)。如果没有它,BetterTouchTool无法对启动的Firefox窗口提供Snapping功能。另外可以自行制作.icns图标放到”/Applications/Firefox(p).app/Contents/Resources”。

$ mkdir “/Applications/Firefox(p).app”
$ mkdir “/Applications/Firefox(p).app/Contents”
$ mkdir “/Applications/Firefox(p).app/Contents/MacOS”
$ mkdir “/Applications/Firefox(p).app/Contents/Resources”
$ cat “/Applications/Firefox(p).app/Contents/MacOS/Firefox(p)”
#!/bin/bash
/Applications/Firefox.app/Contents/MacOS/firefox-bin -P jinyao_personal -no-remote
$ cat “/Applications/Firefox(p).app/Contents/Info.plist”
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>html</string>
<string>htm</string>
<string>shtml</string>
<string>xht</string>
<string>xhtml</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeName</key>
<string>HTML Document</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>HTML</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>svg</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>image/svg+xml</string>
</array>
<key>CFBundleTypeName</key>
<string>SVG document</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>TEXT</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>NSDocumentClass</key>
<string>BrowserDocument</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>text</string>
<string>txt</string>
<string>js</string>
<string>log</string>
<string>css</string>
<string>xul</string>
<string>rdf</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeName</key>
<string>Text Document</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>TEXT</string>
<string>utxt</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>jpeg</string>
<string>jpg</string>
<string>png</string>
<string>gif</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>fileBookmark.icns</string>
<key>CFBundleTypeName</key>
<string>document.icns</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>GIFf</string>
<string>JPEG</string>
<string>PNGf</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>oga</string>
<string>ogg</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>audio/ogg</string>
</array>
<key>CFBundleTypeName</key>
<string>HTML5 Audio (Ogg)</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>ogv</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>video/ogg</string>
</array>
<key>CFBundleTypeName</key>
<string>HTML5 Video (Ogg)</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>webm</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>document.icns</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>video/webm</string>
</array>
<key>CFBundleTypeName</key>
<string>HTML5 Video (WebM)</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>firefox(p)</string>
<key>CFBundleGetInfoString</key>
<string>Firefox 32.0</string>
<key>CFBundleIconFile</key>
<string>firefox(p)</string>
<key>CFBundleIdentifier</key>
<string>org.mozilla.firefox</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Firefox(p)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>32.0</string>
<key>CFBundleSignature</key>
<string>MOZB</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLIconFile</key>
<string>document.icns</string>
<key>CFBundleURLName</key>
<string>http URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>http</string>
</array>
</dict>
<dict>
<key>CFBundleURLIconFile</key>
<string>document.icns</string>
<key>CFBundleURLName</key>
<string>https URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>https</string>
</array>
</dict>
<dict>
<key>CFBundleURLName</key>
<string>ftp URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ftp</string>
</array>
</dict>
<dict>
<key>CFBundleURLName</key>
<string>file URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>file</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>3214.8.25</string>
<key>NSAppleScriptEnabled</key>
<true/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>LSMinimumSystemVersionByArchitecture</key>
<dict>
<key>i386</key>
<string>10.6.0</string>
<key>x86_64</key>
<string>10.6.0</string>
</dict>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>NSPrincipalClass</key>
<string>GeckoNSApplication</string>
<key>NSDisablePersistence</key>
<true/>
</dict>
</plist>

iPad难觅理想浏览器

对于iPad浏览器的要求:

  1. 支持Firefox书签同步
  2. 支持外接蓝牙键盘快捷键
  3. 有“阅读器”功能
  4. 可以将网页保存到Evernote

 

对键盘快捷键的支持只存在于Safari;Dolphin浏览器不支持1、2、3;Foxbrowser只支持2;Mercury Browser支持阅读器功能但速度非常慢,另外用键盘打字时显示有明显滞后。

[转载]我的心悲伤过七次

Seven times have I despised my soul:
我的心悲伤过七次

Kahlil Gibran,1883—1931 纪伯伦

The first time when I saw her being meek that she might attain height.
第一次,是当我看到她本可进取,却故作谦卑时。

The second time when I saw her limping before the crippled.
第二次,是当我看到她在瘸子面前跛行而过时。

The third time when she was given to choose between the hard and the easy,
and she chose the easy.
第三次,是当她在难易之间,却选择了容易时。

The fourth time when she committed a wrong, and comforted herself that others
also commit wrong.
第四次,是当她犯了错,却借由别人也会犯错来宽慰自己时。

The fifth time when she forbore for weakness, and attributed her patience to
strength.
第五次,是当她因为软弱而忍让,却声称为自己的坚韧时。

The sixth time when she despised the ugliness of a face, and knew not that it
was one of her own masks.
第六次,是当她鄙夷一张丑恶的嘴脸,却不知那正是自己面具中的一副时。

And the seventh time when she sang a song of praise, and deemed it a virtue.
第七次,是当她吟唱赞歌,却自诩为一种美德时。

初学GitHub

(背景:之前有限度接触过svn和cvs,曾经架设过一个svn服务器但从未投入实际使用。)

首先阅读了GitHub的4篇教程,分别是Set Up Git、Create a Repository、Fork a Repository、Be Social。实践了前两篇。

教程中关键的命令如下:
git remote add origin https://github.com/username/Hello-World.git
# Creates a remote named “origin” pointing at your GitHub repository
git push origin master
# Sends your commits in the “master” branch to GitHub

练习时首先在办公室将一个python文件add/commit/push到GitHub上,回到家里后在家里的计算机上做了些更改再commit/push到GitHub。第二天回到办公室修改代码,试图push时提示:
$ git push origin master
To https://github.com/****/Hello-World.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://github.com/****/Hello-World.git’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: ‘git pull’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.

于是按照提示运行
$ git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 3 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://github.com/****/Hello-World
8e27c93..9d246e3 master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details
git pull
If you wish to set tracking information for this branch you can do so with:
git branch –set-upstream-to=origin/ master

由此可知不管push还是pull,都要指定remote和branch。这里remote是origin, branch是master。
再运行
$ git pull origin master
$ git push origin master

本地代码和GitHub就同步了。

PS:发现了一个有用的工具cheat。可以通过gem install cheat来安装,然后运行cheat git快速参考git的用法。另外尝试了cheat cheat 和cheat vim。初次使用时下载cheatsheet有点慢。

去除Duckduckgo.com搜索结果链接中的HTTPS

duckduckgo.com默认搜索结果的链接是HTTPS而非HTTP。但是Wikipedia的HTTPS链接在中国大陆被封禁了,另外Firefox打开https://ieeexplore.ieee.org时页面显示不完整。

解决办法:1. 安装Firefox插件HTTPS Everywhere
2. 进入Firefox profile目录(OS X下是~/Library/Application Support/Firefox/Profiles/**/),在这下面的HTTPSEverywhereUserRules文件夹添加ieeexplore.xml和wikipedia.xml

ieeexplore.xml
<ruleset name=”ieeexplore”>
<target host=”ieeexplore.ieee.org” />
<rule from=”^https://(ieeexplore\.)?ieee\.org/” to=”http://ieeexplore.ieee.org/”/>
</ruleset>

wikipedia.xml
<ruleset name=”Wikipedia”>
<target host=”en.wikipedia.org” />
<rule from=”^https://(en\.)?wikipedia\.org/” to=”http://en.wikipedia.org/”/>
</ruleset>

参考: https://duck.co/topic/how-to-force-wikipedia-bang-or-search-to-use-http

易忘的中秋

回家了。处理了一些家事。十五这天,妈妈擀面,拌芝麻,耐心地做了一个又一个芝麻饼。她让我带几个饼给荣洪。她说他没有娘了,带些饼给他吃。

十六这天是金时超结婚。中午去吃面,遇到了很多多年不见的本家亲戚。大部分人即使见过一面,也记不住了。

和大伯伯家修复关系了。中午爸妈和我们一起去看了婷婷的未来老公,还去金光哥哥家里喝了茶。