Skip to content

Instantly share code, notes, and snippets.

Avatar
〽️

Yu-Cheng Chuang yorkxin

〽️
View GitHub Profile
@yorkxin
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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!-- ATSUI-compatible preferred fallback -->
<dict>
<!-- default ordered fallback list - fallback entity has to be PostScript name -->
<key>default</key>
<array>
<string>LucidaGrande</string> <!-- MAKE sure this matches the kCTFontSystemFontType in CTFontDescriptorCreateForUIType() & TDescriptorSourceImp::CreateDefaultDescriptor()! -->
<string>AppleSymbolsFB</string>
@yorkxin
yorkxin / gist:805284
Created Feb 1, 2011
sample code of supporting to S3's GET link with response-* params
View gist:805284
# see https://github.com/rightscale/right_aws/pull/47 for more details
# Traditional way, without headers and response-* params
s3instance.get_link('bucket_name', 'key/song.mp3', 86400)
#=> https://bucket_name.s3.amazonaws.com:443/key%2Fsong.mp3?Signature=vIh5...&Expires=1296611902&AWSAccessKeyId=AK...
# 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
yorkxin / wordpressdotcom.rb
Created Nov 25, 2011
Wordpress.com (XML export) to Octopress importer. See http://git.io/x8yapw for change notes.
View wordpressdotcom.rb
# coding: utf-8
# Original File: https://github.com/mojombo/jekyll/blob/master/lib/jekyll/migrators/wordpress.rb
# Modified by Yu-Cheng Chuang <ducksteven@gmail.com>
# Licensed under MIT License (same as the original file)
# This version of wordpressdotcom.rb is compatible
# with the real-world Wordpress.com 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
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
yorkxin / Readme.markdown
Created Mar 9, 2012
Test failed for Ruby 1.9.2-p320 (compiled with Clang 3.1)
View Readme.markdown
@yorkxin
yorkxin / readme.md
Created Apr 4, 2012
Build GitX (R)
View readme.md

GitX (R)

brew install cmake
brew link cmake
brew install libgit2

git clone git://github.com/rowanj/gitx.git
cd gitx

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

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 (怒)。

這裡提供一個解決方法

View avoid-jquery-when-possible.md

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
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, source.coffee"
}