Skip to content

Instantly share code, notes, and snippets.

@cball
cball / gist:1201885
Created September 7, 2011 21:48
Spork & Rspec Guardfile
# More info at https://github.com/guard/guard#readme
guard 'spork', :cucumber => false, :test_unit => false, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch('spec/spec_helper.rb')
end
@cball
cball / action_mailer.rb
Created November 22, 2011 18:32
Send all email on QA/Staging to alternate address
# add to config/initializers
if hostname =~ /qa/ || Rails.env.staging?
class OverrideMailRecipient
def self.delivering_email(mail)
mail.to = "[email protected]"
end
end
ActionMailer::Base.register_interceptor(OverrideMailRecipient)
end
@cball
cball / shell+ruby
Created January 10, 2012 18:13
How to use perftools.rb
# generate profile around a script/test
$ CPUPROFILE=/tmp/my_app_profile RUBYOPT="-r`gem which perftools | tail -1`" ruby -I spec spec/models/user_role_spec.rb
# generate profile using a block
# (this is in ruby obviously)
require 'perftools'
PerfTools::CpuProfiler.start("/tmp/add_numbers_profile") do
5_000_000.times{ 1+2+3+4+5 }
end
@cball
cball / application.css
Created March 8, 2012 00:49
Icon Font Usage
/* method taken from http://pictos.cc/articles/using-icon-fonts/ */
[data-icon]:before {
font-family: 'IcoMoonRegular';
content: attr(data-icon);
-webkit-font-smoothing: antialiased;
}
.icon {
strong {
text-indent: -99999px;
@cball
cball / gist:2076871
Created March 18, 2012 16:28
Copy production heroku db to staging
# backup current production db
$ heroku pgbackups:capture --app myapp-production
# restore to staging
$ heroku pgbackups:restore DATABASE `heroku pgbackups:url --app myapp` --app myapp-staging
@cball
cball / gist:2430852
Created April 20, 2012 18:22
Adding new staging servers & multiple branch deploys on heroku
## add new staging server locally that someone else created ##
# make sure you're a collaborator on the app
heroku apps
# assuming you already have directory cloned, if not clone it.
git remote add app2 [email protected]:app2.git
# deploy master
git push app2
@cball
cball / freshbooks_importer.rb
Last active December 14, 2015 23:39
Here's a simple script to migrate Freeagent invoice data -> Freshbooks. Putting this out there in case it helps someone else.
# gem install ruby-freshbooks
# https://github.com/elucid/ruby-freshbooks
#
# * Limitations *
# - Freshbooks Invoice #'s can only be 10 characters
# - requires creating clients ahead of time (though this would be easy for someone to add)
# - client names must match exactly
#
# * Usage *
# require 'freshbooks_importer'
@cball
cball / gist:9392345
Last active August 29, 2015 13:57
run downloaded logentries log from heroku app through oink
gunzip productionlog.gz
# if 63 changes in the future, you want to cut from the first char in date -> rails
cat productionlog.log | cut -c 63- | grep 'rails\[' > log/production-oink.log
oink --threshold=0 log/production-oink.log
get 'some/path/to/app/*', to: 'controller#action_that_uses_template_with_ember_stuff'
# user requests some/path/to/app/cool/path
# ember should see cool/path
@cball
cball / gist:5c8e3673a0a67fd64b10
Created September 5, 2014 13:21
AMS example response
{
"survey":{
"id":4,
"name":"Cool Survey",
"instructions": null,
"question_ids": [48,49]
}
}