Skip to content

Instantly share code, notes, and snippets.

View overthink's full-sized avatar

Mark Feeney overthink

  • Waterloo, Ontario, Canada
View GitHub Profile
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
sudo apt-get update
sudo apt-get upgrade
@overthink
overthink / gist:3739858
Created September 17, 2012 21:16
Use Tampermonkey in Chrome to install this.
// ==UserScript==
// @name Hide who to follow on twitter
// @namespace http://blog.markfeeney.com
// @version 0.1
// @description Hide the who to follow thing on twitter.
// @match https://twitter.com/*
// @copyright 2012+, Mark Feeney
// ==/UserScript==
// 2 seconds ought to be enough for anyone
@overthink
overthink / content.md
Created October 5, 2012 12:08 — forked from ayosec/content.md
Why Lisp macros are cool, a Perl perspective
@overthink
overthink / gist:6241841
Created August 15, 2013 15:36
O(n) size by default... great.
def time[R](block: => R): R = {
val t0 = System.currentTimeMillis
val result = block // call-by-name
val t1 = System.currentTimeMillis
println("Elapsed time: " + (t1 - t0) + "ms")
result
}
val list1 = 1 to 10000 toList
val ary1 = 1 to 10000 toArray
@overthink
overthink / gist:7669b95275ae2f11e496
Last active August 29, 2015 14:06
variable-arity arg weirdness
(def person1 {:fname "John" :mname "Q" :lname "Doe"})
(def person2 {:fname "Jane" :mname "P" :lname "Doe"})
(defn fname-compare [p1 p2]
(do
(println "Comparing fname")
(compare (:fname p1) (:fname p2))))
(defn lname-compare [p1 p2]
(do
@overthink
overthink / gist:b55d96f3d1df385163cd
Created February 21, 2015 04:08
Simple cache made hard
(ns exp.cache
"I keep screwing myself up on this and need to write it out.
Caching impl with these constraints:
- caching is layered onto oblivious source fns
- data to cache is some unparsed source data that is transformed in a non-trivial way
- thr raw source data is not interesting to most users and shouln't mess up the api
- caching the final transformed thing is not desireable since we often change the transformation fn
- not all source data should be cached
~/tmp/units-2.11$ make clean
rm -f *.o units units.fn units.ky units.pg units.tp \
units.vr units.log units.dvi units.1 units.cp distname .chk \
units.toc units.aux units.cps units.op units_cur_inst units_cur
~/tmp/units-2.11$ time (./configure && make)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
@overthink
overthink / gist:e56f35159f6bc5751d34
Last active August 29, 2015 14:20
Scala lost guarded exhaustiveness checks at 2.10.x... very annoying
mark@mark-pc2:~/tmp/patterns$ cat Test.scala
sealed trait Foo
case object A extends Foo
case object B extends Foo
object Test {
def f(foo: Foo) {
foo match {
case A if true =>
println("A")
@overthink
overthink / gist:c7efe144abbd23524004
Created April 30, 2015 19:56
Bytecode for Using.apply()
public <A extends java/lang/Object, B extends java/lang/Object> B apply(A, scala.Function1<A, B>);
flags: ACC_PUBLIC
Code:
stack=3, locals=7, args_size=3
0: aload_2
1: aload_1
2: invokeinterface #77, 2 // InterfaceMethod scala/Function1.apply:(Ljava/lang/Object;)Ljava/lang/Object;
7: astore_3
8: aload_1
9: ifnull 37
(ns foo.core
"Looking at ways to mock out records when testing and also using schema."
(:require
[schema.core :as s]))
;; approach 1 (problematic for mocks) --------------------------------------------------
(s/defrecord Thing
[name :- s/Str
age :- s/Int])