This file contains 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
# Example JRuby program to display the JVM's available locales | |
# and their number, currency, and date formats. | |
# | |
# Keith R. Bennett, @keithrbennett | |
require 'java' | |
java_import 'java.util.Locale' | |
java_import 'java.text.DateFormat' | |
java_import 'java.text.NumberFormat' |
This file contains 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 "sinatra/base" | |
require "sinatra/namespace" | |
require "multi_json" | |
require "api/authentication" | |
require "api/error_handling" | |
require "api/pagination" | |
module Api | |
class Base < ::Sinatra::Base |
This file contains 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) |
This file contains 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 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 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 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 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 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 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 |