Skip to content

Instantly share code, notes, and snippets.

View danielevans's full-sized avatar

Daniel Evans danielevans

  • Anfract
  • Portland, OR
View GitHub Profile
$(document).ready(function(){
var r=function(e){
alert("Hello World");
};
$("#remove").click(r);
});
@danielevans
danielevans / rubber1
Created April 5, 2011 18:16
output from a rubber create_staging call
gate@tolanna:~/Work/project-rails/project$ RUBBER_ENV=rubbertest cap rubber:create_staging
triggering load callbacks
* executing `rubber:init'
* executing `rubber:create_staging'
Hostname to use for staging instance [rubbertest]:
Roles to use for staging instance [web,app,db:primary=true]:
* executing `rubber:create'
* Creating new security group: project_rubbertest_app
* Creating new security group: project_rubbertest_passenger
* Creating new security group: project_rubbertest_default
@danielevans
danielevans / gist:923831
Created April 17, 2011 07:45
rvm install script
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
source "/usr/local/rvm/scripts/rvm"
else
printf "ERROR: An RVM installation was not found.\n"
fi
rvm use --create ree@#{app_name}
gem install bundler --no-ri --no-rdoc
@danielevans
danielevans / rvm helper
Created April 17, 2011 08:05
RVM from a ruby script
rvm_dir = File.join([ENV['rvm_path'], 'lib'])
$LOAD_PATH.unshift(rvm_dir) unless $LOAD_PATH.include?(rvm_dir)
require 'rvm'
RVM.use! "ree"
RVM.rvm :gemset, :create, app_name
RVM.rvm :use, "ree@#{app_name}", :rvmrc => true
@danielevans
danielevans / rvm.rb
Created April 19, 2011 19:24
RVM script for rails 3 template (Original code: https://github.com/danielevans/rails3-app/blob/master/cuke.rb)
rvm_dir = File.join([ENV['rvm_path'], 'lib'])
$LOAD_PATH.unshift(rvm_dir) unless $LOAD_PATH.include?(rvm_dir)
require 'rvm'
RVM.use! "default"
RVM.rvm :gemset, :create, app_name
RVM.rvm :use, "default@#{app_name}", :rvmrc => true
@danielevans
danielevans / gist:968072
Created May 12, 2011 07:06
JSON api definition for competition server
//ACTION DEFINITIONS
//start_game
{//informs of a game starting
"method": "start_game",
"game": GAME_OBJECT,
"player": PLAYER_OBJECT
}
//response ignored
@danielevans
danielevans / attachment.rb
Created May 29, 2011 07:51
multiple dynamic file storage for paperclip
module Paperclip
class Attachment
attr_accessor :queued_for_write, :queued_for_delete
end
end
@danielevans
danielevans / gist:1011309
Created June 6, 2011 23:01
A create admin rake task using the highline gem
namespace :admin do
desc "creates and admin user"
task :create => :environment do
line = HighLine.new # a command line lib that uses erb? Bizarre.
line.say "<%= color('Creating a new administrative user', BOLD) %>"
email = line.ask("Email: ")
pass = line.ask("Password: " ) { |q| q.echo = "*" }
admin = Admin.new(:email => email, :password => pass)
@danielevans
danielevans / gist:1026490
Created June 15, 2011 04:35
Palindrome search space
FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthesedeadshal
@danielevans
danielevans / gist:1287851
Created October 14, 2011 18:06
Broken rails form helper code
Controller:
@estimate = Hashie::Mash.new({
:same_address => 1,
:cc_number => nil,
:shipping_address => Hashie::Mash.new,
:billing_address => Hashie::Mash.new
})
View: