Skip to content

Instantly share code, notes, and snippets.

@pcreux
pcreux / chpwd_update_git_vars.sh
Created November 30, 2009 18:13 — forked from scelis/chpwd_update_git_vars.sh
Zsh prompt with git status
update_current_git_vars
#!/usr/bin/env ruby
require 'csv'
require 'date'
CSV::Reader.parse(File.open(ARGV[0])) do |row|
date = row[0].match(/^\d{4}-\d{2}-\d{2}/) ? Date.strptime(row[0], "%Y-%m-%d") : row[0]
hours = row[2]
memo = "#{row[3]} #{row[4]}"
puts "#{date} | #{hours} | #{memo}"
end
@pcreux
pcreux / Jabber-SH
Created December 17, 2009 06:17
Jabber-SH — SH console via XMPP/Jabber (GTalk) Jabber-SH allows to you to administrate a remote computer via a command line through a Jabber client. It’s like SSH via GoogleTalk! :)
#!/usr/bin/env ruby
# Jabber-SH — SH console via XMPP/Jabber (GTalk)
#
# Jabber-SH allows you to administrate a remote computer via a command line
# through a Jabber client. It’s like SSH via GoogleTalk! :)
# This is just a hack but it might be usefull sometime to run basic commands
# on a machine that is not accessible via ssh.
#
# Philippe Creux. pcreux/AT/gmail/DOT/com
@pcreux
pcreux / migrate_rubygems_to_ruby_enterprise_edition.rb
Created February 12, 2010 22:14
Migrate rubygems to Ruby Enterprise Edition (REE) - Make REE install the gems used by your default ruby environment.
#!/usr/bin/ruby
# Migrate rubygems to Ruby Enterprise Edition (REE)
# Make REE install the gems used by your default ruby environment.
REE_PATH = ENV['REE_PATH'] || Dir.glob('/opt/ruby-enterprise-*').last
unless REE_PATH
puts "Can't find path to ruby enterprise edition. Please use the following command:"
puts "REE_PATH=/path/to/ruby-enterprise ruby migrate-rubygems-to-ree"
@pcreux
pcreux / runner.rb
Created May 20, 2010 00:11
script/runner for Rails 3
#!/usr/bin/env ruby
# script/runner for rails 3.0
APP_PATH = File.expand_path('../../config/environment', __FILE__)
require 'rubygems'
require 'rails/commands/runner'
require 'rspec'
def set(attribute, &block)
before(:all) do
instance_variable_set("@#{attribute}", yield)
end
let(attribute) { instance_variable_get("@#{attribute}") }
end
# Set @@variable_name in a before(:all) block and give access to it
# via let(:variable_name)
#
# Example:
# describe Transaction do
# set(:transaction) { Factory(:transaction) }
#
# it "should be in progress" do
# transaction.state.should == 'in_progress'
# end
@pcreux
pcreux / boot.rb
Created August 31, 2010 15:08
Custom config/boot.rb to test a Rails 3 app with Integrity
require 'rubygems'
# Set up gems listed in the Gemfile.
GEMFILE_PATH = File.expand_path('../../Gemfile', __FILE__)
if File.exist?(GEMFILE_PATH)
# Force the rails 3 application to use its Gemfile
ENV['BUNDLE_GEMFILE'] = GEMFILE_PATH
require 'bundler'
Bundler.setup
end
@pcreux
pcreux / install_chef_client.sh
Created September 7, 2010 19:06
Bash script to install chef client on blank ubuntu 10.04 - lucid
#/bin/bash
# From http://wiki.opscode.com/display/chef/Package+Installation+on+Debian+and+Ubuntu
# Run: wget http://gist.github.com/raw/568876/install_chef_client.sh && bash install_chef_client.sh
echo "Add the Opscode APT Repository"
echo 'deb http://apt.opscode.com/ lucid main' | sudo tee /etc/apt/sources.list.d/opscode.list
sudo apt-get update
echo "Install curl"
sudo apt-get install curl
merb : chef-server (api) : worker (port 4000) ~ Started request handling: Tue Sep 07 15:25:42 -0700 2010
merb : chef-server (api) : worker (port 4000) ~ Params: {"format"=>nil, "action"=>"show", "id"=>"apps", "q"=>"*:*", "start"=>"0", "rows"=>"1000", "controller"=>"search", "sort"=>"X_CHEF_id_CHEF_X asc"}
merb : chef-server (api) : worker (port 4000) ~ undefined method `closed?' for nil:NilClass - (NoMethodError)
/usr/lib/ruby/1.8/net/http.rb:1060:in `request'
/usr/share/chef-server-api/lib/../../chef-solr/lib/chef/solr.rb:58:in `solr_select'
/usr/share/chef-server-api/lib/../../chef-solr/lib/chef/solr/query.rb:63:in `raw'
/usr/share/chef-server-api/lib/../../chef-solr/lib/chef/solr/query.rb:84:in `search'
/usr/share/chef-server-api/app/controllers/search.rb:48:in `show'
/usr/lib/ruby/1.8/merb-core/controller/abstract_controller.rb:315:in `send'
/usr/lib/ruby/1.8/merb-core/controller/abstract_controller.rb:315:in `_call_action'