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 'yaml' | |
def spit_context context, level=0 | |
spaces = " " * level | |
puts "#{spaces}context '#{context[0]}' do" | |
puts "#{spaces} setup do\n#{spaces} end\n\n" | |
spit_specs(context[1], level) | |
puts "#{spaces}end\n\n" | |
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
// TODO | |
// show spinner on loading | |
// | |
// element.identify() is a prototype function -- remove it so | |
// there are less methods to overwrite when switching backend | |
// also: addClassName / RemoveClassName | |
// | |
// clean up the namespace -- instead of long function names in the window | |
// have descriptive names in their own class | |
// |
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 'irb/completion' | |
require 'irb/ext/save-history' | |
ARGV.concat [ "--readline", "--prompt-mode", "simple" ] | |
IRB.conf[:SAVE_HISTORY] = 100 | |
if ENV['RAILS_ENV'] | |
rr = IRB.conf[:LOAD_MODULES].detect{|x| x =~ /environment$/}.gsub(/config\/environment$/, '') | |
IRB.conf[:HISTORY_FILE] = File.join(rr, '.irb_history') | |
else | |
IRB.conf[:HISTORY_FILE] = File.join(ENV['HOME'], '.irb_history') |
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 'yaml' | |
require 'rubygems' | |
gem 'twitter' | |
require 'twitter' | |
class AutoRetweet | |
def initialize search_phrase, config_file_name = 'config.yml' | |
@phrase = search_phrase | |
@config_file = config_file_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
# examples of using before_render | |
# http://github.com/xtoddx/before_render | |
class HiController < ApplicationController | |
before_render :hook_it_up | |
before_render :double_hooked, :if => lambda{|x| false} | |
before_render :cool_action, :only => [:index] | |
before_render :lousy_action, :except => [:index] | |
# just the page |
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 | |
print "MESSAGE> " | |
message = gets.gsub(/\s/, '').split(//) | |
print "PAD> " | |
pad = gets.gsub(/\s/, '').split(//) | |
message.zip(pad) do |mc, pc| | |
puts "#{mc} | #{pc} | #{'%2i' % (nm = mc[0] - ?a)} | #{'%2i' % (np = pc[0] - ?a)} | #{'%2i' % ((nm + np) % 26)} | #{(((nm + np) % 26) + ?a).chr}" |
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 'test/unit' | |
# | |
# The goal for this exercise is to get the test to pass while not returning the | |
# expected value. | |
# | |
# CompTest may be renamed, as may CompEntry, so don't rely on names. | |
# | |
class CompEntry | |
def add addend_a, addend_b |
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 | |
# This script runs all nova components in windows of a singe screen. | |
# Arguments: [nova.conf] [novarc] | |
function locate_binary { | |
# Called with the basename of a binary, like nova-api | |
# If we are in a nova checkout, use the bin/* version. | |
# Otherwise, get whatever is in ${PATH} for system wide nova | |
bin_name=${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
$HOME=File.expand_path(File.join(Dir.pwd, '..')) | |
Vagrant::Config.run do |config| | |
ip = "10.0.0.5" | |
aptdir = "#{$HOME}/aptcache/" | |
checkout = "#{$HOME}/openstack-cookbooks" | |
config.vm.box = "base" | |
config.vm.box_url = "http://images.ansolabs.com/vagrant/maverick64.box" | |
config.vm.network ip | |
config.vm.share_folder("v-apt", "/var/cache/apt", aptdir) | |
config.vm.provision :chef_solo do |chef| |
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/ruby | |
$: << 'fog/lib' | |
require 'fog' | |
# Get your api key / token `keystone-mange token list` | |
compute = Fog::Compute.new(:provider => 'Rackspace', | |
:rackspace_auth_token => '887665443383838', | |
:rackspace_management_url => 'http://127.0.0.1:8774/v1.0/', | |
:rackspace_username => 'joeuser', |
OlderNewer