Skip to content

Instantly share code, notes, and snippets.

View hc5duke's full-sized avatar

Hwan-Joon Choi hc5duke

View GitHub Profile
$ curl -u 'hc5duke:password' -d "status=going to flash my android phone just for fun" http://twitter.com/statuses/update.xml
// ==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;
iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 5900 -j ACCEPT
# 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 = []
// 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){
@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.
@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 / 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 / pre-commit
Created October 5, 2011 23:42
pre-commit hook
#!/bin/sh
files=$(git diff-index --name-status --cached HEAD | grep -v ^D | cut -c3-)
if [ "$files" != "" ]
then
for f in $files
do
# Only examine known text files
if [[ "$f" =~ [.](conf|css|erb|html|haml|scss|css|js|json|log|properties|rb|ru|txt|xml|yml)$ ]]
then
@hc5duke
hc5duke / git_info.bash
Created January 11, 2012 08:49
Git info in PS1
git_info() {
# colors
local RESET="\033[0m"
local GRAY="\033[1;30m"
local RED="\033[1;31m"
local GREEN="\033[1;32m"
local BLUE="\033[1;34m"
local PINK="\033[1;35m"
local CYAN="\033[1;36m"