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 CanCan | |
class Query | |
def sanitize_sql(conditions) | |
conditions | |
end | |
end | |
# customize to handle Mongoid queries in ability definitions conditions | |
class CanDefinition | |
def matches_conditions_hash?(subject, conditions = @conditions) |
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 Workflow | |
module MongoidInstanceMethods | |
def load_workflow_state | |
self.workflow_state | |
end | |
def persist_workflow_state(new_value) | |
self.workflow_state = new_value | |
save! | |
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
%w(rubygems mongoid rspec).each do |gem| | |
require gem | |
end | |
Mongoid.configure do |config| | |
name = "dirty_track_test" | |
host = "localhost" | |
config.master = Mongo::Connection.new.db(name) | |
config.persist_in_safe_mode = false | |
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
#!/usr/bin/env bash | |
# adapted from: http://rvm.beginrescueend.com/workflow/rvmrc/ | |
ruby_string="1.8.7" | |
gemset_name="cancan" | |
if rvm list strings | grep -q "${ruby_string}" ; then | |
# Load or create the specified environment |
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
namespace :gource do | |
desc "Build gource file" | |
task :build => :environment do | |
system("gource -s .05 -800x600 --disable-progress --stop-at-end --bloom-multiplier .4 --bloom-intensity 1.5 --hide-filenames --output-framerate 30 --user-image-dir #{Rails.root}/.git/avatar --output-ppm-stream #{Rails.root}/gource/pathways.ppm #{Rails.root}") | |
system("ffmpeg -y -b 3000k -r 30 -f image2pipe -vcodec ppm -i #{Rails.root}/gource/pathways.ppm -vcodec libx264 -vpre hq -vpre fastfirstpass #{Rails.root}/gource/pathways.mp4") | |
system("rm #{Rails.root}/gource/pathways.ppm") | |
end | |
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
class String | |
def bling | |
self + "inator" | |
end | |
def bling! | |
replace(self.bling) | |
end | |
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
require 'acceptance/acceptance_helper' | |
feature "Articles", %q{ | |
In order to have an awesome blog | |
As an author | |
I want to create and manage articles | |
} do | |
background do | |
Article.create!(:title => 'One') |
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
# CLOSURES IN RUBY Paul Cantrell http://innig.net | |
# Email: username "cantrell", domain name "pobox.com" | |
# I recommend executing this file, then reading it alongside its output. | |
# | |
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments, | |
# then trying to guess the output of the code! | |
# A closure is a block of code which meets three criteria: |
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
# with AWK | |
curl -s http://www.gutenberg.org/files/1080/1080.txt | | |
awk ' | |
BEGIN { FS="[^a-zA-Z]+" } | |
{ | |
for (i=1; i<=NF; i++) { | |
word = tolower($i) | |
words[word]++ | |
} |
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
require 'rubygems' | |
require 'yaml' | |
# A demonstration of YAML anchors, references and handling of nested values | |
# For more info, see: | |
# http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/ | |
stooges = YAML::load( File.read('stooges.yml') ) | |
# => { | |
# "default" => { |
OlderNewer