Skip to content

Instantly share code, notes, and snippets.

View jmervine's full-sized avatar

Joshua Mervine jmervine

View GitHub Profile
@jmervine
jmervine / gist:6232984
Last active December 21, 2015 02:09
find++
# "Install" (I use that term loosely)
#
# - Paste the function below in your .bashrc / .profile / .zshrc / etc.
#
# Usage: find /usr/local -type [m|g] -name [KEYWORD]
#
# -type m : google maps search
# -type g : google search
#
# all other types pass through to find
@jmervine
jmervine / test_helper.sh
Last active December 19, 2015 03:08
Simple Bash Test Framework
################################################################################
# Simple CLI Testing Psudo-Framework
# > http://mervine.net/simple-cli-testing-framework
#
# Assertions:
# - assert "CMD" "FAIL MESSAGE"
# - refute "CMD" "FAIL MESSAGE"
# - assert_equal "FIRST" "SECOND" "FAIL MESSAGE"
# - refute_equal "FIRST" "SECOND" "FAIL MESSAGE"
# - assert_numeq "FIRST" "SECOND" "FAIL MESSAGE"
#!/usr/bin/env bash
set -x
cd /tmp
rm -rf node
set -ue
git clone git://github.com/joyent/node.git
cd node
@mbeale
mbeale / gist:4247971
Created December 10, 2012 02:01
Dynamic JSON sample golang #4
type JSONContainer struct {
data []interface{}
}
func (j *JSONContainer) All() (objects []JSONObject) {
for _, v := range j.data {
objects = append(objects, JSONObject{data: v})
}
return
}
" for use before a colorscheme definition
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
" for use when not using a colorscheme
" highlight ExtraWhitespace ctermbg=red guibg=red
" show unwanted whitespace
match ExtraWhitespace /\s\+\%#\@<!$/
" strip unwanted trailing whitespace on save
@mariusbutuc
mariusbutuc / branch-rename-remote.git
Created September 21, 2012 23:12
Rename remote Git branch
git push origin previous_name:new_name
git branch new_name origin/new_name
# http://stackoverflow.com/a/3790682/341929
anonymous
anonymous / file1.txt
Created September 21, 2012 20:55
gistcli - Paste
#! /usr/bin/python
#########################################################################################
# gistcli - version 1.1 #
# written by : pranavk #
#########################################################################################
import urllib2
import sys
@domenic
domenic / portable-node.md
Created May 25, 2012 21:03
Tips for Writing Portable Node.js Code

Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.

Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.

Paths and URLs

On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@thbar
thbar / README.MD
Created April 18, 2012 09:43
Ruby JSON pipe pretty-printer

A quick ruby command line to pretty-print piped json.

Usage

Put this somewhere in your path, with chmod +x, then:

curl http://myapp.com/stuff.json | json