Skip to content

Instantly share code, notes, and snippets.

@smathy
smathy / gist:116460
Created May 23, 2009 01:27
Scary SQLite bug
#!/usr/bin/env ruby
require 'rubygems'
require 'sqlite'
file = 'foo.sqlite'
File.unlink(file)
db = SQLite::Database.new( file )
db.execute( "CREATE TABLE foos ( id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(255))" )
@smathy
smathy / .bash_profile
Created July 21, 2009 23:57
git and svn tracking prompt
current_git_branch() {
git_exists=`git branch 2>/dev/null | sed -ne'/^\* /s///p'`
if [[ "$git_exists" != "" ]]; then
if [[ "$git_exists" == "(no branch)" ]]; then
git_exists="\e[31m\]$git_exists\e[0m\]"
fi
echo "$git_exists "
fi
unset git_exists
@smathy
smathy / functions.bash
Created July 28, 2009 19:29
Bash functions for svn
#!/bin/bash
alias inf=svn\ info
alias ci=svn\ ci
alias up=svn\ up
alias st=svn\ st
export RRAKE=`which rake`
export MM="rake test:units"
@smathy
smathy / .ackrc
Last active September 3, 2015 22:25
Various config files for Rails, github, etc..
--type-add=ruby=.haml,sass=.sass
@smathy
smathy / survey.md
Created November 6, 2009 00:35 — forked from radar/survey.md

What did you do to get good at Rails?

In order...

  1. Got good at Ruby (read the pickaxe cover-to-cover).
  2. Read a Rails tutorial (AWDwR).
  3. Found a cooperative commercial client to write an actual application for (and billed him at reduced rates because I was learning).
  4. Found every forum I could online to find people asking questions, then researched (mainly in the Rails source) and answered questions I was pretty sure of. Waited for others to answer questions I wasn't sure of and checked my answers against theirs.

Who taught you what you know?

@smathy
smathy / Chapter 05.markdown
Created November 6, 2009 21:43
Learn to Program

Chapter 2

Each one builds on the previous, ie. I re-use constants defined earlier.

Hours in a year

HOURS_IN_DAY = 24
DAYS_IN_YEAR = 365.242199
HOURS_IN_YEAR = HOURS_IN_DAY * DAYS_IN_YEAR

puts "Hours in an astronomical year: #{HOURS_IN_YEAR}"

// ==UserScript==
// @name LighthouseBadge
// @namespace http://fluidapp.com
// @description Adds a badge showing the number of open tickets assigned to you.
// @include *
// @author Adam Tucker http://adamjt.net
// ==/UserScript==
// How often to check for new tickets in milliseconds
var updateInterval = 300000;
require 'rubygems'
require 'rack'
require 'nokogiri'
require 'open-uri'
class HelloWorld
def call(env)
lines = Nokogiri::HTML(open('http://stannard.net.au/blog/index.cfm/2009/11/3/Hello-World-with-ColdFusion-and-Spring')).css('div.code').to_s.count("\n")
[ 200, { "Content-type" => "text/plain" }, "How can it take #{lines} lines to say Hello?" ]
end
@smathy
smathy / .bash_profile
Created December 18, 2009 16:50
Scripts for opening browser to github or lighthouse from console
alias gh=~/bin/gh.sh
alias lh=~/bin/lh.pl
function r18 {
r_comb 1.8 "ruby rb-rubygems"
}
function r19 {
r_comb 1.9 ruby19
}
function r_comb {
for i in `port contents $2 | grep /bin/`