Skip to content

Instantly share code, notes, and snippets.

# 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)
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'
)
@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
bundle_path "vendor/bundler_gems"
disable_system_gems
gem "rails", '2.3.5'
gem 'will_paginate', '2.3.11'
gem 'authlogic', '2.1.2'
gem 'haml', '2.2.13'
gem 'formtastic', '0.9.1'
gem 'state_machine', '0.8.0'
gem 'RedCloth', '4.2.2'
@hchoroomi
hchoroomi / config.ru
Created January 17, 2010 04:28 — forked from peterc/config.ru
twilio, sinatra
# Very simple, but working, voice message system for Twilio in Ruby
# by Peter Cooper - http://twitter.com/peterc
#
# You can call the Twilio number, leave a message, as well as see the
# messages that are left.
#
# To set up on a server, just have this as the config.ru (yes, scrappy)
# on a Rack compliant server. Works great with Passenger..
#
# In Twilio, just set the root as the endpoint for your app.
SPEC_SUITES = [
{ :id => :acl, :title => 'access control', :files => %w(spec/controllers/**/acl_spec.rb) },
{ :id => :amazon, :title => 'Amazon libraries', :dirs => %w(spec/lib/amazon) }
]
namespace :spec do
namespace :suite do
SPEC_SUITES.each do |suite|
desc "Run all specs in #{suite[:title]} spec suite"
Spec::Rake::SpecTask.new(suite[:id]) do |t|