Skip to content

Instantly share code, notes, and snippets.

View sleepynate's full-sized avatar

Nathan Dotz sleepynate

View GitHub Profile
; Project Euler Problem 1
;
; If we list all the natural numbers below 10 that are multiples of 3 or 5
; we get 3, 5, 6 and 9. The sum of these multiples is 23.
;
; Find the sum of all the multiples of 3 or 5 below 1000.
;
; solution by nathan dotz
; nathan (period) dotz (at sign) gmail (period) com
; Project Euler Problem 1
;
; If we list all the natural numbers below 10 that are multiples of 3 or 5
; we get 3, 5, 6 and 9. The sum of these multiples is 23.
;
; Find the sum of all the multiples of 3 or 5 below 1000.
;
; solution by nathan dotz
; nathan (period) dotz (at sign) gmail (period) com
; Project Euler Problem 2
; Solution by nathan dotz - nathan (period) dotz (at sign) gmail (period) com
;
; Each new term in the Fibonacci sequence is generated by adding
; the previous two terms. By starting with 1 and 2, the first
; 10 terms will be:
; 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
;
; Find the sum of all the even-valued terms in the sequence
; which do not exceed four million.
#!/bin/zsh
#
# Set cpu scaling policy the convenient way.
#
# nathan (period) dotz (at) gmail (period) com
#
max_cpu() {
echo performance | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo performance | sudo tee /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
@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 ]
@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.
#!/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:
(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]
)
@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');
});
@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__':