Some interesting gems to consider.
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
# | |
# 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' |
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 'json' | |
my_json = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" } | |
puts JSON.pretty_generate(my_json) | |
Which gets you... | |
{ | |
"array": [ | |
1, | |
2, | |
3, |
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
# 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 |
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
# 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 |
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
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' |
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
class Base | |
def initialize args | |
update args | |
end | |
def update args | |
args.each do |k,v| | |
send "#{k}=", v if respond_to? k | |
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
######################################### | |
# 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 |
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
#!/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 |
OlderNewer