Skip to content

Instantly share code, notes, and snippets.

View hc5duke's full-sized avatar

Hwan-Joon Choi hc5duke

View GitHub Profile
@hc5duke
hc5duke / nokogiri
Created September 21, 2011 18:31 — forked from softprops/nokogiri
# using rvm with ruby-1.8.7-p249
# latest version 2.7.7 2010-06-17
brew install libxml2
# installing libxslt from source code
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar xvfz libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.7
@hc5duke
hc5duke / gsub.rb
Created August 26, 2011 23:23
gsub vs none
n = 1_000_000
time = Benchmark.bm(8) do |r|
r.report("str") do
n.times do
str = "foo.jpg"
str.gsub(".jpg", '.png')
end
end
r.report("compile") do
@hc5duke
hc5duke / brew install -v git
Created November 16, 2010 23:09
trying to update git
$ brew info git
git 1.7.3.2
http://git-scm.com
/usr/local/Cellar/git/1.7.1.1 (916 files, 18M)
http://github.com/mxcl/homebrew/commits/master/Library/Formula/git.rb
$ brew install -v git
Warning: It appears you have MacPorts or Fink installed.
Software installed with MacPorts and Fink are known to cause problems.
If you experience issues try uninstalling these tools.
// based on http://github.com/christkv/node-mongodb-native demo
var mongodb = require('mongodb'),
express = require('express'),
sys = require('sys'),
app = express.createServer(),
client = new mongodb.Db('integration_tests_20', new mongodb.Server("127.0.0.1", 27017, {}));
app.get('/', function(req, res){
# from Yahoo sports http://g.sports.yahoo.com/soccer/world-cup/schedule/
# assuming DEU-ESP ends in a 0-0 tie and disregarding PK
scores = ["1,1", "0,0", "2,0", "1,0", "1,1", "0,1", "0,1", "4,0", "2,0", "1,0", "1,1", "1,1", "0,0", "2,1", "0,1", "0,1", "0,3", "4,1", "2,1", "0,2", "0,1", "2,2", "0,0", "1,0", "1,1", "1,2", "0,2", "1,1", "3,1", "7,0", "1,0", "2,0", "0,1", "1,2", "2,2", "0,2", "0,1", "1,0", "0,1", "2,1", "3,2", "0,0", "1,3", "1,2", "0,0", "0,3", "0,0", "1,2", "2,1", "1,2", "4,1", "3,1", "2,1", "3,0", "0,0", "1,0", "2,1", "1,1", "0,4", "0,1", "2,3", "0,0", "2,1", "1,2", "4,1", "3,1", "2,1", "3,0", "0,0", "1,0", "2,1", "1,1", "0,4", "0,1", "2,3", "0,0"]
# from Ruby Cookbook pp. 55-56
def mean(array); array.inject(0) { |sum, x| sum += x } / array.size.to_f; end
def median(array); return array.size % 2 == 1 ? array.sort[array.size/2] : mean(array.sort[(array.size/2-1)..(array.size/2)]); end
winners = []
iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 5900 -j ACCEPT
// ==UserScript==
// @name chris chase sucks
// @namespace com.choibean.monkey.yahoo
// @description remove chris chase articles from yahoo college basketball
// @include http://rivals.yahoo.com/ncaa/basketball
// ==/UserScript==
var debug = (typeof(console) == 'object' && console.log);
var i = 0;
$ curl -u 'hc5duke:password' -d "status=going to flash my android phone just for fun" http://twitter.com/statuses/update.xml
# Star Trek
(doc/"table.wikitable"/"tr").select{|tr| (tr/"td").count > 2}.map{|tr| (tr/"td").select{|td| !td.nil? && td.inner_html.match(/\"/)}.first.inner_html.gsub(/<\/?[^>]*>/, "").gsub(/\"/, "").gsub("&#160;"," ") }[7..-1]
$ defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1