Skip to content

Instantly share code, notes, and snippets.

View icco's full-sized avatar
🏠
Working from home

Nat Welch icco

🏠
Working from home
View GitHub Profile
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb
# and made a lot more robust by me
# this implementation uses erb by default. if you want to use any other template mechanism
# then replace `erb` on line 13 and line 17 with `haml` or whatever
module Sinatra::Partials
def partial(template, *args)
template_array = template.to_s.split('/')
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
options = args.last.is_a?(Hash) ? args.pop : {}
options.merge!(:layout => false)
# Hoptoad integration example.
task "deploy:before" => "isolate:dotgems" do
if /\.gems/ =~ `git status`
abort "Changed gems. Commit '.gems' and deploy again."
end
ENV["TO"] = Deploy.env
end
@defunkt
defunkt / browser
Created March 1, 2010 10:01
pipe html to a browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo '<h1>hi mom!</h1>' | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then
@rcmachado
rcmachado / soy.vim
Created April 15, 2010 16:59
Soy template syntax
" Vim syntax file
" Language: Soy Templates
" Maintainer: Rodrigo Machado rcmachado@gmail.com
" Last Change: Thu Apr 15 16:59:00 GMT 2010
" Filenames: *.soy
" URL: http://gist.github.com/gists/367358/download
"
" Based on Smarty.vim
" For version 5.x: Clear all syntax items
#!/opt/local/bin/ruby -w
# git clone http://github.com/jjl/get_iplayer.git ~/Workspace/bin/get_iplayer/get_iplayer
# curl http://ftp.twaren.net/Unix/NonGNU/flvstreamer/macosx/flvstreamer_macosx_intel_32bit_latest --output ~/Workspace/bin/flvstreamer
# chmod 755 ~/Workspace/bin/flvstreamer
GET_IPLAYER = "~/Workspace/bin/get_iplayer/get_iplayer"
IPLAYER_CACHE = "~/.get_iplayer/radio.cache"
IPLAYER_HISTORY = "~/.get_iplayer/download_history"
FLVSTREAMER = "~/Workspace/bin/flvstreamer"
DOWNLOAD_PATH = "~/Music/BBC"
@icco
icco / gist:461991
Created July 2, 2010 22:24
svn-uberblame
#!/bin/bash
# originally from http://stackoverflow.com/questions/3143575/list-the-files-i-own-in-subversion/3144017
set -e
for file in `svn ls -R`; do
if [ -f $file ]; then
owner=`svn blame $file | tr -s " " " " | cut -d" " -f3 | sort | uniq -c | sort -nr | head -1 | tr -s " " " " | cut -d" " -f3`
if [ $owner ]; then
echo $file $owner
@jpf
jpf / gist:582162
Created September 16, 2010 09:11
--- SHDH statistics ---
42 parties transmitted, 41 parties received, 0.2% party loss
party min/avg/max/stddev = 21/47.976/105/17.097 days
<?php
/**
* Compares all running instances to all reserved instances and reports
* utilization. Useful for making sure you're not wasting money. :P
*
* Requires EC2_CERT and EC2_PRIVATE_KEY environment variables to be set.
*
* @author Dave
* @date 2010-10-05
*/
@icco
icco / license
Created November 16, 2010 19:50 — forked from defunkt/license
MIT License Gist
#!/bin/sh -e
# Usage: license
# Prints an MIT license appropriate for totin' around.
#
# $ license > COPYING
#!/bin/sh
echo "Copyright (c) `date +%Y` Nathaniel Welch
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@robhurring
robhurring / Rakefile
Created December 7, 2010 20:09
Delayed Job with Sinatra -- without sinatra specific gems, etc.
task :environment do
require './dj-sinatra'
end
namespace :jobs do
desc "Clear the delayed_job queue."
task :clear => :environment do
Delayed::Job.delete_all
end