This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bulk of this snagged from: https://gist.github.com/guilleiguaran/56a3879da5f6b6f467ce | |
Fixtures bit snagged from: https://github.com/cucumber/cucumber/wiki/Fixtures | |
require 'active_record' | |
require 'active_record/fixtures' | |
class MiniTest::Spec | |
ActiveRecord::Base.establish_connection( | |
:adapter => "sqlite3", | |
:database => "./db/development.sqlite3" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
r = requests.get(r'http://jsonip.com') | |
ip= r.json()['ip'] | |
print 'Your IP is', ip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_from_cache(uid, key) | |
redis_available = true | |
Sidekiq.redis do |connection| | |
begin | |
objects = Rails.cache.read("user:#{uid}:#{key}") if connection | |
rescue Redis::CannotConnectError | |
ExceptionNotifier.notify_exception(e) | |
redis_available = false | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "active_record" | |
namespace :db do | |
db_config = YAML::load(File.open('config/database.yml')) | |
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'}) | |
desc "Create the database" | |
task :create do | |
ActiveRecord::Base.establish_connection(db_config_admin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tn = TrialNotification.new(@account, Notifier) | |
tn.assm_current_state | |
# :trial | |
tn.send_first_notification! | |
tn.assm_current_state | |
# :first_notification_sent | |
tn.send_second_notification! | |
tn.assm_current_state | |
# :second_notification_sent | |
tn.send_third_notification! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'active_record' | |
dbconfig = YAML::load(File.open('database.yml')) | |
ActiveRecord::Base.establish_connection(dbconfig) | |
ActiveRecord::Base.logger = Logger.new(File.open('database.log', 'a')) | |
class Employee < ActiveRecord::Base | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.gmap.map-preview | |
:width 540px | |
:height 400px | |
:margin 5px auto | |
:border 5px solid #DDD | |
:background #F1F1F1 url('/images/map-placeholder.jpg') center center no-repeat |