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 / 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 / velocity.js
Created September 6, 2017 16:20 — forked from yuheiy/velocity.js
add `easeOutBounce` to velocity.js
'use strict';
import Velocity from 'velocity-animate';
let baseEasings = {};
baseEasings.Bounce = p => {
let pow2;
let bounce = 4;
while (p < ((pow2 = Math.pow(2, --bounce)) - 1) / 11) {}
@chinghanho
chinghanho / bytesToSize.js
Created November 2, 2017 06:50 — forked from lanqy/bytesToSize.js
JavaScript To Convert Bytes To MB, KB, Etc
// from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return 'n/a';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
if (i == 0) return bytes + ' ' + sizes[i];
return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
};
@chinghanho
chinghanho / what-forces-layout.md
Created January 13, 2018 02:13 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@chinghanho
chinghanho / fuzzy_string_match.js
Created May 13, 2018 15:34 — forked from dtjm/fuzzy_string_match.js
Fuzzy string matching function for JavaScript
// Fuzzy matching algorithm
var fuzzyMatch = function(needle, haystack) {
if(needle === "" || haystack === "") return true;
needle = needle.toLowerCase().replace(/ /g, "");
haystack = haystack.toLowerCase();
// All characters in needle must be present in haystack
var j = 0; // haystack position
for(var i = 0; i < needle.length; i++) {
uniform sampler2D tex; // matched from gst-plugin-gl uniform
const vec4 kappa = vec4(1.0,1.7,0.7,15.0);
// These can be made uniform if they are added to:
// gst/gl/gstglfiltershader.c:363
// gst_gl_shader_set_uniform_1f (filtershader->shader0, "screen_width", width);
// gst_gl_shader_set_uniform_1f (filtershader->shader0, "screen_height", height);
const float screen_width = 1920.0;