Skip to content

Instantly share code, notes, and snippets.

View elskwid's full-sized avatar
🤡

Don Morrison elskwid

🤡
View GitHub Profile
Experiments in revision control: Curry recipe.
My personal recipe for Japanese curry, which has mutated over the years and is
now open-source thanks to github, hot damn. Some of the ingredients are not
very Japanese, but curry came to Japan from England which got it from India to
begin with, so whatever.
1.5 - 2 lbs. of meat, prefer thin-sliced beef (komagire), pork works, too.
Thin-sliced stuff is always best, but in a pinch stewing beef works. Bacon
works surprisingly well. Chicken will work, technically, but if you must,
#!/usr/bin/env ruby
# From: http://blog.infinitered.com/entries/show/5
# == Synopsis
# This is a sample description of the application.
# Blah blah blah.
#
# == Examples
# This command does blah blah blah.
# config.gem "rspec", :lib => false, :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
# config.gem "rspec-rails", :lib => 'spec/rails', :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
@elskwid
elskwid / check_column_names.rb
Created September 30, 2009 18:03
Rake task to check column names against oracle reserved words
namespace :oracle do
desc "Check column names against the oracle reserved words"
task :check_column_names => [:environment] do |t|
if ActiveRecord::Base.connection.adapter_name =~ /oracle/i
found = []
ActiveRecord::Base.connection.tables.each do |table_name|
@elskwid
elskwid / sudoku_mathy_matrix.rb
Created October 14, 2009 16:26
sudoku mathy matrix
require 'pp'
# create an array of values for a sudoku grid
# and extract the grids as subarrays in the
# correct order.
#
# 4x4 = 4 grids of 4 cells
# 6x6 = 6 grids of 6 cells
# 9x9 = 9 grids of 9 cells
# etc
class Search < ActiveRecord::Base
has_many :search_results
has_many :cars, :through => :search_results, :source => :results, :source_type => "Car"
has_many :dealers, :through => :search_results, :source => :results, :source_type => "Dealer"
# search.results gives you the list of linked records
has_many :results, :class_name => "SearchResult"
end
class SearchResult < ActiveRecord::Base
task :do_a_thing => :environment do
@zh_cn = " 联想"
@zh_tw = " 聯想"
%w( zh-cn zh-tw ).each do |chinese|
lang = Language.find_by_language_code(chinese)
LocalizedString.all(:conditions => ["language_id = ? and string_value like '%FindMe%'", lang.id]).each do |loc|
loc.string_value.gsub!('FindMe', instance_variable_get("@#{chinese.underscore}"))
loc.save_without_validation
#!/usr/bin/env ruby
#
# Update JIRA with git commit messages
#
# == Usage ==
#
# To update a JIRA issue, prepend the first line of your git commit message
# with the issue key and a colon:
#
# $ git commit -m "GIT-1: Updates something"
@elskwid
elskwid / gist:658965
Created November 1, 2010 22:10 — forked from brianjlandau/gist:176754
Useful gist for cap deploy gh style
# you'd obviously have more settings somewhere
set :scm, :git
set :repository, "git@github.com:defunkt/github.git"
set :branch, "origin/master"
set :migrate_target, :current
set :use_sudo, false
set :ssh_options, {:forward_agent => true}
set :rails_env, 'production'
set(:latest_release) { fetch(:current_path) }
@elskwid
elskwid / unicorn_cap_tasks.rb
Created November 2, 2010 21:37
Some tasks I'm using with Unicorn
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
desc "Start unicorn"
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} bundle exec #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end