Skip to content

Instantly share code, notes, and snippets.

View sleepynate's full-sized avatar

Nathan Dotz sleepynate

View GitHub Profile
@sleepynate
sleepynate / gist:3172614
Created July 24, 2012 20:56
problem23.hs
{-
- Problem 23
- Extract a given number of randomly selected elements from a list.
- Example:
- Prelude System.Random>rnd_select "abcdefgh" 3 >>= show
- "eda"
-}
pure_rnd_select :: [a] -> Int -> [a]
pure_rnd_select x y = unsafePerformIO $ rnd_select x y
@sleepynate
sleepynate / BYB OSCON 2012 Presentation.org
Created July 16, 2012 19:27
BYB OSCON 2012 Presentation

Backyard Brains

Neuroscience For Everyone!

Timothy Marzullo & Gregory Gage (Founders)

The Challenge

Can you listen to neurons for under $100?

The Spikerbox

World’s first consumer-grade neural amplifier

Schematics, parts list, and lessons are CC-BY-NC

99$

DIY Kit for 49$

@sleepynate
sleepynate / gist:2639407
Created May 8, 2012 21:21
spinning record view
public class Deck extends View {
// private static final String TAG = "Deck";
private Bitmap mRecordImage;
private RotateAnimation anim;
public Deck(Context context, AttributeSet attrs) {
super(context, attrs);
mRecordImage = BitmapFactory.decodeResource(getResources(),
@sleepynate
sleepynate / gist:2154978
Created March 22, 2012 01:15
backbone derp?
RedrawCheckbox = Backbone.View.extend({
el: '#redrawCheckbox',
events: {
'click' : 'checkState'
},
checkState: function() {
this.trigger('redrawOnMove', this.$el.is(':checked'));
}
});
@sleepynate
sleepynate / gist:2048430
Created March 16, 2012 03:46
Multiprocessing Example.
import time, random
from multiprocessing import Process, Pipe, current_process
from multiprocessing.connection import wait
def foo(w):
for i in range(10):
w.send((i, current_process().name))
w.close()
if __name__ == '__main__':
@sleepynate
sleepynate / gist:1715403
Created February 1, 2012 06:03
backbone events wat
it("derps when using a space in an event name", function() {
var callback = jasmine.createSpy('-Custom Event Callback-');
obj.bind('all', callback);
obj.trigger("foo bar");
expect(callback.callCount).toBe(1);
expect(callback.mostRecentCall.args[0]).toBe('foo bar');
});
(ns tootr.core
(:use
[compojure.core :only (defroutes GET POST)]
[hiccup.page-helpers :only (html5)]
[hiccup.form-helpers :only (form-to label text-area submit-button)]
)
(:require [ring.adapter.jetty :as ring]
[compojure.handler :as handler]
[clojure.contrib.sql :as sql]
)
#!/usr/bin/env python
#
# Parses the U.S. Securities and Exchance Commision website for info on
# Form 4/A filings.
from urllib import urlopen
import re
class SECParser:
@sleepynate
sleepynate / drums.py
Last active September 12, 2021 04:29
Use a video game controller as a drum set (perhaps a Rock Band drum kit?!) video: http://www.youtube.com/watch?v=PV9hOaZsXgs
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <[email protected]> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return - Nathan Dotz
# ----------------------------------------------------------------------------
#
# This script will use pygame to turn a rockband drum kit plugged in your USB
# port into a sampler.
@sleepynate
sleepynate / gist:1084970
Created July 15, 2011 16:02
Make sure HUnit exists and is linked
{--
- Save this file as Main.hs and run with % runghc Main.hs
-}
module Main where
import Test.HUnit
derp = test [ "a silly test" ~: 'a' ~=? 'a' ]
tests = TestList [ derp ]