Skip to content

Instantly share code, notes, and snippets.

@chumpy
chumpy / heroku_data_transfer
Last active October 12, 2015 15:28 — forked from nhocki/gist:1095522
Transfer data from production to staging on Heroku
heroku addons:add pgbackups --remote staging
heroku addons:add pgbackups --remote production
heroku pgbackups:capture --remote production
heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging
@chumpy
chumpy / app_contansts.rb
Created October 31, 2012 18:52
Rails app contants in YAML file (adapted from http://goo.gl/9EuAh)
# this goes in config/initializers
APP_CONFIG = YAML.load(File.read(File.expand_path('../../app_constants.yml', __FILE__)))[Rails.env]
@chumpy
chumpy / capybara_cheat_sheet.md
Created October 23, 2012 22:46 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet

Capybara Cheat Sheet

Navigating

  visit('/projects')
  visit(post_comments_path(post))
@chumpy
chumpy / gem_list.txt
Created April 13, 2012 22:46
gem list
$ gem list
*** LOCAL GEMS ***
actionmailer (2.3.12)
actionpack (2.3.12)
activerecord (2.3.12)
activeresource (2.3.12)
activesupport (2.3.12)
addressable (2.2.6)
@chumpy
chumpy / dep_warning.txt
Created April 13, 2012 22:41
deprecation warning
gem -v = 1.8.17
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
@chumpy
chumpy / uninstall_gems.sh
Created February 22, 2012 04:01
Uninstall all gems
#! /bin/bash
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@chumpy
chumpy / add_ppp0_route.sh
Created February 21, 2012 04:00
Adds ppp0 route to kernel route list to support IPSec VPN
#! /bin/bash
ifconfig -a ppp0 | grep inet | awk '{print $2}' | xargs -0 -I ip sudo route add default gw ip ppp0
@chumpy
chumpy / restful_auth_basic.rb
Created January 29, 2012 00:29
Basic Auth w/Restful Authentication
# Here’s a way to do http basic authentication and tie it in
# to the Restful Authentication mechanism to make current_person accessible:
def authenticate_person
authenticate_or_request_with_http_basic do |login, password|
person = Person.authenticate(login, password)
return false if !person or person.nil?
session[:person_id] = person.id
end
end
@chumpy
chumpy / yaml_compare.rb
Created January 29, 2012 00:20
compare two yaml files in ruby
#require 'active_support/core_ext'
class YamlCompare
def self.compare_keys first_file_info, second_file_info, results_location
first_file = Hash.new
second_file = Hash.new
deltas_file = Hash.new
File.open( first_file_info[:file_location] ) { |yf| first_file = YAML.load( yf ) }
File.open( second_file_info[:file_location] ) { |yf| second_file = YAML.load( yf ) }
first_file[first_file_info[:root]].each_pair do |k,v|
@chumpy
chumpy / yaml_to_xml.rb
Created January 29, 2012 00:14
yaml to xml conversion
#require 'active_support/core_ext'
class YamlToXml
def self.yaml_to_xml file_to_read, file_to_write
doc = String.new
File.open( file_to_read ) { |yf| doc << YAML.parse( yf ).transform.to_xml }
File.open( file_to_write, 'w' ) { |f| f.write( doc ) }
end
def self.xml_to_yaml file_to_read, file_to_write