Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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 / authentication.rb
Created July 15, 2009 03:33
a starting point for authentication with mongomapper and rails
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
@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]);
}
}
}
/*!
* jQuery JavaScript Library v1.3.3pre
* http://jquery.com/
*
* Copyright (c) 2009 John Resig
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 2009-07-16 03:32:39 -0400 (Thu, 16 Jul 2009)
* Revision: 6447