Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'packr'
class Packr
def self.compress_to_file(filename, options = {})
defaults = {
:target_file => filename.gsub(/\.js$/, '.min.js'),
:shrink_vars => true
}
module NumberFormat
def to_comma_separated
self.to_s.gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, '\1,')
end
end
class Integer
include NumberFormat
end
class Float
MySQL commands
mysql> create database [database_name];
mysql> show databases;
CREATE BACKUP
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
RESTORE BACKUP
mysql -u root -p[root_password] [database_name] < dumpfilename.sql
require 'cucumber/step_definition_light'
class StepUsage
class StepDefKey < Cucumber::StepDefinitionLight
end
def initialize(step_mother, io, options)
@step_mother = step_mother
@io = io
@stepdef_to_match = Hash.new{|h,stepdef_key| h[stepdef_key] = []}
if (window.___dialogEncountered === undefined) {
window.___dialogEncountered = false;
}
if (window.___dialogReturnValue === undefined) {
window.___dialogReturnValue = false;
}
window.___dialogHandler = function(dialogType) {
window.parent.___dialogEncountered = dialogType;
// inserting HTML that contains a script that contains document.write
$('a').first().html('<script>document.write("hey! don't be broken")</script>');
Factory.define :post do |post_factory|
post_factory.user { Factory.build(:user) }
end
require 'test/unit'
class Frame
attr_reader :rolls
def initialize(first_roll)
@rolls = [first_roll]
end
def << pins
Migrate Heroku app to 1.9.2
http://devcenter.heroku.com/articles/bamboo
> heroku stack:migrate bamboo-mri-1.9.2
> heroku config:add BUNDLE_WITHOUT="development:test"