Skip to content

Instantly share code, notes, and snippets.

View jellybob's full-sized avatar

Jon Wood jellybob

View GitHub Profile
def me
user_classes = ["User", "Account"]
methods = [:email_address, :email, :username, :login]
user_classes.each do |class_name|
begin
klass = class_name.constantize
methods.each do |method|
return klass.send("find_by_#{method}", "jon@blankpad.net") if klass.new.respond_to?(method)
end
@jellybob
jellybob / Client Only
Created January 28, 2010 12:40 — forked from btm/build_chef_0.8
Installing on Debian sid
echo "deb ftp://mir1.ovh.net/debian/ sid main contrib non-free" > /etc/apt/sources.list
echo "deb-src ftp://mir1.ovh.net/debian/ sid main contrib non-free" >> /etc/apt/sources.list
apt-get update
apt-get install -y ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential wget ssl-cert rubygems git-core rake liblibxml-ruby librspec-ruby zlib1g-dev libxml2-dev
gem sources -a http://gems.opscode.com
gem install jeweler merb-core cucumber uuidtools json libxml-ruby --no-ri --no-rdoc
mkdir ~/src
cd ~/src
git clone git://github.com/opscode/chef.git
git clone git://github.com/opscode/ohai.git
search(:users).each do |user|
puts "Found #{user.id}"
end
<!DOCTYPE html>
<html>
<head>
<script src="http://www.google.com/jsapi?key=ABQIAAAAFGHbizpn9jfT8F79BhK2CRQBcqlJQAiZ8qPJLW0U41gaFClPGxSlTQ2kK3woukL0OnUH00YrxzWNeg"></script>
<script>
google.load("feeds", "1");
function init() {
var feed = new google.feeds.Feed("http://twitter.com/statuses/user_timeline/25873473.rss")
feed.load(function (result) {
service "slapd" do
supports :restart => true, :status => true
action [ :enable, :start ]
end
# ... some shit ...
unless node[:slapd][:some_shit_has_been_done]
service "slapd" do
action :stop
@jellybob
jellybob / gist:478222
Created July 16, 2010 10:46
A snippet of the Sinatra app I'm using to interact with chef databags
# ...snip...
get '/users' do
@users = User.all
erb :users
end
get '/users/new' do
@user = User.new
erb :user_form
end
unless ARGV[0] && ARGV[1]
puts "Usage: set_password.rb username password"
exit 1
end
require 'chef'
require 'chef/config'
require 'chef/webui_user'
Chef::Config.from_file(File.expand_path("~/.chef/knife.rb"))
require 'chef/config'
require 'chef/node'
Chef::Config.from_file(File.join("etc", "chef", "client.rb"))
node = Chef::Node.load("node_name")
chosen_server = nil
ruby_block "choose server" do
block do
chosen_server = `hideous java command`
end
end
puts chosen_server
Failure/Error: it { should_not redirect_to("/login") }
Expected response to be a <:redirect>, but was <200>.
Expected block to return true value.