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
define :mysql_database, :action => 'create' do | |
def mysql(command, config=nil, ) | |
"mysql --defaults-file=#{config} --execute=#{command.inspect}" | |
end | |
include_recipe "mysql::client" | |
# For now, use the super-user conf | |
case @node[:platform] | |
when "debian", "ubuntu" |
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
module Enumerable | |
def return | |
each do |i| | |
value = yield(i) | |
return value if value | |
end | |
nil | |
end | |
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
class Hash | |
# Accept a hash of values, changes the value in self | |
# from the key in the param to be indexed at the value of param | |
# and returns the new hash. Does not modify self. | |
# | |
# >> a = {"dog" => "meow", "bird" => "tweet" } | |
# => {"bird"=>"tweet", "dog"=>"meow"} | |
# >> a.rename_keys "dog" => "cat" | |
# => {"cat"=>"meow", "bird"=>"tweet"} | |
# >> a |
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
module Autoconf | |
extend self | |
def switches(config=nil) | |
case config | |
when String | |
switch(config) | |
when Enumerable | |
config.map {|item| switch(item) }.join(" ").strip | |
else |
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
articles = Article.find(:all) | |
articles.each do |article| | |
published_at = "#{published_at.year}-#{published_at.month}-#{published_at.day}" | |
author = article.user.login | |
permalink = article.permalink | |
title = article.title | |
excerpt = article.excerpt | |
body = article.body | |
fp = File.open("_posts/#{'draft-' if article.published_at.nil?}#{published_at}-#{permalink}.markdown", 'w') |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'thor' | |
require 'chef' | |
require 'chef/node' | |
require 'chef/rest' | |
# Please see the readme for overview documentation. | |
# |
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
For each Ruby module/class, we have Ruby methods on the left and the equivalent | |
Clojure functions and/or relevant notes are on the right. | |
For clojure functions, symbols indicate existing method definitions, in the | |
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can | |
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master, | |
ruby-to-clojure.*/* functions can be obtained from the source files in this | |
gist. | |
If no method symbol is given, we use the following notation: |
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
test |
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
# you'd obviously have more settings somewhere | |
set :scm, :git | |
set :repository, "[email protected]:defunkt/github.git" | |
set :branch, "origin/master" | |
set :migrate_target, :current | |
set(:latest_release) { fetch(:current_path) } | |
set(:release_path) { fetch(:current_path) } | |
set(:current_release) { fetch(:current_path) } |
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
# previously required http://github.com/mislav/addressable | |
# with changes merged upstream, main repo should work too: | |
# http://github.com/sporkmonger/addressable/ | |
require 'addressable/template' | |
# http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0followers | |
template = Addressable::Template.new 'http://{host=twitter.com}' + | |
'/statuses/followers{-prefix|/|id}.{format=json}' + | |
'?{-join|&|user_id,screen_name,cursor}' |
OlderNewer