Skip to content

Instantly share code, notes, and snippets.

@sohooo
sohooo / gist:79815
Created March 16, 2009 10:19
Ruby T-Shirt text
["do", "dont do"].include? "try"
#=> false
@sohooo
sohooo / vhost.sh
Created March 18, 2009 20:17 — forked from trey/vhost.sh
vhosts script
#!/bin/sh
ME=your-username
DIR=/Users/$ME/Sites/$1
if [ ! -d $DIR ]
then
sudo -u $ME mkdir $DIR
sudo -u $ME touch $DIR/index.php
echo "<h1>$1</h1>" >> $DIR/index.php
fi
@sohooo
sohooo / atp_calendar.rb
Created April 8, 2009 15:18
retrieve tournament info from ATP homepage to create ical
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'icalendar'
require 'date'
class ATPCalendar
def initialize(source)
@source = source
@sohooo
sohooo / vhost.sh
Created May 10, 2009 09:04 — forked from trey/vhost.sh
vhost script
#!/bin/sh
ME=soho
DIR=/Users/$ME/Sites/$1
if [ ! -d $DIR ]
then
sudo -u $ME mkdir $DIR
sudo -u $ME touch $DIR/index.php
echo "<h1>$1</h1>" >> $DIR/index.php
fi
@sohooo
sohooo / carbon.md
Created November 15, 2009 19:15 — forked from defunkt/carbon.md
remove evil whitespace

Vim

autocmd BufWritePre * :%s/\s\+$//e

Emacs

(add-hook 'before-save-hook 'delete-trailing-whitespace)

Textmate

@sohooo
sohooo / gist:260245
Created December 19, 2009 21:01 — forked from mudge/gist:191473
Sinatra Rack Testing
require 'sinatra_app'
require 'test/unit'
require 'rack/test'
set :environment, :test
class SinatraAppTest < Test::Unit::TestCase
include Rack::Test::Methods
# Make all tests transactional.
@sohooo
sohooo / Capfile
Created January 24, 2010 10:29 — forked from mig/Capfile
Wordpress Capistrano task
require 'capistrano/version'
load 'deploy'
# Customize the following variables
set :domain, "host.example.com"
set :user, "username"
set :application, "my_wordpress_blog"
set :deploy_to, "/var/www/apps/#{application}"
# These variables probably don't need to change
@sohooo
sohooo / git-deploy.sh
Created June 5, 2011 07:37
$ git deploy
#!/bin/sh
# Git push then pull over ssh
#
# Supposing you have these environments on the same ssh git remote:
# project/origin.git
# project/dev/.git
# project/prod/.git
#
# You can then push the current branch and pull it in dev/ and prod/ by doing:
# $ git deploy dev
@sohooo
sohooo / memorysize_raw.rb
Created February 3, 2012 11:58 — forked from ahpook/memorysize_raw.rb
Custom facter fact for raw memorysize.
# for some reason facter takes the raw memorysize and reports it as
# a formatted string, which is useless for calculation
#
Facter.add("memorysize_raw") do
confine :kernel => :linux
setcode do
size = 0
File.readlines("/proc/meminfo").each do |l|
size = $1.to_f if l =~ /^MemTotal:\s+(\d+)/
@sohooo
sohooo / guard_lightroom.sh
Created March 24, 2012 15:30
This little script creates incremental rsync backups from my external Lightroom Library (but could be anything) to another external harddrive. Backups are important, you know.
#!/bin/bash
# This little script creates incremental rsync backups from my
# external Lightroom Library (but could be anything) to another
# external harddrive. Backups are important, you know.
# The result looks like this:
#
# 20120105-1759
# 20120107-1928