Skip to content

Instantly share code, notes, and snippets.

View juanje's full-sized avatar

Juanje Ojeda juanje

View GitHub Profile
@Yasushi
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 <yasushi.abe@gmail.com>'
description 'This is a plugin for Redmine'
@lusis
lusis / irbrc.rb
Created January 26, 2011 16:07
Add this to disable irb echo
# via http://tagaholic.me/2009/05/29/exploring-how-to-configure-irb.html#echo
def irb_verbosity_toggle
irb_context.echo ? irb_context.echo = false : irb_context.echo = true
end
@ayosec
ayosec / gems.md
Created March 2, 2011 17:32
Gems collection
@juanje
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
end
def update args
args.each do |k,v|
send "#{k}=", v if respond_to? k
end
@fnichol
fnichol / README.md
Created December 28, 2011 17:41
Vagrantify: Create a chef-solo enabled Vagrant virtual machine for development

Installation

gem install thor
mkdir -p ~/vagrants && cd ~/vagrants
curl -LO https://raw.github.com/gist/1528832/vagrantify
chmod 755 vagrantify

Usage

./vagrantify init webserver

@karmi
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'
Chef::Config.from_file('./.chef/knife.rb')
EC2 = Fog::Compute.new 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 = EC2.servers.select { |s| s.tags["Name"] =~ /ec2\-test\-/ && s.state == "running" }
application "redmine" do
path "/opt/redmine"
owner "nobody"
group "nogroup"
repository "git://github.com/redmine/redmine.git"
revision "2.0-stable"
packages ["build-essential",
"git",
"postgresql-server-dev-all",
"libgraphicsmagick++-dev",
@jtimberman
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
acrmp / 00_README.md
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
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: