Skip to content

Instantly share code, notes, and snippets.


Yu-Cheng Chuang yorkxin

View GitHub Profile
yorkxin / gist:221439
Created Oct 29, 2009
my DefaultFontFallbacks.plist
View gist:221439
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<!-- ATSUI-compatible preferred fallback -->
<!-- default ordered fallback list - fallback entity has to be PostScript name -->
<string>LucidaGrande</string> <!-- MAKE sure this matches the kCTFontSystemFontType in CTFontDescriptorCreateForUIType() & TDescriptorSourceImp::CreateDefaultDescriptor()! -->
yorkxin / gist:805284
Created Feb 1, 2011
sample code of supporting to S3's GET link with response-* params
View gist:805284
# see for more details
# Traditional way, without headers and response-* params
s3instance.get_link('bucket_name', 'key/song.mp3', 86400)
# To generate url with response-* params, headers parameter must be specified,
# and response-* params are in hash style
s3instance.get_link('bucket_name', 'key/song.mp3', 86400,
{}, # empty additional headers
yorkxin / wordpressdotcom.rb
Created Nov 25, 2011 (XML export) to Octopress importer. See for change notes.
View wordpressdotcom.rb
# coding: utf-8
# Original File:
# Modified by Yu-Cheng Chuang <>
# Licensed under MIT License (same as the original file)
# This version of wordpressdotcom.rb is compatible
# with the real-world export file, which:
# - Makes paragraphs (<p>) and line breaks (<br>)
View yaci.zsh-theme
# depends on oh-my-zsh
# forked from macovsky-ruby theme
local return_code="%(?..%{$bg[red]%}%{$fg[black]%}=%?%{$reset_color%})"
function rvm_prompt_info {
echo "$ZSH_THEME_RVM_PROMPT_PREFIX$(~/.rvm/bin/rvm-prompt i v g)$ZSH_THEME_RVM_PROMPT_SUFFIX"
function git_prompt_status_full {
yorkxin / DeafultKeyBinding.dict
Created Dec 23, 2011
Mac OS X Function-Key Hack
View DeafultKeyBinding.dict
/* home */
"\UF729" = "moveToBeginningOfLine:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
/* end */
"\UF72B" = "moveToEndOfLine:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
/* page up/down */
yorkxin / Readme.markdown
Created Mar 9, 2012
Test failed for Ruby 1.9.2-p320 (compiled with Clang 3.1)
View Readme.markdown
yorkxin /
Created Apr 4, 2012
Build GitX (R)

GitX (R)

brew install cmake
brew link cmake
brew install libgit2

git clone git://
cd gitx

git submodule init
yorkxin /
Last active Aug 10, 2016
Safari 6 Default Font Fallback Fix (for CJK users)

Safari 6 的預設字體也崩潰了

跟 Chrome 一樣, Safari 6 也使用 html tag 的 lang attribute 來判斷要用哪一套字體來 fallback (參考這裡)。以繁體中文的 zh-TW 為例,它會 fallback 到 Heiti TC (黑體-繁),不只漢字,連英文、數字都套用。我不喜歡這樣,理由:

  1. Heiti TC / Heiti SC 的英文與數字很醜。
  • Heiti TC / Heiti SC 的日文假名也很醜,注音符號更醜,後者尤其是讓我身為台灣人卻沒感到尊重。
  • zh 視為 zh-cn ,所以如果到了 維基百科 ,你就會看到簡體版的 Heiti SC (黑体-简),也就是中國國家標準的漢字及標點符號;不是看到簡體字,而是某些字筆畫有些不同,以及標點符號從正中間挪到左下方(參考漢字標準格式・標點樣式)。
  • 出於個人偏好,我對整個 OS X 設定了繁體中文(Hant)、簡體中文(Hans)都使用 Hiragino Sans GB (冬青黑體)而非預設的 Heiti TC / Heiti SC,雖然標點符號不符合台灣的規範,而且一樣有漢字寫法的問題,但字比較美。 Safari 的行為把這一原則給推翻了,我又看到了 Heiti TC / Heiti SC (怒)。



Avoid jQuery When Possible

jQuery does good jobs when you're dealing with browser compatibility. But we're living in an age that fewer and fewer people use old-school browsers such as IE <= 7. With the growing of DOM APIs in modern browsers (including IE 8), most functions that jQuery provides are built-in natively.

When targeting only modern browsers, it is better to avoid using jQuery's backward-compatible features. Instead, use the native DOM API, which will make your web page run much faster than you might think (native C / C++ implementaion v.s. JavaScript).

If you're making a web page for iOS (e.g. UIWebView), you should use native DOM APIs because mobile Safari is not that old-school web browser; it supports lots of native DOM APIs.

If you're making a Chrome Extension, you should always use native APIs, not only because Chrome has almost the latest DOM APIs available, but this can also avoid performance issue and unnecessary memory occupation (each jQuery-driven extension needs a separate

yorkxin / KeyBindings.json
Last active Nov 29, 2018
My Sublime Text 2 Config
View KeyBindings.json
/* Default (OS X).sublime-keymap */
/* Key Bindings - User */
{ "keys": ["ctrl+shift+."], "command": "erb", "context":
"key": "selector",
"operator": "equal",
"operand": "text.html.ruby, text.haml, source.yaml, source.css, source.scss, source.js,"