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 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}", "[email protected]") if klass.new.respond_to?(method) | |
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
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 |
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
search(:users).each do |user| | |
puts "Found #{user.id}" | |
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
<!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) { |
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
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 |
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
# ...snip... | |
get '/users' do | |
@users = User.all | |
erb :users | |
end | |
get '/users/new' do | |
@user = User.new | |
erb :user_form | |
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
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")) |
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 'chef/config' | |
require 'chef/node' | |
Chef::Config.from_file(File.join("etc", "chef", "client.rb")) | |
node = Chef::Node.load("node_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
chosen_server = nil | |
ruby_block "choose server" do | |
block do | |
chosen_server = `hideous java command` | |
end | |
end | |
puts chosen_server |
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
Failure/Error: it { should_not redirect_to("/login") } | |
Expected response to be a <:redirect>, but was <200>. | |
Expected block to return true value. |
OlderNewer