Skip to content

Instantly share code, notes, and snippets.

View aar0nTw's full-sized avatar

Aaron Huang aar0nTw

View GitHub Profile
@aar0nTw
aar0nTw / self_route.vcl
Created May 26, 2022 04:45 — forked from rezan/self_route.vcl
Self routing Varnish Cache cluster example
# Self routing cluster example
vcl 4.0;
import directors;
backend node1 {
.host = "node1.example.com";
.port = "80";
}
@aar0nTw
aar0nTw / 0_reuse_code.js
Created June 24, 2014 18:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
### Keybase proof
I hereby claim:
* I am aar0ntw on github.
* I am aar0ntw (https://keybase.io/aar0ntw) on keybase.
* I have a public key whose fingerprint is B57A F8D1 213E 4141 AA7F BA57 3E16 E47D 032F F507
To claim this, I am signing this object:
@aar0nTw
aar0nTw / CJKMatcher.coffee
Created May 21, 2014 08:53
Check the string have cjk char
define (require) ->
##
# Unicode range for CJK words.
# 3000 - 303f: Japanese-style punctuation
# 3040 - 309f: Hiragana
# 30a0 - 30ff: Katakana
# ff00 - ff9f: Full-width Roman characters and half-width Katakana
# 4e00 - 9faf: CJK unified ideographs - Common and uncommon Kanji
# 3400 - 4dbf: CJK unified ideographs Extension A - Rare Kanji
##
length = 32
mid = 2**(length-1)
max_unsigned = 2**length
to_signed = proc {|n| (n>=mid) ? n - max_unsigned : n}
p to_signed["0xFFF54006".to_i(16)]
# use pbcopy and pbpaste
# need preinstall the reattach-to-user-namespace 'brew install reattach-to-user-namespace'
#
set -g default-shell /bin/zsh
set-option -g default-command "reattach-to-user-namespace -l zsh"
bind C-c run "tmux show-buffer | reattach-to-user-namespace pbcopy"
bind C-v run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
# start window index of 1
set -g base-index 1
\set PROMPT1 '%[%033[1m%]%M %001%[%033[1;33;40m%]%002%n@%/%R%001%[%033[0m%]%002%# '
\set PROMPT2 '[more] %R > '
-- By default, NULL displays as an empty space. Is it actually an empty
-- string, or is it null? This makes that distinction visible.
\pset null '[NULL]'
-- Use table format (with headers across the top) by default, but switch to
-- expanded table format when there's a lot of data, which makes it much
\set PROMPT1 '%[%033[1m%]%M %n@%/%R%[%033[0m%]%# '
\set PROMPT2 '[more] %R > '
-- By default, NULL displays as an empty space. Is it actually an empty
-- string, or is it null? This makes that distinction visible.
\pset null '[NULL]'
-- Use table format (with headers across the top) by default, but switch to
-- expanded table format when there's a lot of data, which makes it much
⮀ aaron ⮀ Gabrielle [14:00:15] ~/Projects/Faria/keybridge
> $ time (RAILS_ENV=staging rake requirejs:precompile:all) ⬡ 2.0.0-p353 ⬡ 0.11.8 [±release]
Enable development mail interceptor
( RAILS_ENV=staging bundled_rake requirejs:precompile:all; ) 68.99s user 3.65s system 94% cpu 1:16.64 total
⮀ aaron ⮀ Gabrielle [14:01:46] ~/Projects/Faria/keybridge
> $ time (RAILS_ENV=staging rake requirejs:precompile:all) ⬡ 2.0.0-p353 ⬡ 0.10.24 [±release]
Enable development mail interceptor
( RAILS_ENV=staging bundled_rake requirejs:precompile:all; ) 53.84s user 4.41s system 89% cpu 1:05.25 total
edit_area_click = (evt, callback) ->
$el = $(evt.currentTarget)
tg = $("##{$el.data('target')}")
tg.redactor('destroy')
$el.parents().find(".overlay").show()
$el.parents().hide()
$('.overlay').attr 'style', ''
callback(tg)