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
| <!-- Add the following lines to theme's html code right before </head> --> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
| <script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script> | |
| <script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script> | |
| <!-- | |
| Usage: just add <div class="gist">[gist URL]</div> | |
| Example: <div class="gist">https://gist.github.com/1395926</div> | |
| --> |
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
| # put the file into spec/support | |
| shared_examples_for "ActiveModel" do | |
| include ActiveModel::Lint::Tests | |
| # to_s is to support ruby-1.9 | |
| ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m| | |
| example m.gsub('_',' ') do | |
| send m | |
| 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
| module Watchable | |
| def events | |
| @events ||= Hash.new { |h,k| h[k] = [] } | |
| end | |
| def fire event, *args | |
| events[event].each { |e| e[*args] } | |
| end | |
| def on event, &block |
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
| --colour | |
| -I app |
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 MultiValue < BasicObject | |
| attr_reader :secondary | |
| def initialize(obj, *secondary) | |
| @obj, @secondary = obj, secondary | |
| end | |
| def method_missing(sym, *args, &block) | |
| @obj.__send__(sym, *args, &block) | |
| 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
| source :rubygems | |
| gem "sinatra", "~> 1.3.2" | |
| group :test do | |
| gem "minitest", "~> 2.10" | |
| gem "rack-test", "~> 0.6.1" | |
| gem "capybara", "~> 1.1" | |
| gem "capybara-webkit", "~> 0.11" | |
| gem "capybara_minitest_spec", "~> 0.2" |
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
| shared_examples_for "driver with javascript support" do | |
| before { @driver.visit('/with_js') } | |
| describe '#find' do | |
| it "should find dynamically changed nodes" do | |
| @driver.find('//p').first.text.should == 'I changed it' | |
| end | |
| end | |
| describe '#drag_to' do |
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
| SELECT hstore(array_agg(v), array_agg(c::text)) FROM ( | |
| SELECT v, COUNT(*) as c ,1 as agg from unnest(ARRAY['foo','bar','baz','foo']) v GROUP BY v) t | |
| GROUP BY agg | |
| --> "bar"=>"1", "baz"=>"1", "foo"=>"2" |
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
| # SSL self signed localhost for rails start to finish, no red warnings. | |
| # 1) Create your private key (any password will do, we remove it below) | |
| $ openssl genrsa -des3 -out server.orig.key 2048 | |
| # 2) Remove the password | |
| $ openssl rsa -in server.orig.key -out server.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
| require 'java' | |
| java_import java.nio.channels.FileChannel | |
| java_import java.nio.file.StandardOpenOption | |
| java_import java.nio.file.FileSystems | |
| path = FileSystems.default.get_path('/') | |
| option = StandardOpenOption::READ | |
| ch = FileChannel.open(path, option) |