Skip to content

Instantly share code, notes, and snippets.

View juanje's full-sized avatar

Juanje Ojeda juanje

View GitHub Profile
Yasushi / init.rb
Created February 24, 2009 07:08
Redmine Gist embed plugin
# vendor/plugins/redmine_gist/init.rb
require 'redmine'
require 'open-uri'
Redmine::Plugin.register :redmine_gist do
name 'Redmine Gist embed plugin'
author 'Yasushi Abe <>'
description 'This is a plugin for Redmine'
lusis / irbrc.rb
Created January 26, 2011 16:07
Add this to disable irb echo
# via
def irb_verbosity_toggle
irb_context.echo ? irb_context.echo = false : irb_context.echo = true
ayosec /
Created March 2, 2011 17:32
Gems collection
juanje / gist:1210545
Created September 12, 2011 03:49
Ruby class template based on attribs and a passed hash
class Base
def initialize args
update args
def update args
args.each do |k,v|
send "#{k}=", v if respond_to? k
fnichol /
Created December 28, 2011 17:41
Vagrantify: Create a chef-solo enabled Vagrant virtual machine for development


gem install thor
mkdir -p ~/vagrants && cd ~/vagrants
curl -LO
chmod 755 vagrantify


./vagrantify init webserver

karmi / accessing_knife_rb_config_from_script.rb
Created January 1, 2012 11:37
Accessing knife.rb configuration from a Ruby script (eg. a Rakefile)
require 'fog'
require 'chef/config'
EC2 = provider: 'AWS',
region: Chef::Config[:knife][:region],
aws_access_key_id: Chef::Config[:knife][:aws_access_key_id],
aws_secret_access_key: Chef::Config[:knife][:aws_secret_access_key]
servers = { |s| s.tags["Name"] =~ /ec2\-test\-/ && s.state == "running" }
application "redmine" do
path "/opt/redmine"
owner "nobody"
group "nogroup"
repository "git://"
revision "2.0-stable"
packages ["build-essential",
jtimberman / aws_main.rb
Created April 11, 2012 13:53
Load data bag items from Ruby DSL files
# Put this in ~/chef-repo/data_bags/aws/main.rb
# Upload it to the Chef Server with:
# knife data bag item rb aws main.rb
# Export the two AWS values for your account.
'id' => "main",
'aws_access_key_id' => ENV['AWS_ACCESS_KEY_ID'],
acrmp /
Created November 10, 2012 00:05
Mocking out a library in Chef

Example of mocking out a library in Chef so you can test the provider in isolation.

If you want to test the library itself you can do more normal Ruby things.

jtimberman / rename-node.rb
Created March 2, 2012 07:47 — forked from mpasternacki/rename-node.rb
A knife exec script to change Chef node's name.
#!./bin/knife exec
# A knife exec script to change chef node's name, preserving all the attributes.
# Usage: knife exec rename-node.rb old-name new-name
# Script retrieves the Node object, changes its 'name' attribute,
# creates new Node object with updated name and rest of attributes
# untouched. Then it deletes old Node and Client objects from
# database, and logs into the server to update it: