Skip to content

Instantly share code, notes, and snippets.

@sumskyi
sumskyi / magent.yml
Created June 23, 2011 17:07
replica set yml
development: &dev
host:
- 127.0.0.1
27017
- 0.0.0.0
27017
database: queue
Feature: When a user associates social network accounts with their postpone.it account
Background:
Given I am a new, authenticated user
Then I go to the accounts page
Scenario: User can authorize Facebook
Then I should see "Facebook (0)"
And we authorize with "Facebook"
Then I should have been authorized with "Facebook"
And I should see "Facebook (1)"
json = {
:as_of => @search.until.in_time_zone.xmlschema
}
if @updates.max_distance
json[:next_offset] = @search.next_offset
json[:distance] = @updates.max_distance
end
json[:updates] = @updates.map do |el|
class << Marshal
def load_with_rails_classloader(*args)
begin
load_without_rails_classloader(*args)
rescue ArgumentError, NameError => e
if e.message =~ %r(undefined class/module)
const = e.message.split(' ').last
const.constantize
retry
else
Scenario: Get List of My Hitchhiking Items via API
Given the existing things:
|name|
|The Guide (duh)|
|A towel|
|Sub-Etha Sens-O-Matic|
|Pan Galactic Gargle Blaster|
|Kill-o-Zap blaster pistol|
And the existing accounts:
|email|name|password|
@sumskyi
sumskyi / comment.rb
Created February 24, 2011 23:16
my FK rescueing
class Comment < ActiveRecord::Base
belongs_to :post
def create_or_update
super
rescue ActiveRecord::InvalidForeignKey => e
e.message =~ /REFERENCES `([^`]*)`/
errors[:"#{$1}"] = 'Foreign Key Constraint Failed'
false
end
@sumskyi
sumskyi / locations.rb
Created February 24, 2011 10:11
app/models/location.rb
class Location < ActiveRecord::Base
searchable do
integer :id
spellchk :name
latlon :lat
latlon :lon
string :geohash
end
class << self
# (1) copy the newrelic rpm java client into #{RAILS_ROOT}/solr/newrelic
# (2) add a newrelic.yml in that directory with you API key
# (3) add this monkey patch in an initializer to load newrelic with the solr server
Sunspot::Server.class_eval do
def run
command = ['java']
command << "-Xms#{min_memory}" if min_memory
command << "-Xmx#{max_memory}" if max_memory
command << "-Djetty.port=#{port}" if port
command << "-Dsolr.data.dir=#{solr_data_dir}" if solr_data_dir
@sumskyi
sumskyi / cap_logs.rb
Created January 24, 2011 13:12
cap_logs.rb
namespace :logs do
desc '=> logs:rails'
task :default do
rails
end
desc "watch rails logs"
task :rails, :roles => :app do
stream "tail -f #{deploy_to}/shared/log/production.log"
@sumskyi
sumskyi / .ackrc
Created January 17, 2011 12:46
my .ackrc
--type-set=sass=.sass
--type-set=scss=.scss
--type-set=haml=.haml
--type-add=ruby=.haml
--type-add=js=.javascript
--ignore-dir=target/
--ignore-dir=.rsync_cache/
--ignore-dir=coverage/