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 "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. |
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 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 |
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
#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 |
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
# 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) |
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? |
OlderNewer