Skip to content

Instantly share code, notes, and snippets.

View todd-a-jacobs's full-sized avatar

Todd A. Jacobs todd-a-jacobs

View GitHub Profile
@todd-a-jacobs
todd-a-jacobs / install_ember-cli.sh
Created December 21, 2014 17:47
Install ember-cli and dependencies without -g flag.
#!/usr/bin/env bash
npm install ember-cli
npm install bower
npm install phantomjs
rcfile="$HOME/.bashrc"
if ! grep -Fq node_modules "$rcfile"; then
echo 'export PATH="$PATH:$HOME/node_modules/.bin"' | tee -a "$rcfile"
fi
@todd-a-jacobs
todd-a-jacobs / gist:ef3008345256fe82d11a
Created January 27, 2015 03:43
Install Rubinius on OS X Yosemite
CC=clang ruby-install rbx 2.5.1 --sha1 5096b28f6b91968c7554946d55eefc218603c9a8 -- --llvm-config /opt/local/bin/llvm-config-mp-3.3
@todd-a-jacobs
todd-a-jacobs / llvm-config-path.sh
Created January 27, 2015 05:23
Path to latest version of llvm-config.
#!/bin/sh
# Use standard location of port command to detect MacPorts.
if [ -x /opt/local/bin/port ]; then
# Query port for path to latest version of llvm-config. Selects
# latest version with tail if more than one version is installed
# with tail.
port contents $(port installed | egrep -o 'llvm-[^ ]+' | tail -1) |
# Uses head to avoid binaries in libexec rather than bin.
fgrep llvm-config | head -1
@todd-a-jacobs
todd-a-jacobs / yubikey_ssh_public_key.sh
Created March 7, 2015 02:03
Extract an OpenSSH public key from an OpenPGP authentication key stored on a Yubikey NEO.
echo 'SSH Public Key for Yubikey NEO'
echo '------------------------------'
gpgkey2ssh $(
gpg --card-status 2>&1 |
pcregrep -o '^Authentication.*\K.{9}$' |
tr -d ' '
)
@todd-a-jacobs
todd-a-jacobs / cow.rb
Created March 27, 2015 16:03
Helping out William with question posted on Facebook at https://www.facebook.com/groups/2221017023/permalink/10152617269302024/
class Animal
# Use an instance method instead of a getter/setter.
def make_noise sound
p sound
end
end
cow = Animal.new
cow.make_noise "Moo!"
#=> "Moo!"
#!/bin/bash
function remove_dir () {
rm -rf "$1_"
if [ -d "$1" ]
then
mv "$1" "$1_"
fi
}
@todd-a-jacobs
todd-a-jacobs / keybase.md
Last active September 24, 2015 23:01
Keybase Identity for CodeGnome

Keybase proof

I hereby claim:

  • I am codegnome on github.
  • I am codegnome (https://keybase.io/codegnome) on keybase.
  • I have a public key whose fingerprint is 49AC A1C8 9F24 6338 62F9 6F91 2E85 63CE 12A7 5526

To claim this, I am signing this object:

@todd-a-jacobs
todd-a-jacobs / durstenfeld_shuffle.coffee
Created May 6, 2011 16:38 — forked from dpritchett/durstenfeld_shuffle.coffee
durstenfeld array shuffle in coffeescript
# See http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
# written as one-liners because my REPL didn't like multiline functions this morning
# tested on CoffeeScript v1.0.1
input = [0 .. 7]
swap = (input, x, y) -> [input[x], input[y]] = [input[y], input[x]]
rand = (x) -> Math.floor(Math.random() * x)
durst = (input) -> swap(input, i, rand(i)) for i in [input.length - 1 .. 1]
"""
@todd-a-jacobs
todd-a-jacobs / gist:2203978
Created March 26, 2012 08:52
Install RVM with Puppet
exec { '/bin/bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)':
provider => shell,
creates => '/home/vagrant/.rvm',
cwd => '/tmp',
user => 'vagrant',
}
@todd-a-jacobs
todd-a-jacobs / flock_example.rb
Created March 8, 2013 13:43
Ruby requires a Bitwise OR to make non-blocking File#flock work.
f1 = File.open('foo', File::RDWR|File::CREAT, 0644)
f1.flock(File::LOCK_EX)
# => 0
f2 = File.open('foo', File::RDWR|File::CREAT, 0644)
f2.flock(File::LOCK_NB|File::LOCK_EX)
# => false
f1.close; f2.close
# => nil