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'
@georgkreimer
georgkreimer / gist:537794
Created August 19, 2010 12:44
pretty print json in ruby
require 'json'
my_json = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" }
puts JSON.pretty_generate(my_json)
Which gets you...
{
"array": [
1,
2,
3,
@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
# FIRST: Environment variables
knife_env = ENV['KNIFE_ENV']
knife_org = ENV['KNIFE_ORG']
knife_config_dir = ENV['KNIFE_CONFIG_DIR']
knife_config_file = ENV['KNIFE_CONFIG_FILE']
if knife_env.blank?
`git branch 2> /dev/null` =~ /^\*\s(.*)$/
git_branch = $1
@ayosec
ayosec / gems.md
Created March 2, 2011 17:32
Gems collection
@mislav
mislav / gist:938183
Created April 23, 2011 02:28
Faraday SSL example
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
@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
@mattetti
mattetti / rack_example.ru
Created December 8, 2011 13:58
Very basic rack application showing how to use a router based on the uri and how to process requests based on the HTTP method used.
#########################################
# Very basic rack application showing how to use a router based on the uri
# and how to process requests based on the HTTP method used.
#
# Usage:
# $ rackup rack_example.ru
#
# $ curl -X POST -d 'title=retire&body=I should retire in a nice island' localhost:9292/ideas
# $ curl -X POST -d 'title=ask Satish for a gift&body=Find a way to get Satish to send me a gift' localhost:9292/ideas
# $ curl localhost:9292/ideas
@webframp
webframp / reposplit.sh
Created December 15, 2011 03:37
Bash script to split multi-cookbook repo into individual git repos, retaining history, and uploads to github
#!/bin/bash
for cookbook_dir in `ls community-cookbooks`; do
if [ $cookbook_dir != 'readme.md' ]; then
REPO=chef-$cookbook_dir
git clone --no-hardlinks ./community-cookbooks/ $REPO
SAVEDIR=`pwd`
cd $REPO
git filter-branch --subdirectory-filter $cookbook_dir HEAD -- --all --prune-empty
git reset --hard
@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