Skip to content

Instantly share code, notes, and snippets.

View splittingfield's full-sized avatar

Marc Millstone splittingfield

View GitHub Profile
@splittingfield
splittingfield / gist:77229c67ea0fd81b4f8e652e4cb45afb
Last active May 18, 2017 01:44
Frequency Map for 60A on 18.05.2017
5645 -- Marc
5685 -- Luca
5760 -- Jeff
5800 -- Bob and Justin
5860 -- Josh and Bob
@splittingfield
splittingfield / gist:2306562
Created April 4, 2012 23:31
Cute scala...
scala> case class A[S,T](s:Int,b:T)(f:(S,T)=>T,g:(S,T)=>T)
defined class A
scala> case class A[S:Manifest,T:Manifest](s:Int,b:T)(f:(S,T)=>T,g:(S,T)=>T)
<console>:5: error: case classes limited by implementation: maximum of 2 constructor parameter lists.
Because the Manifests are just sort of added as a third parameters list with implicits...
@splittingfield
splittingfield / gist:1987191
Created March 6, 2012 16:22
Itunes settings
Return sane iTunes Library settings
defaults write com.apple.iTunes hide-ping-dropdown 1
defaults write com.apple.iTunes show-store-link-arrows 1
defaults write com.apple.iTunes invertStoreLinks 1
@splittingfield
splittingfield / configure
Created December 19, 2011 23:09
Configure flags for numerical libraries on a mac
./configure --with-blas="-framework vecLib" --with-lapack="-framework vecLib" F77=gfortran CC=/usr/local/bin/gcc CXX=/usr/local/bin/g++ LDFLAGS="-flat_namespace" FFLAGS="-fexceptions -m64 -fbackslash" CFLAGS="-fno-common -m64" CXXFLAGS="-fno-common -fexceptions -m64” -disable-shared
@splittingfield
splittingfield / slowmockito
Created December 15, 2011 14:23
Slow Mockito
describe(“A tree”) {
it("can have a root”){
val n1 = mock[Node]
when(n1.id).thenReturn("1”)
val g = Tree(n1)
g.root.id should be ("1")
}
}
test output with time.
@splittingfield
splittingfield / blahspec.scala
Created December 6, 2011 19:01
Opinions on workaround
class Blah [@specialized (Int) T:Manifest](a:Array[T]) {
def map[@specialized (Int) S>:T, @specialized (Int) W:Manifest](f:S=>W):Blah[W] = {
var i = 0
val newA = new Array[W](a.length)
while (i < a.length) {
newA(i) = f(a(i))
i = i+1
}
new Blah(newA)
}
@splittingfield
splittingfield / specworkaround
Created December 5, 2011 21:34
Workaround for specialization issue for known datatypes
import com.azavea.math.Numeric
import com.azavea.math.EasyImplicits._
trait F1[@specialized T, @specialized W] extends Function1[T,W] {
def apply(a:T):W
}
abstract class F12D[@specialized T:Numeric:Manifest] extends F1[T,Double]{
def apply(a:T):Double
}
abstract class F12I[@specialized T:Numeric:Manifest] extends F1[T,Int] {
@splittingfield
splittingfield / noboxing
Created December 5, 2011 16:55
No boxing here.
import com.azavea.math.Numeric
import com.azavea.math.EasyImplicits._
class Blah {
def blah[@specialized T:Numeric:Manifest, @specialized W:Numeric:Manifest](f:Function1[T,W]):W = {
f(numeric[T].zero)
}
def blah2[T:Numeric:Manifest](f:Function[T,T]):T = {
f(numeric[T].zero)
}
@splittingfield
splittingfield / boxing
Created December 3, 2011 00:07
Boxing and unboxing
import com.azavea.math.Numeric
import com.azavea.math.EasyImplicits._
class Blah[@specialized T:Numeric:Manifest] {
def blah[@specialized W:Numeric:Manifest](f:Function1[T,W]):W = {
f(numeric[T].zero)
}
def blah2(f:Function[T,T]):T = {
f(numeric[T].zero)
}