Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jnunemaker
jnunemaker / test_helper.rb
Created March 24, 2009 19:33
Rails test_helper with jnunemaker's matchy and a few handy custom matchers
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
gem 'jnunemaker-matchy', '>= 0.4.0'
require 'matchy'
class ActiveSupport::TestCase
self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false
@jnunemaker
jnunemaker / .gitignore
Created April 7, 2009 02:29
Rails template for starting apps
testapp
require 'rubygems'
data = open(ARGV[0]).read
data.gsub!(/^require.*/, '')
data.gsub!(/describe\s/, 'context ')
data.gsub!(/it\s(\"|\')should\s?/, 'should \1')
data.gsub!('before(:each)', 'setup')
data.gsub!('before', 'setup')
data.gsub!('be_nil', 'be(nil)')
data.gsub!('be_true', 'be(true)')
data.gsub!('be_false', 'be(false)')
@jnunemaker
jnunemaker / instructions.txt
Created June 5, 2009 18:06
How to open a clone of the current tab in terminal with a simple command
1) Put terminal_clone_tab.sh somewhere in
your path and make sure it is executable
chmod u+x terminal_clone_tab.sh
2) Then add the following alias (~/.bash_profile or something)
alias nt='terminal_clone_tab.sh'
3) Then you can hit nt (for new tab) anywhere
and a new tab will open up in same directory.
If there is an easier way to do this, let me know nunemaker@gmail.com.
@jnunemaker
jnunemaker / lighter.rb
Created June 17, 2009 15:47 — forked from macournoyer/lighter.rb
Campfire from the command line
# Lighter -- Campfire from the command line
# usage: ruby lighter.rb subdomain "Main Room" macournoyer@gmail
require "rubygems"
require "tinder"
require "readline"
require "highline/import"
class Lighter
def initialize(room)
@room = room

HOWTO: iPhone AT&T Tethering

In 10 steps:

  • Update iTunes to 8.2 via Software Update
  • Update your iPhone to the 3.0 release (out today - June 17th)
  • Download this dmg and mount it: tethering file
  • Enable hidden carrier testing option (in Terminal.app): defaults write com.apple.iTunes carrier-testing -bool TRUE
  • Start up iTunes
@jnunemaker
jnunemaker / gist:142568
Created July 8, 2009 04:00
Recently added to mongomapper readme. Has really improved pull requests when compared to projects without the note.
= Note on Patches/Pull Requests
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don’t break it in a
future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
(if you want to have your own version, that is fine but
bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.
@jnunemaker
jnunemaker / .git-completion.sh
Created July 8, 2009 14:47
bash completion support for git
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
@jnunemaker
jnunemaker / errors.js
Created July 14, 2009 16:40
jQuery and Rails form errors
(function($) {
// errors is an array of errors
// render :json => {:errors => @item.errors.full_messages}
function FormErrors(errors) {
var self = this,
error_count = errors.length;
this.html = function() {
var html = '';
html += '<div class="errorExplanation" id="errorExplanation">';
@jnunemaker
jnunemaker / application.js
Created August 11, 2009 16:00
Pretty output of rails errors when doing ajax requests with jQuery
// only outputs if console available and does each argument on its own line
function log() {
if (window && window.console && window.console.log) {
var i, len;
for (i=0, len=arguments.length; i<len; i++) {
console.log(arguments[i]);
}
}
}