Skip to content

Instantly share code, notes, and snippets.

@smith
smith / statsd.rb
Created March 23, 2012 04:02
What a capistrano-notifier notifier could look like
require 'capistrano/notifier/base'
require 'statsd-instrument'
class Capistrano::Notifier::StatsD
include Capistrano::Notifier::Base
name :statsd
description 'Notifies StatsD of a deploy'
# The base module takes this method and loads it in as a task of the
# current capistrano instance
@smith
smith / ubuntu-ruby-1.9.2
Created March 15, 2012 20:39
bootstrap for ubuntu
bash -c '
# Ubuntu Ruby 1.9.2 Chef bootstrap script
# Is chef-client not installed?
if [ ! `which chef-client` ]; then
apt-get update
apt-get install -y wget libffi5 build-essential
# Is ruby installed?
if [ `which ruby` ]; then
@smith
smith / gist:1679216
Created January 25, 2012 22:17
ruby 1.9.2 crash
smith@iNeXT:~/Projects/Ridley:develop$ rvm current
ruby-1.9.2-p290@ridley
smith@iNeXT:~/Projects/Ridley:develop$ rails server
/Users/smith/.rvm/gems/ruby-1.9.2-p290@ridley/gems/yard-0.7.4/lib/yard.rb:38: [BUG] Bus Error
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
-- control frame ----------
c:0032 p:---- s:0101 b:0101 l:000100 d:000100 CFUNC :callcc
c:0031 p:0080 s:0098 b:0098 l:0012b0 d:0012b0 TOP /Users/smith/.rvm/gems/ruby-1.9.2-p290@ridley/gems/yard-0.7.4/lib/yard.rb:38
c:0030 p:---- s:0095 b:0095 l:000094 d:000094 FINISH
@smith
smith / things-i-like-about-iowa.html
Created December 15, 2011 15:48
Things I Like About Iowa - The Demo
<!doctype html>
<html>
<head>
<title>A Demo: Things I Like About Iowa</title>
</head>
<body>
<h1>Things I Like About Iowa</h1>
<a href="#">home</a>
<div id="container"></div>
/*
* Refs
*
* http://documentcloud.github.com/backbone/
* http://msdn.microsoft.com/en-us/scriptjunkie/hh377172.aspx
* http://arturadib.com/hello-backbonejs/
* http://stackoverflow.com/questions/5629972/integrating-json-feed-with-backbone-js
* http://stackoverflow.com/questions/6048480/backbone-js-fetch-problem-cant-refresh-data-immediately
* http://documentcloud.github.com/backbone/docs/todos.html
*
@smith
smith / gist:1248874
Created September 28, 2011 18:57
Redmine Backlogs Stacktrace
ActionView::TemplateError (Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id) on line #1 of vendor/plugins/redmine_backlogs/app/views/rb_stories/_story.html.erb:
1: <li class="model story <%= mark_if_closed(story) %> <%= "tracker" + story.tracker.id.to_s%>" id="<%= story_html_id_or_empty(story) %>">
2: <div class="id story_tooltip story_field" title="<%= render :partial => "rb_stories/tooltip", :object => story %>">
3: <div class="t"><%= issue_link_or_empty(story) %></div>
4: <div class="v"><%= id_or_empty(story) %></div>
vendor/plugins/redmine_backlogs/app/views/rb_stories/_story.html.erb:1
vendor/plugins/redmine_backlogs/app/views/rb_stories/_helpers.html.erb:23
vendor/plugins/redmine_backlogs/app/views/rb_master_backlogs/show.html.erb:73
app/helpers/application_helper.rb:868:in `content_for'
@smith
smith / solo.rb
Created September 9, 2011 20:58
Chef solo config
# Get the current path
dirname = File.dirname(__FILE__)
here = File.symlink?(dirname) ? File.readlink(dirname)
: File.expand_path(dirname)
cookbook_path [File.join(here, '..', 'cookbooks'),
File.join(here, '..', 'site_cookbooks')]
json_attribs File.join(here, 'solo-node.json')
@smith
smith / apps1.js
Created August 29, 2011 01:54
CloudFlare Apps JS
var _gaq = _gaq || [], vglnk = vglnk || {}, clicky_site_id = 0;
(window.__CF || window).addSequenceHandler = function() {
var a = {}, b = "", c;
window.document.onkeydown = function(d) {
c && clearTimeout(c), b += d ? d.keyCode : event.keyCode;
if (a[b])
for (var e = 0; e < a[b].length; e++)
a[b][e]();
c = setTimeout(function() {
b = ""
@smith
smith / mx.rb
Created August 5, 2011 14:43
Read domains from a CSV and get the IP of their MX.
# Read domains from a CSV and get the IP of their MX.
require 'resolv'
require 'csv'
Resolv::DNS.open do |dns|
CSV.foreach('/Users/smith/Desktop/domains.csv') do |row|
domain = row[1]
next if domain == 'domain' # heading
mxs = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
if mxs.length == 0