Skip to content

Instantly share code, notes, and snippets.

@hchoroomi
hchoroomi / hi.rb
Created July 22, 2008 00:21 — forked from anonymous/hi.rb
puts "error" if __FILE__ = $0
@hchoroomi
hchoroomi / meh.rb
Created November 3, 2008 20:04 — forked from seaofclouds/README
require "rubygems"
require "sinatra"
require 'atom' #sudo gem install ratom
require 'net/http'
require 'uri'
not_found do
headers["Status"] = "301 Moved Permanently"
redirect("/")
end
@hchoroomi
hchoroomi / http-proxy-server.rb
Created February 3, 2009 15:31 — forked from jamis/http-proxy-server.rb
HTTP proxy server
# This is a trivial HTTP proxy server, intended for use as a troubleshooting tool
# ONLY (not for real, actual, production use). I wrote this because I couldn't find
# a simple HTTP proxy that I could use to test HTTP proxy support in Net::SSH.
#
# This code is in the public domain, so do with it what you will!
require 'socket'
server = TCPServer.new('127.0.0.1', 8080)
client = server.accept
# haml + liquid example
#
# James MacAulay 2009
require 'rubygems'
require 'liquid'
require 'haml'
template = <<EOF
# For the queasy, this is MIT licensed. See comment at the end.
module MySQLEncryption
# Mimics MySQL's AES_ENCRYPT() and AES_DECRYPT() encryption functions
def mysql_encrypt(s, key)
encrypt(s, mysql_key(key))
end
def mysql_decrypt(s, key)
@hchoroomi
hchoroomi / ghkey.rb
Created May 10, 2009 22:28 — forked from fcoury/ghkey.rb
Creating and adding an SSH pubkey to GitHub on the fly
#!/usr/bin/env ruby
require 'rubygems'
require 'octopi'
require 'choice'
include Octopi
Choice.options do
header ''
@hchoroomi
hchoroomi / github-test.rb
Created May 12, 2009 14:15 — forked from pjhyett/github-test.rb
Simulation script for building a gem on GitHub
#!/usr/bin/env ruby
require 'yaml'
if ARGV.size < 1
puts "Usage: github-test.rb my-project.gemspec"
exit
end
require 'rubygems/specification'
data = File.read(ARGV[0])
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
@hchoroomi
hchoroomi / gist:160399
Created August 3, 2009 06:45 — forked from djanowski/gist:159524
ruby-debug -- Ruby 1.9
# This assumes you have the latest Ruby 1.9 installed via MacPorts:
#
# $ sudo port sync
# $ sudo port install ruby19
#
# Make sure there are no trails of columnize, linecache, ruby-debug-base and ruby-debug.
for name in columnize linecache ruby-debug-base ruby-debug
do
(gem1.9 list | grep ^$name >/dev/null) && sudo gem1.9 uninstall -a -x -I $name
find /opt/local/lib/ruby1.9/gems/1.9.1/gems -name "$name*" -type d -maxdepth 1 -print0 | sudo xargs -0 rm -rf
@hchoroomi
hchoroomi / epic snow leopard upgrade guide.txt
Created August 30, 2009 14:20 — forked from edward/epic snow leopard upgrade guide.txt
Epic Snow Leopard Upgrayyyyd Guide
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness