Skip to content

Instantly share code, notes, and snippets.

View kaddopur's full-sized avatar

Jason Huang kaddopur

View GitHub Profile
@kaddopur
kaddopur / gist:3419a0c8b6e8933fbaea
Created May 28, 2014 09:36
Install new ruby version with rbenv in OS X with proper utf-8 support in irb
brew install readline
CONFIGURE_OPTS="--disable-install-doc --with-readline-dir=$(brew --prefix readline)" rbenv install 1.9.3-p392
def twenty_four(*operands)
p operands
operators = %w(+ - * /)
operands.map! {|op| op.to_f}
operands.permutation.to_a.uniq.each do |ordered_operands|
operators.repeated_permutation(operands.length-1) do |ordered_operators|
check_answer(ordered_operands, ordered_operators)
end
end
@kaddopur
kaddopur / gist:972ad28a7018fd5f95b6
Created March 3, 2015 10:21
install generator-fluxible
$ npm install -g yo
$ npm install -g generator-fluxible
$ yo fluxible
npm install -g yo
npm install -g generator-fluxible
@kaddopur
kaddopur / cbv.coffee
Created May 27, 2012 18:03
CoffeeScript call by value hack
for child in children
$('#list').append("<li>#{child.name}</li>").bind 'click', do =>
tmp = child.id
-> check(tmp)
# always check the id of last child
for child in children
$('#list').append("<li>#{child.name}</li>").bind 'click', => check(child.id)
@kaddopur
kaddopur / gist:2949755
Created June 18, 2012 18:06
Using less.js locally
python -m SimpleHTTPServer 8080
@kaddopur
kaddopur / gist:2949817
Created June 18, 2012 18:21
Client-side usage
<link rel="stylesheet/less" type="text/css" href="styles.less">
<script src="less.js" type="text/javascript"></script>
@kaddopur
kaddopur / gist:2954838
Created June 19, 2012 15:35
Using jQuery in content scripts
"content_scripts": [
{
"matches": ["http://www.xxx.com/*"],
"css": ["css/bootstrap.css", "css/content.css"],
"js": ["js/jquery.min.js", "js/content.js"]
}
]
@kaddopur
kaddopur / wake.rb
Created June 20, 2012 14:29
watchr script example
watch('.*\.jade') {|md| system("jade -P -O .. #{md[0]}")}
watch('.*\.styl') {|md| system("stylus -o ../css #{md[0]}")}
watch('.*\.coffee') {|md| system("coffee -bc -o ../js #{md[0]}")
$.get( "your_partial.html", function( data ) {
$( "#your_div" ).html( data );
alert( "Load was performed." );
});