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
// Naive proxy server to route data from 12345 to postgres as 5432 | |
// | |
// javac Server.java | |
// java -server Server | |
import java.io.IOException; | |
import java.nio.channels.*; | |
import java.nio.ByteBuffer; | |
import java.net.*; |
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
# Newbie Programmer | |
def factorial(x) | |
if x == 0 | |
return 1 | |
else | |
return x * factorial(x - 1) | |
end | |
end | |
puts factorial(6) | |
puts factorial(0) |
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
## Sibling constant resolution/scoping | |
module X | |
class Y; end | |
end | |
class X::Z | |
def self.y | |
Y | |
end | |
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
10.times do |i| args = File.readlines(__FILE__)[__LINE__-1].match(/\|(.+?)\|/)[1].split(/[, ]+/) | |
p args | |
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
def wait_conditionally_until | |
if page.driver.wait? | |
page.wait_until do | |
begin | |
yield | |
rescue Selenium::WebDriver::Error::WebDriverError => e | |
# do nothing - continue to wait for timeout | |
end | |
end | |
else |
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
def luhn?(c)(0..c.size).inject(0){|s,i|_=c[i,1].to_i;s+(i%2!=0?_:(_*2).to_s.split('').inject(0){|y,z|y+z.to_i})}%10==0 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
# mongoid issue #136 | |
require 'rails' | |
require 'rspec' | |
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
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
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db('testing') | |
end | |
class Parent | |
include Mongoid::Document | |
field :name |
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
#!/usr/bin/env ruby | |
require "rubygems" | |
require "jruby-jars" | |
args = [ "-jar", JRubyJars.stdlib_jar_path, | |
"-r", JRubyJars.stdlib_jar_path ].push(*$*) | |
exec("java", *args) |
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
1) Mongoid::Persistence .create! inserting with a field that is not unique when a unique index exists raises an error | |
Failure/Error: lambda { Person.create!(:ssn => "555-55-9999") }.should raise_error | |
expected Exception but nothing was raised | |
# ./spec/integration/mongoid/persistence_spec.rb:34 | |
# spec/integration/mongoid/association_attributes_spec.rb:3 | |
2) Mongoid::Collections .index_information returns index information from the collection | |
Failure/Error: Person.index_information["title_1"].should_not be_nil | |
expected not nil, got nil | |
# ./spec/unit/mongoid/collections_spec.rb:53 |
OlderNewer