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 / ascii_finder.sh
Created April 11, 2013 15:35
Find ASCII chars in a directory. Useful for when you're getting encoding errors and you're not sure exactly where they're coming from.
cat lib/tasks/* | perl -n -e 'print if /[^\x00-\x7F]/'
@dtuite
dtuite / taps_linode.md
Created March 24, 2013 19:58
Pulling data from Linode with Taps

Start server on Linode

taps server postgres://[DB_USER]:[DB_PASSWORD]@localhost/[DB_NAME] [USER_NAME] [USER_PASSWORD]

where:

  • DB_USER is the name of the user for the database we want to pull from.
  • DB_PASSWORD is the password of that user.
@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.
@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 / 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 / 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 / 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 / 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 / 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 / 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