Skip to content

Instantly share code, notes, and snippets.

@chuckha
chuckha / blastoff.swift
Created August 19, 2014 03:42
Straight up breaks the playground
func test() -> String {
func innerTest(n: Int) -> String {
if n == 0 {
return "Blast off"
}
return innerTest(n - 1)
}
return innerTest(10)
}
var worstFunctionEver = function (badArg) {
while (1) {
if (badArg == "hello") {
console.log("worst code ever");
}
}
}
@chuckha
chuckha / some.md
Created January 21, 2014 21:20
so much markdown

Some Title

  1. first
  2. second
  3. third!
@chuckha
chuckha / dec_to_dms.rb
Last active December 24, 2015 10:29
lat/lon to dms
def lat_sign(dec)
dec >= 0 ? 'N' : 'S'
end
def lon_sign(dec)
dec >= 0 ? 'E' : 'W'
end
def lat_to_dms(dec)
"#{dec_to_dms dec} #{lat_sign dec}"
end
@chuckha
chuckha / main.go
Created September 26, 2013 19:47
Code for a blog post
func GenerateAllPics() {
// Set the number of processors Go can use
runtime.GOMAXPROCS(runtime.NumCPU())
// Make all the channels we need
rows := make(chan []string)
throttle := make(chan struct{}, 10)
doneChan := make(chan int)
// Start reading the CSV
go MustReadRowAtATime("data/training.csv", rows)
// Populate the throttle so that the workers can start working
(function(module, $) {
module.thingy = function () {};
}(window.module = window.module || {}, jQuery));
@chuckha
chuckha / node.py
Created August 1, 2013 14:31
An empty node object for a linked list with full test coverage.
class Node(object):
"""A node to be used for a linked list"""
def __init__(self, data):
"""Create a new Node instance
>>> head = Node(4)
>>> print(head.next)
None
>>> head.data
@chuckha
chuckha / install_package.sh
Created December 4, 2012 17:07
install a python package
#!/bin/bash
rm -rf dist
rm -rf build
rm -rf *.egg-info
python setup.py install
@chuckha
chuckha / fizzbuzz.erl
Created September 21, 2012 14:07
Erlang fizzbuzz
-module(fizzbuzz).
-export([fizzbuzz/1]).
-define(MOD_THREE, "fizz").
-define(MOD_FIVE, "buzz").
% Helper function to map fizzbuzz across a sequence of numbers
fizzbuzz(To) ->
lists:map(fun nt/1, lists:seq(1, To)).
@chuckha
chuckha / base.rb
Created August 15, 2012 14:19
base role for safarilabs
name "base"
description "A base role for all safarilab nodes"
run_list(
# Add recipes or roles here
"recipe[build_essential]"
)