Skip to content

Instantly share code, notes, and snippets.

@nz
nz / autotest.rb
Created October 29, 2008 16:46
My autotest config file. With colored Growl support for Test::Unit and RSpec. Save in ~/.autotest
require 'autotest/redgreen'
Autotest.send(:alias_method, :real_make_test_cmd, :make_test_cmd)
Autotest.send(:define_method, :make_test_cmd) do |*args|
real_make_test_cmd(*args).sub('test/unit', %[rubygems -e "require 'redgreen'"])
end
Autotest.add_hook :initialize do |autotest|
autotest.add_exception(/^\.\/vendor/)
autotest.add_exception(/\.svn/)
@nz
nz / git-helper-functions.sh
Created October 30, 2008 05:52
Some shell functions I use to help me effortlessly do clean rebasing and pushing in git.
function rebase {
if [[ $1 == "" ]]; then master='master'; else master=$1; fi
branch=`git branch | grep \* | awk '{print $2}'` &&
git checkout $master && git pull && git rebase $master $branch
}
function push {
if [[ $1 == "" ]]; then master='master'; else master=$1; fi
branch=`git branch | grep \* | awk '{print $2}'` &&
rebase $master && git checkout $master && git merge $branch && git push &&
# 0. Do all your work in a local branch, preferably named loosely for the feature you're working on.
git checkout -b work
# 1. Make sure all your changes are committed.
git commit -m "changes to a local branch"
# 2. Update the master branch, pulling down the latest code from the rest of the team
git checkout master
git pull
// The search query for this was my address here in Bremerton. This is the result.
{"places":
{"place":
[{ "woeid":2368481,
"placeTypeName":"Town",
"placeTypeName attrs":{"code":7},
"name":"Bremerton",
"country":"United States",
"country attrs":{"type":"Country","code":"US"},
"admin1":"Washington",
class GatheringPlan < ActiveRecord::Base
belongs_to :roov
belongs_to :gathering_idea
has_many :participations, :class_name => "GatheringPlanParticipation"
has_many :participants, :through => :participations, :source => :user
has_many :votes, :class_name => "GatheringPlanVote"
has_many :suggestions, :through => :votes, :source => :suggestion
end
[4294967295,4294967295].to_yaml
#=> "--- \n- 4294967295\n- 4294967295\n"
[4294967295,4294967295].to_yaml.size
#=> 31
[4294967295,4294967295].to_json
#=> "[4294967295,4294967295]"
[4294967295,4294967295].to_json.size
#=> 23
class User < AR::Base
has_many :gathering_participations
has_many :gatherings, :through => :gathering_participations
has_many :gathering_suggestions
has_many :gathering_votes
end
class GatheringParticipation
belongs_to :user
belongs_to :gathering
# zsh shell functions for working in local git branches and rebasing appropriately
function rebase {
if [[ $1 == "" ]]; then master='master'; else master=$1; fi
branch=`git branch | grep \* | awk '{print $2}'` &&
git co $master && git pull && git rebase $master $branch
}
function push {
if [[ $1 == "" ]]; then master='master'; else master=$1; fi
# Copyright (c) 2008 Nicholas A. Evans
# http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/
#
# With some tweaks (slow spec profiler, growl support)
# By Nick Zadrozny
#
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
@nz
nz / focus.rb
Created March 3, 2009 18:46 — forked from robrasmussen/focus.rb
#!/usr/bin/env ruby
# The script that give you focus!
# Create a text file that contains sites want to give yourself
# access to only during certain times of day.
#
# The file will look like this:
# 12 news.ycombinator.com
# 11-13,19-21 twitter.com
#