Skip to content

Instantly share code, notes, and snippets.

View corey's full-sized avatar
😎
_

Corey Reece corey

😎
_
  • Bay Area, CA
View GitHub Profile
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"
@corey
corey / return.rb
Created June 18, 2009 17:20 — forked from lifo/return.rb
module Enumerable
def return
each do |i|
value = yield(i)
return value if value
end
nil
end
end
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
module Autoconf
extend self
def switches(config=nil)
case config
when String
switch(config)
when Enumerable
config.map {|item| switch(item) }.join(" ").strip
else
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')
@corey
corey / gist:188555
Created September 17, 2009 16:14 — forked from jsierles/gist:100837
#!/usr/bin/env ruby
require 'rubygems'
require 'thor'
require 'chef'
require 'chef/node'
require 'chef/rest'
# Please see the readme for overview documentation.
#
@corey
corey / index.txt
Created September 19, 2009 01:12 — forked from mmcgrana/index.txt
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:
# you'd obviously have more settings somewhere
set :scm, :git
set :repository, "git@github.com: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) }
# 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}'
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#