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 'dm-tokyo-adapter' | |
# Tokyo Tyrant connection. | |
# start the server with the following: | |
# | |
# ttserver -port 1978 somefile.tct | |
DataMapper.setup(:default, :adapter => 'tokyo_tyrant', :host => 'localhost', :port => 1978 ) |
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
# Allows you to build a Hash in a fashion very similar to Builder. Example: | |
# | |
# HashBuilder.build! do |h| | |
# h.name "Brent" | |
# h.skillz true | |
# h.location do | |
# h.planet "Earth" | |
# 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
#!/bin/bash | |
FIZZBUZZLIB="${FIZZBUZZLIB:-/usr/local/lib/fizzbuzz}" | |
source "${FIZZBUZZLIB}/fizzbuzz.inc.sh" | |
fizzbuzz $1 |
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
#!/bin/bash - | |
command_not_found_handle () { | |
local Fizz=3 Buzz=5 | |
[ $(( $2 % $1 )) -eq 0 ] && echo -n $1 && [ ${!1} -eq 3 ] | |
} | |
for i in {1..100} | |
do | |
Fizz $i && ! Buzz $i || echo -n $i |
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 'spec_helper' | |
describe Account do | |
before(:each) do | |
@account = Account.new( | |
:first_name => 'obligatory', | |
:last_name => 'name', | |
:email => 'email@address', | |
:address => '123 Any St.', | |
:city => 'Omaha', |
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 Something < Model | |
Model.setup | |
field :first_name, :required | |
field :last_name, :required | |
field :organization | |
end | |
me = Something.new(:first_name => 'First', :last_name => 'Last') | |
me.valid? |
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 Canvas | |
class Account < Canvas::Model | |
Canvas::Model.setup | |
attr_reader :instances | |
field :id | |
field :first_name, :required => true | |
field :last_name, :required => true | |
field :email, :required => true |
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
#!/bin/bash - | |
source ../bignum.sh | |
testBignumSanitize() { | |
local a='+|4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0' | |
assertEquals "Sanitize failed." "$( bn_sanitize "${a}" )" '+|4' | |
} |
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 self.uri(options = {}) | |
uri = [ Canvas::BASE_URI ] | |
uri.push self.model | |
uri.push options[:id].to_s if options[:id] | |
uri.push options[:action].to_s if options [:action] | |
apikey = options[:api_key] || @@api_key | |
uri.push "?api_key=#{apikey}" if apikey | |
uri.join '/' | |
end |
OlderNewer