Skip to content

Instantly share code, notes, and snippets.

class CreateGenresShows < ActiveRecord::Migration
def self.up
create_table :genres_shows, :id => false do |t|
t.integer :show_id
t.integer :genre_id
end
end
def self.down
drop_table :shows_genres
if(options.type == 'spy'){
// May have issues with scope/context that will need investigating if they crop up
expectation.original_method.apply(mock, arguments);
}
var BOSH_SERVICE = 'https://jamie-template.local/http-bind/';
var connection = null;
function rawInput(data)
{
console.log('RECV: ' + data);
}
function rawOutput(data)
{
Strophe.addConnectionPlugin('connectionmanager', {
pingTime: 10000, // the time in ms between each ping
timeoutTime: 8000, // the time in ms to wait for a ping to return
pingInterval: null,
connection: null,
init: function(connection) {
this.connection = connection;
},
@kernow
kernow / gist:706491
Created November 19, 2010 13:07
Mongoid criteria problem?
# I would expect all of the following to return the same results
# Works as expected
Article.find(:first, :conditions => { :slug => 'blah', :published => true })
# On latest beta gem errors with ArgumentError: wrong number of arguments (2 for 0..1)
# Works on latest github master commi
Article.where(:published => true).find(:first, :conditions => { :slug => 'blah' })
# On latest beta gem erros with ArgumentError: wrong number of arguments (2 for 0..1)
@kernow
kernow / gist:707239
Created November 19, 2010 21:40
mongoid key issue
class Car
include Mongoid::Document
field :name
field :colour
key :name
end
c1 = Car.new :name => 'bob', :colour => 'red'
@kernow
kernow / gist:740495
Created December 14, 2010 14:29
problem running selenium with capybara/cucumber
# features/ask_a_question.feature
Feature: Asking a question
@javascript @wip
Scenario Outline: Using the question preview
Given that I am a user
When I go to the homepage
And I fill in "question_title" with "<Question Title>"
And I fill in "question_body" with "<Input Body>"
# cucumber feature
Scenario: Add member to mailing list
Given I am on the registration page
When I fill in my details
And I check "add me to the mailing list"
And I press "Sign up"
When the account is confirmed the member should be added to the mailing list
Scenario: Don't add member to mailing list
>> r = Company.search "teach"
=> [#<Company model: nil, avatar_mime_type: nil, avatar_size: nil, charity: false, address: "", permalink: "Finance/Teaching/conn-ortiz", name: "Conn-Ortiz", _keywords: ["love", "teach", "teaching", "conn", "ortiz"], avatar_uid: nil, created_at: Thu, 16 Dec 2010 11:19:33 UTC +00:00, category: "Teaching", member_id: nil, updated_at: Fri, 17 Dec 2010 16:33:30 UTC +00:00, url: "", _id: BSON::ObjectId('4d09f5c56c78035f08000027'), contact_title: "", tel: "", contact_surname: "", avatar_ext: nil, contact_forename: "", linkedin: nil, description: "We love teaching", avatar_name: nil, email: "ortiz_conn@feeney.uk", sector: "Finance">]
>> r = Company.search "teaching"
=> [#<Company model: {"_id"=>BSON::ObjectId('4d09f5c56c78035f08000027'), "_keywords"=>["love", "teach", "teaching", "conn", "ortiz"], "name"=>"Conn-Ortiz", "permalink"=>"Finance/Teaching/conn-ortiz", "address"=>"", "charity"=>false, "avatar_size"=>nil, "avatar_mime_type"=>nil, "model"=>nil, "category"=>"Teaching", "created_a
criteria.merge!( :_keywords => { :$in => words } )
search_result = collection.map_reduce(search_map(words), search_reduce, {:query => criteria, :finalize => search_finalize})
def search_reduce
"function( key , values ){return { model: values[0]};}"
end
def search_finalize
"function( key , values ){return values.model;}"