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 / epoch.js
Last active January 7, 2016 18:22
JavaScript function to get seconds since epoch.
// Return seconds since epoch, rounded. Use Math.floor() instead
// to truncate.
function epoch() {
'use strict';
return Math.round(Date.now() / 1000);
}
#!/bin/bash
function remove_dir () {
rm -rf "$1_"
if [ -d "$1" ]
then
mv "$1" "$1_"
fi
}
@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!"
@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 / 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 / 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 / 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 / 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 / caller_to_symbol.rb
Created December 15, 2014 17:33
Return name of calling method as a Symbol.
#!/usr/bin/env ruby
def foo
caller[0].match(/`\K[^']+/).to_s.to_sym
end
def bar
foo
end
@todd-a-jacobs
todd-a-jacobs / nsw.sh
Last active August 29, 2015 14:10
What time is it "Down Under" in New South Wales?
#!/usr/bin/env bash
TZ='Australia/Sydney' date