Skip to content

Instantly share code, notes, and snippets.

@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 / 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
(function(module, $) {
module.thingy = function () {};
}(window.module = window.module || {}, jQuery));
@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
@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 / some.md
Created January 21, 2014 21:20
so much markdown

Some Title

  1. first
  2. second
  3. third!
int f = 0;
int g = 1;
for (int i = 0; i <= 15; i++)
{
StdOut.println(f);
f = f + g;
g = f - g;
}
All commands can be run with -h (or --help) for more information.
[cha@2518 ar2 (twitter-instagram)]$ rails s
=> Booting WEBrick
=> Rails 4.1.9 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
Exiting
/Users/cha/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- instagram (LoadError)
from /Users/cha/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:247:in `block in require'
@chuckha
chuckha / Obama.txt
Created May 6, 2016 01:25
Thanks, Obama.
[cha@2518 ~]$ python collatz.py
Traceback (most recent call last):
File "collatz.py", line 25, in <module>
num_terations = collatz(i, 0)
File "collatz.py", line 16, in collatz
return collatz(lookup[start], iteration + 1)
File "collatz.py", line 12, in collatz
return collatz(lookup[start], iteration + 1)
File "collatz.py", line 12, in collatz
return collatz(lookup[start], iteration + 1)
lookup = {}
def collatz(start, iteration):
if start == 1:
return iteration + 1
if start in lookup:
return collatz(lookup[start], iteration + 1)
if start % 2 == 0:
lookup[start] = start / 2
return collatz(lookup[start], iteration + 1)
else: