Skip to content

Instantly share code, notes, and snippets.

View jhsu's full-sized avatar
💀
compliant with future standards

Joe Hsu jhsu

💀
compliant with future standards
  • MineHub
  • New York, NY
  • X @jhsu
View GitHub Profile
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@jhsu
jhsu / taskrunner.rb
Created July 8, 2011 20:18
load the environment once and run tasks
#!/usr/bin/env ruby
# Move this script to RAILS_ROOT/scripts/taskrunner, `chmod +x` it and run with ./script/taskrunner
# run one or more rake tasks `Task:> db:migrate app:do_something env_variables=like_this`
require 'readline'
require 'irb'
require './config/environment'
load './Rakefile'
@jhsu
jhsu / my_lastfm.sh
Created July 26, 2011 21:38
get recent 50 tracks of a user from last.fm
#!/usr/bin/env bash
curl -s "http://ws.audioscrobbler.com/2.0/user/$1/recenttracks.rss?limit=50" | grep -E '^\s+<title>' | sed 's/^[ \t]*<title>//;s/<\/title>[ \t]*$//'
module PluginHelper
module ClassMethods
attr_accessor :commands
def user_commands(*cmds)
@commands = cmds
end
end
def self.included(base)
base.extend(ClassMethods)
ruby-1.9.2-p180 :019 > CSV.parse("this is some,b0rken \"csv\"")
#=> CSV::MalformedCSVError: Illegal quoting on line 1.
flip: (╯°□°)╯︵ ┻━┻
@jhsu
jhsu / .rvmrc
Created August 30, 2011 23:29
UB Open courses checker (HUB Student Center)
rvm use 1.8.7
# Maintainer: Joseph Hsu <[email protected]>
pkgname=bdsm-git
pkgver=20110418
pkgrel=1
pkgdesc="SM :: S{cripting,ystem,tack} Management (SM) Framework (Core)"
arch=('i686' 'x86_64')
url="https://sm.beginrescueend.com/"
license=("Apache License, Version 2.0")
depends=("bash")
makedepends=("git")
@jhsu
jhsu / mkick.rb
Created September 26, 2011 19:15
# mkick.rb
#
# Mass-kicks users in a channel
#
# http://scripts.irssi.org/html/mkick.pl.html
#
# Possible inspiration: http://weechat.org/files/scripts/unofficial/chanlist.rb
#
# Usage: /mkick <channel> <kick message>
#!/usr/bin/env bash
git reset --soft HEAD~1