Skip to content

Instantly share code, notes, and snippets.

View parallelepiped's full-sized avatar

Owen Martin parallelepiped

View GitHub Profile
package quickcheck
import common._
import org.scalacheck._
import Arbitrary._
import Gen._
import Prop._
abstract class QuickCheckHeap extends Properties("Heap") with IntHeap {
@parallelepiped
parallelepiped / State.scala
Last active October 11, 2015 20:05
Some of the State exercises
trait RNG {
def nextInt: (Int, RNG) // Should generate a random `Int`. We'll later define other functions in terms of `nextInt`.
}
object RNG {
type Rand[+A] = RNG => (A, RNG)
// ?? What does _ mean in this syntax? Access to the RNG trait?
val int: Rand[Int] = _.nextInt
$("video").playbackRate = 2
@parallelepiped
parallelepiped / ex217_18.scm
Created March 17, 2014 17:08
SICP questions 2.17 and 2.18
;2.17
;(last-pair (list 23 72 89 124 34)) ; should be (34)
(define (last-pair x)
(if (atom? (cdr x))
x
(last-pair (cdr x))))
(display (last-pair (list 23 72 89 124 34)))
(newline)
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@parallelepiped
parallelepiped / ex131.scm
Last active August 29, 2015 13:56
SICP ex. 1.31
;helpers
(define (identity x) x)
(define (plus1 x) (+ 1 x))
; recursive
(define (product term a next b)
(if (> a b)
1
(* (term a)
(product term (next a) next b))))
@parallelepiped
parallelepiped / meetupunsubscribe.js
Last active December 25, 2015 21:58
How to unsubscribe from all meetup emails
_.each($(".editInPlace"), function(g){g.click()})
// wait a second for ajax to finish
_.each($("input[type=checkbox]:checked"), function(c) {c.click()})
_.each($("input[type=radio][value=1]"), function(e) {e.click()})
_.each($("input[type=radio][name=mailing_list_status][value=0]"), function(e) {e.click()})
_.each($("input[type=radio][name=evRemind][value=1]"), function(e) {e.click()})
_.each($("form[method=POST]"), function(f) {$.post(f.action, $(f).serialize(), function(e) {console.log("Unsubscribed from " + f.action)})})
🕜 o@ombp ~/eng/labs/miri (master)* $ time rline rental_entry.dump
caf478db3e705152013e7055807526ee rentjungle.com 2013-05-03 Cooper Square NEW YORK NY 10003 40.7284617 -73.9907367 dfaade06187ed9790ce60a8f07854932 **NO FEE**STUNNING NOHO TWO BEDROOM**LUXURY CORNER PENTHOUSE**NO FEE** dfaade06187ed9790ce60a8f07854932-2.0-null 2.0-null 2 2 12000 12000 f fapartment
real 0m0.041s
user 0m0.025s
sys 0m0.014s
🕜 o@ombp ~/eng/labs/miri (master)* $ time wc -l rental_entry.dump
4924266 rental_entry.dump
real 0m1.478s