Skip to content

Instantly share code, notes, and snippets.

# Add to the bottom of the rake file:
require 'hydra'
require 'hydra/tasks'
Hydra::TestTask.new('hydra:spec') do |t|
t.add_files 'spec/**/*_spec.rb'
end
Hydra::TestTask.new('hydra:features') do |t|
t.add_files 'features/**/*.feature'
end
module Search
VECTORS = [
{:klass => Company, :columns => ['ticker', 'name']},
{:klass => Executive, :columns => ['name']}
]
class << self
def find(query)
query = query.split(' ').join(' & ')
return Search::VECTORS.collect{|tuple|
Array(tuple[:columns]).collect{|column|
-# render your objects with their dom_id from ActionController::RecordIdentifier
-# this means each TR will have an id like "object_47"
%table
- @objects.each do |obj|
%tr{:id => dom_id(obj)}
%td= h obj.title
%td
%li= link_to "Edit", edit_obj_path(obj)
#!/usr/bin/env ruby
def sleep_for_5
puts 'gonna sleep for 5'
sleep(5)
puts 'yawn!'
end
def sleep_for_15
puts 'gonna sleep for 15'
module ActiveRecord
module ConnectionAdapters
class AbstractAdapter
def current_savepoint_name
"active_record_#{Process.pid.to_s}_#{open_transactions}"
end
end
end
end
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=250000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=100000000
export RUBY_HEAP_FREE_MIN=1000000
ree-1.8.7-2010.01 > require 'rubygems'
=> true
ree-1.8.7-2010.01 > require 'fastercsv'
=> true
ree-1.8.7-2010.01 > FasterCSV.open('test.csv', 'w') do |csv|
ree-1.8.7-2010.01 > csv << ["this", "is", "test, or not"]
ree-1.8.7-2010.01 ?> end
=> <#FasterCSV io_type:File io_path:"test.csv" lineno:1 col_sep:"," row_sep:"\n" quote_char:"\"">
File contains:
module Paperclip
class Geometry
def self.from_file file
parse("100x100")
end
end
class Thumbnail
def make
src = Test::FileHelper.fixture_file('white_pixel.jpg')
dst = Tempfile.new([@basename, @format].compact.join("."))
#!/usr/bin/env ruby
def notify(msg)
puts "NOTIFY: #{msg}"
`notify-send -i /home/nick/bin/nicks-toolbox/pom.png "Pomodoro" "#{msg}"`
end
unless ARGV.size == 2
puts "Usage: pomodoro <work time> <rest time>"
exit(1)
end
$ firetower setup
What is your Campfire subdomain? If your Campfire address is
http://mycompany.campfirenow.com, your subdomain is "mycompany" (without the
quotes).
smartlogic
Please enter your Campfire API token. You can find your token at
http://smartlogic.campfirenow.com/member/edit
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (my real token was here)
Use SSL when connecting to Campfire?
y