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
# Simple example of using ShadowFacter with RSpec to verify system configuration | |
# bradley @ http://railsmachine.com | |
# | |
# run with 'spec -c installed_test.rb' | |
require 'shadow_facter' | |
def installed_fact(n) | |
name = n | |
fact(name) { exec("#{name.to_s} --version") ? true : false } |
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
# deploy to staging from your current topic branch, with ease | |
set :branch, "origin/#{`git branch`.scan(/^\* (\S+)/)}" |
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
# NAME: recaptcha | |
# VERSION: 1.0 | |
# AUTHOR: Peter Cooper [ http://www.rubyinside.com/ github:peterc twitter:peterc ] | |
# DESCRIPTION: Sinatra plugin to provide CAPTCHA support through recaptcha.net | |
# COMPATIBILITY: 0.3.2 /and/ latest rtomayko Hoboken builds! | |
# LICENSE: Use for what you want, just don't claim full credit unless you make significant changes | |
# | |
# INSTRUCTIONS: | |
# 0. Check out an extended client code example at the footer of this file | |
# 1. Ensure _this_ file is lib/recaptcha.rb within your app's directory structure |
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 'rack/hoptoad_notifier' | |
use Rack::HoptoadNotifier do |config| | |
config[:api_key] = 'XXXXXXXX' | |
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
# urlmonitor - print out the URLs requested system wide on the main network interface | |
# Accept a network interface name as an optional argument | |
iface = ARGV.first | |
# No interface specified? Try to guess which one is king.. | |
unless iface | |
`ifconfig -l`.split.each do |iface| | |
next if iface =~ /^lo/ | |
break if `ifconfig #{iface}` =~ /inet (0|1|2)/ |
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
# rails foo_name -m http://gist.github.com/93545.txt | |
# rake rails:template LOCATION=http://gist.github.com/93545.txt | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
# Set up git repository | |
git :init | |
git :add => '.' |
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 'sinatra/metal' | |
class SinatraMetal < Sinatra::Base | |
include Sinatra::Metal | |
get '/sinatra' do | |
'hello sinatra!' | |
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
rails_root = "/data/github/current" | |
20.times do |num| | |
God.watch do |w| | |
w.name = "dj-#{num}" | |
w.group = 'dj' | |
w.interval = 30.seconds | |
w.start = "rake -f #{rails_root}/Rakefile production jobs:work" | |
w.uid = 'git' |
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 | |
# Lighter -- Campfire from the command line | |
# usage: ruby lighter.rb subdomain "Main Room" macournoyer@gmail ssl | |
require "rubygems" | |
require "tinder" | |
require "readline" | |
require "highline/import" | |
class Lighter | |
def initialize(room) |
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
# this script will migrate and reorganize a Paperclip attachments directory to utilize :id_partition | |
# Quickly put together by mario@orbitalvoice.com | |
# Assumes that your images to migrate < 1 000 000 | |
# | |
# Usage: ruby paperclip_partition_id_migrate.rb TARGET_DIR=/path/to/attachments/:class/:style | |
require '/opt/ruby-enterprise/lib/ruby/1.8/fileutils.rb' | |
def add_leading_zeros(i) |
OlderNewer