Skip to content

Instantly share code, notes, and snippets.

View jnewland's full-sized avatar

Jesse Newland jnewland

View GitHub Profile
ipd (dev)> Host.scoped(:conditions => { :enabled => true }).scoped(:conditions => ['free_ram > ?', 1024] )
Host Load (0.3ms) SELECT * FROM "hosts" WHERE ((free_ram > 1024) AND ("hosts"."enabled" = 't'))
require 'sinatra/metal'
class SinatraMetal < Sinatra::Base
include Sinatra::Metal
get '/sinatra' do
'hello sinatra!'
end
end
# 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 => '.'
# 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)/
require 'rack/hoptoad_notifier'
use Rack::HoptoadNotifier do |config|
config[:api_key] = 'XXXXXXXX'
end
# 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
class Date
def self.next_weekday(original_date=Date.today)
weekdays_from(original_date, 1)
end
def self.weekdays_since(original_date, now=Date.today)
weekdays = 1..5
cursor = original_date
weekdays_skipped = 0
until cursor == now do
@jnewland
jnewland / deploy.rb
Created February 22, 2009 23:43 — forked from defunkt/deploy.rb
# deploy to staging from your current topic branch, with ease
set :branch, "origin/#{`git branch`.scan(/^\* (\S+)/)}"
# 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 }
# A Sinatra App as a Rails Plugin
#
# In your Edge Rails app:
#
# ruby script/plugin install git://gist.github.com/50625.git
require 'sinatra/base'
class SinatraRailsPlugin < Sinatra::Base