Skip to content

Instantly share code, notes, and snippets.

# 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 / 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])
@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 ''
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
:date => '%m/%d/%Y',
:date_time12 => '%m/%d/%Y %I:%M%p',
:date_time24 => '%m/%d/%Y %H:%M',
:day_date => '%a %m/%d/%Y',
:day_date_time12 => '%a %m/%d/%Y | %I:%M%p',
:day_date_time24 => '%a %m/%d/%Y | %H:%M'
)
# 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)
require File.dirname(__FILE__) + '/../spec_helper'
describe CategoriesController, "GET #index" do
subject { controller }
before(:each) { get :index }
it { should assign_to(:categories) }
it { should respond_with(:success) }
end
# haml + liquid example
#
# James MacAulay 2009
require 'rubygems'
require 'liquid'
require 'haml'
template = <<EOF
@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
class TestGist
# test
end
class String
def translate
I18n.t self, :default => self
end
def t
translate
end