Skip to content

Instantly share code, notes, and snippets.

Nathan Youngman nathany

Block or report user

Report or block nathany

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nathany /
Last active May 3, 2019
Magical Unicorn Configuration for Heroku
# add something like this to
# see
if Integer(ENV['UNICORN_KILLER'] || 0) != 0
require 'unicorn/worker_killer'
# Max memory size (RSS) per worker
use Unicorn::WorkerKiller::Oom, (350*(1024**2)), (400*(1024**2)), 30, true
nathany /
Created Jun 16, 2011
Decode Mac Open Firmware Password
# I forgot the firmware password on my MacBook Air and didn't want to take it in:
# info
# run the following command to retrieve your obfuscated firmware password:
# sudo nvram -p | grep security-password
security_password = "%..."
# take the complement of every second bit:
nathany / gist:190489
Created Sep 21, 2009
index-of-any, based on Stuart Halloway's Programming Clojure book, but with attempts in Python and Ruby (of course regex would be another, string-only, option)
View gist:190489
// Returns the index of the first character contained in searchChars
// From Apache Commons Lang,
public static int indexOfAny(String str, char[] searchChars) {
if (isEmpty(str) || ArrayUtils.isEmpty(searchChars)) {
return -1;
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
for (int j = 0; j < searchChars.length; j++) {
if (searchChars[j] == ch) {

Keybase proof

I hereby claim:

  • I am nathany on github.
  • I am nathany ( on keybase.
  • I have a public key ASDQMnXaH02CR8BQhuy4A0xJpt8RfQDOIkGAJFX9QuNlIAo

To claim this, I am signing this object:

nathany / luhn.ex
Last active Dec 28, 2016
Luhn algorithm to checksum credit cards.
View luhn.ex
defmodule Luhn do
@moduledoc """
Luhn algorithm to checksum credit cards.
@doc """
Check if a credit card number is valid based on luhn.
def valid?(cc) when is_integer(cc) do
View Ruby, The Good Parts
* mixins (include and extend) for simple modularization (vs. multiple inheritance or traits in other languages)
* innovations in the web space (haml, rack middleware, etc.)
* standardized around MIT and GIT
* no public properties (attr_accessor, etc.)
* open classes
* tooling (gem, rake)
* animal references (ducks, monkeys, bacon)
* metaprogramming (unicorns)
* TDD/BDD emphasis and tools
nathany / checksum.go
Created Aug 11, 2016
Using MultiWriter to do two things at once
View checksum.go
// copyAndChecksum calculates a checksum while writing to another output
func copyAndChecksum(w io.Writer, r io.Reader) (string, error) {
h := md5.New()
mw := io.MultiWriter(w, h)
if _, err := io.Copy(mw, r); err != nil {
return "", err
return hex.EncodeToString(h.Sum(nil)), nil
nathany / fast_regex_list_split.cfm
Created Dec 15, 2010
Split a list into chunks, returns an array of lists
View fast_regex_list_split.cfm
function ListSplit(list, chunk_size, delim)
var result = ArrayNew(1); var re = ""; var start = 1;
while(1) {
re = REFind("((?:[^#delim#]+#delim#){1,#chunk_size#})", list & delim, start, "true");
if( re.len[1] eq 0 ) break;
ArrayAppend(result, Mid(list,re.pos[1],re.len[1]-len(delim)));
start = re.pos[1] + re.len[1];
if(start gte len(list)) break;
View git_test.go
package main
import (
func TestGetSHA(t *testing.T) {
sha, err := getSHA1()
if err != nil {
nathany / Default (OSX).sublime-keymap
Last active Feb 12, 2016
My keymap for GoSublime
View Default (OSX).sublime-keymap
/* GoSublime */
"keys": ["super+s"],
"command": "gs_fmt_save",
"context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }]
"keys": ["super+shift+s"],
"command": "gs_fmt_prompt_save_as",
You can’t perform that action at this time.