This file contains hidden or 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
class Book | |
include MongoMapper::Document | |
CONTEXTS = ['authors', 'rating','keywords', 'genre'] | |
CONTEXTS.each do |context| | |
key context, Array, :index => true | |
end | |
key :title, String<br /> | |
key :contexts, Array<br /> | |
This file contains hidden or 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
module MongoidAdapter | |
class InstanceAdapter < Sunspot::Adapters::InstanceAdapter | |
def id | |
@instance.id | |
end | |
end | |
class DataAccessor < Sunspot::Adapters::DataAccessor | |
def load(id) | |
@clazz.find(id) |
This file contains hidden or 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
class MigrateUserToDevise < ActiveRecord::Migration | |
def self.up | |
change_table :users do |t| | |
t.string :encrypted_password, :null => false, :limit => 128 | |
# ... | |
end | |
end | |
def self.down | |
end |
This file contains hidden or 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
#!/bin/bash | |
case "${1:-''}" in | |
'start') | |
# start commands here | |
/opt/nginx/sbin/nginx | |
;; | |
'stop') | |
# stop commands here | |
kill `cat /opt/nginx/logs/nginx.pid` |
This file contains hidden or 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
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
prepend_before_filter :get_api_key | |
# devise will look for params[:api_key] automatically. it might need to be configured in devise.rb | |
private | |
def get_api_key | |
if api_key = params[:api_key].blank? && request.headers["X-API-KEY"] | |
params[:api_key] = api_key |
This file contains hidden or 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
Sprockets::Helpers::RailsHelper::AssetPaths.class_eval do | |
class MissingAssetError < StandardError; end | |
def digest_for_with_presence_check(logical_path) | |
unless asset_environment[logical_path] | |
raise MissingAssetError.new("#{logical_path} doesn't exist") | |
end | |
digest_for_without_presence_check(logical_path) | |
end | |
alias_method_chain :digest_for, :presence_check |
This file contains hidden or 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
source :rubygems | |
gem "rake" | |
gem 'motion-logger' #cocoalumberjack wrapper |
This file contains hidden or 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
# [ UIViewController, UIView, etc. ]... | |
[ UIViewController ].each do |klass| | |
klass.class_eval do | |
def self.allocWithZone(zone) | |
super.tap do |x| | |
p " + alloc! #{x.inspect}" | |
end | |
end | |
alias_method 'old_dealloc', 'dealloc' |
This file contains hidden or 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
# from http://www.postgresql.org/message-id/[email protected] | |
# list databases & encodings | |
# psql --list | |
vacuumdb --full --analyze --username postgres --dbname mephisto && pg_dump mephisto -Ft -v -U postgres -f tmp/mephisto.tar && dropdb mephisto --username postgres && createdb --encoding UNICODE mephisto --username postgres && pg_restore tmp/mephisto.tar | psql --dbname mephisto --username postgres && vacuumdb --full --analyze --username postgres --dbname mephisto |
This file contains hidden or 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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |