Skip to content

Instantly share code, notes, and snippets.

View chinghanho's full-sized avatar
💁‍♂️
What's up?

Ching-Han Ho chinghanho

💁‍♂️
What's up?
View GitHub Profile
@chinghanho
chinghanho / gist:3346205
Created August 14, 2012 04:18 — forked from lucasfais/gist:1207002
Sublime Text 2: Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T 切換檔案
⌘⌃P 切換專案
⌘R 畫面切換到 method
⌃G 畫面切換到指定行數
⌘KB 關閉 / 開啟側邊欄
⌘⇧P 開啟指令控制面板
@chinghanho
chinghanho / gist:3505158
Created August 28, 2012 23:08 — forked from iCasablanca/gist:1150914
Rails: Convention of Techbang

Rails 開發注意要點

About Ruby Syntax

  • 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
  • 函式如果只有一個參數,就不強制打()
  • 函式如果有二個以上的參數,通通都要有 ()
    • (避免發生奇怪的paser bug跟保持專案一致性)
  • 字串限定用雙引號包覆
  • 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
@chinghanho
chinghanho / devise.zh-TW.yml
Created October 1, 2012 01:11 — forked from littlebtc/devise.zh-TW.yml
Rails: Devise i18n Chinese Traditional Translation
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
zh-TW:
errors:
messages:
expired: "已經過期,請重新申請一個"
not_found: "找不到"
already_confirmed: "已經驗證,請直接登入"
not_locked: "被鎖定了"
not_saved:
@chinghanho
chinghanho / bash.sh
Created October 12, 2012 07:33
OS X: How to uninstall MySQL on OS X
# Maintain in: https://gist.github.com/3877799
# Resources: http://johnmcostaiii.net/2011/removing-mysql-osx-lion/
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
@chinghanho
chinghanho / mountain-lion-brew-setup.markdown
Created October 29, 2012 22:50 — forked from myobie/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

@chinghanho
chinghanho / pptpd.sh
Created November 5, 2012 01:15 — forked from alvin2ye/pptpd.sh
Automaticlly install pptpd on Amazon EC2 Amazon Linux
# Automaticlly install pptpd on Amazon EC2 Amazon Linux
#
# Ripped from http://blog.diahosting.com/linux-tutorial/pptpd/
# pptpd source rpm packing by it's authors
#
# WARNING:
# first ms-dns setting to 172.16.0.23, 172.16.0.23 was showing on my
# /etc/resolv.conf, I'm not sure this is the same on all Amazon AWS zones.
#
# You need to adjust your "Security Groups" which you are using too.
@chinghanho
chinghanho / dev.rake
Created November 25, 2012 11:45
Rebuild system by rake
namespace :dev do
desc "Rebuild system"
task :build => ["tmp:clear", "log:clear", "db:drop", "db:create", "db:migrate"]
task :rebuild => [ "dev:build", "db:seed" ]
end
@chinghanho
chinghanho / gist:5783349
Created June 14, 2013 16:31
判斷字串是否含有中文
// 英文、數字、符號:[a-z0-9~!@#&;=_\$\%\^\*\-\+\,\.\/(\\)\?\:\'\"\[\]\(\)]
// 中文:\u4e00-\u9fa5
// 日文:\u3040-\u30FF
var string = "中文內容"
string.match(/[\u4e00-\u9fa5]+/)
@chinghanho
chinghanho / gist:5794508
Created June 17, 2013 03:37
In Chrome, tweet with selected text which contained the title and the URL of the page from Tweetbot app.
on run (input)
tell application "Google Chrome"
set theURL to URL of active tab of first window
set theTitle to title of active tab of first window
set theData to theTitle & " " & theURL & " #「" & input & "」" as string
end tell
activate application "Tweetbot"
tell application "System Events" to tell process "Tweetbot"
click menu item "New Tweet" of menu 1 of menu bar item "Tweet" of menu bar 1
window.app = angular.module('myApp', []);