Skip to content

Instantly share code, notes, and snippets.

View dtuite's full-sized avatar
🚀
Shipping

David Tuite dtuite

🚀
Shipping
View GitHub Profile
@dtuite
dtuite / json_matcher.rb
Created September 14, 2011 14:18
RSpec2 JSON matcher
# RSpec2 JSON Matcher for functional/controller tests
# Webrat usage example:
#
# it "should be the JSON representation" do
# get :show, id: object.id, format: :json
# response.body.should be_json_eql object.to_json
# end
require 'rspec/expectations'
@dtuite
dtuite / gist:1592618
Created January 11, 2012 02:29
Unix command to list all running processes and daemons
ps -aef | awk "{if ( \$3 == 1 ) { print \$_ }}"
@dtuite
dtuite / gist:1724205
Created February 2, 2012 15:59
Apache Configuration Testing
# get apache to tell you where the errors are in your config
sudo apachectl configtest
@dtuite
dtuite / migrations.md
Created May 28, 2012 09:42
Fancy Rails Migrations

Add Indices and Limits

rails g model User name:index email:uniq token:string{6} age:integer
  • name:index creates an indexed column called name.
  • email:uniq creates column called email with a unique index.
  • Specifying token:string{6} constrains the length of token to 6 chars.
class CreateUsers < ActiveRecord::Migration
@dtuite
dtuite / 0.md
Last active December 11, 2015 11:48
Homebrew formula for installing Vim

Vim Homebrew Formula

  • Includes Python and Ruby support.
  • Uses system Ruby rather than current shell Ruby

Installation Instructions

  1. Find the Vim version number you wish to install. You can either use the Vim patches readme or brew update && brew outdated.
@dtuite
dtuite / checkers.js
Created January 29, 2013 10:02
Someone asked for the JS code from http://domainmasher.com so here it is.
// Service for checking the availability of a given word
Splitter.module('Checkers', function(Checkers, Splitter) {
var LocalChecker = {
comKeyFor: function(compound) {
return 'avail/.com/' + compound;
},
check: function(compound) {
@dtuite
dtuite / lowercase.sh
Created January 30, 2013 20:37
Change a bunch of file names to lowercase.
#!/bin/sh
# Change a list of file names to lowercase
#
# Example:
#
# lowercase UPPercase.PNG
# => uppercase.png
for i in *
@dtuite
dtuite / gittips.md
Last active December 12, 2015 09:49
Git Tips from the Pros Taken from: http://goo.gl/jzuub

Checkout your last branch

git checkout -

Deleting Merged Branches

Show which local branches have been merged into the current branch:

git branch --merged
@dtuite
dtuite / instruction.md
Last active December 13, 2015 16:48
Exporting the latest Heroku backup to your local machine
  1. Download the latest backup to a local file called latest.dump
curl -o latest.dump `heroku pgbackups:url -r production`
  1. Load the dump file into the local database. [username] and [database_name] can be found in the database.yml file.
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U [username] -d [database_name] latest.dump
@dtuite
dtuite / grep_vim.sh
Last active March 31, 2020 15:52
Pipe grep or ack into vim
vim $(grep -rl something ./app)
# The -l (for "Lima") flag ensures that grep returns only the matching file names.
# Page through results in Vim with `:n`.
vim $(ack -l something ./app | xargs)
# The -l (for "Lima") flag does the same thing as for grep.
# We need `xargs` to flatten the list of filenames.