Skip to content

Instantly share code, notes, and snippets.

View jmervine's full-sized avatar

Joshua Mervine jmervine

View GitHub Profile
@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
}
#!/usr/bin/env bash
set -x
cd /tmp
rm -rf node
set -ue
git clone git://github.com/joyent/node.git
cd node
@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"
@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
@igrigorik
igrigorik / github.bash
Last active September 12, 2025 09:24
Open GitHub URL for current directory/repo...
alias gh="open \`git remote -v | grep [email protected] | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\`"
@wookimiii
wookimiii / grco.bash
Last active September 15, 2021 22:06
Check out a branch using grep
#!/bin/bash
BRANCHES=$(git branch -ra | grep $1)
NUM=$(echo "$BRANCHES" | wc -l)
# check for empty
if [ "X$BRANCHES" = "X" ]
then
echo "No branch matches $1"
fi
@jmervine
jmervine / goinst.sh
Last active July 31, 2016 02:36
Installing GoLang - Ubuntu 12.04.3 LTS \n \l
#!/usr/bin/env bash
#
# Example usage:
#
# $ VERSION=1.3 sudo ./goinst.sh
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
/*
Author: Joshua P. Mervine <[email protected]> [github.com/jmervine]
See: http://jsfiddle.net/jmervine/dqA9r/5/
Use:
<script src="http://cdn.mervine.net/FormattedDate.js" />
<script src="http://cdn.mervine.net/FormattedDate.min.js" />
@jmervine
jmervine / 1results.md
Last active August 29, 2015 14:00
Pythagorean Triplet - run time of go vs. java vs. node vs. ruby vs. python vs. perl vs. php vs. c++

Pythagorean Triplet

Note: The method used below is very slow, with 1bb iterations when trying to find 1000. For a faster method see: https://gist.github.com/jmervine/b5d985398b3ca7ba16aa (~125k iterations)


A Pythagorean triplet is a set of three natural numbers, a b c, for which,

a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52.

###
# Usage:
#
# Download this file and start by running 'make'. Then run
# each target listed, 'make lesson_one', 'make lesson_two',
# etc.
#
introduction:
# Introduction: