Skip to content

Instantly share code, notes, and snippets.

require "capybara"
# Encapsulate some jQuery UI interactions so we can call them cleanly using Capybara.
module Capybara::JQueryUI
# Find the jQuery UI Autocomplete widget corresponding to this element
def autocompleter
jquery_result(jquery_this(".autocomplete('widget')").first)
end
# Fill in an autocompletable field and accept a completion.
def all_delayed_timestamps
guess = 100
current = []
until (current = Resque.delayed_queue_peek(0, guess)).size < guess
guess = guess * guess
end
current
end
def all_delayed_jobs
#include <iostream>
using namespace std;
int main() {
const int NUM_ELEMENTS = 8; // Number of elements
int userVals[NUM_ELEMENTS]; // User numbers
int i = 0; // Loop index
int sumVal = 0; // For computing sum
// Prompt user to populate array
# For those times when I don't want to keep track of what arguments are being
# given to Wisper::Publisher#publish ... the Wisper rspec matchers seem like
# much overkill
class MagicListener
def method_missing(method_sym, *arguments, &block)
[method_sym] + arguments
end
def respond_to?(method_sym, include_private = false)
#!/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?