Skip to content

Instantly share code, notes, and snippets.

#!/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 )
# 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
#
@ess
ess / bin_fizzbuzz.sh
Created July 20, 2010 01:32
Embedded elements for a write-up on cucumber and rspec for bash testing
#!/bin/bash
FIZZBUZZLIB="${FIZZBUZZLIB:-/usr/local/lib/fizzbuzz}"
source "${FIZZBUZZLIB}/fizzbuzz.inc.sh"
fizzbuzz $1
#!/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
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',
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?
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
#!/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'
}
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
We couldn’t find that file to show.