This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example using the raf module from npm. try changing some values! | |
var requestAnimationFrame = require("raf") | |
var canvas = document.createElement("canvas") | |
canvas.width = 500 | |
canvas.height = 500 | |
document.body.appendChild(canvas) | |
var context = canvas.getContext("2d") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example using the raf module from npm. try changing some values! | |
var requestAnimationFrame = require("raf") | |
var canvas = document.createElement("canvas") | |
canvas.width = 500 | |
canvas.height = 500 | |
document.body.appendChild(canvas) | |
var context = canvas.getContext("2d") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example using the raf module from npm. try changing some values! | |
var requestAnimationFrame = require("raf") | |
var canvas = document.createElement("canvas") | |
canvas.width = 500 | |
canvas.height = 500 | |
document.body.appendChild(canvas) | |
var context = canvas.getContext("2d") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example using the raf module from npm. try changing some values! | |
var requestAnimationFrame = require("raf") | |
var canvas = document.createElement("canvas") | |
canvas.width = 500 | |
canvas.height = 500 | |
document.body.appendChild(canvas) | |
var context = canvas.getContext("2d") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object ShapelessTest extends App { | |
import shapeless._ | |
import record._ | |
import ops.hlist.ToList | |
import ops.record.{ Keys, Values } | |
import syntax.singleton._ | |
val ps = List( | |
("name" ->> "Mel") :: | |
("age" ->> 90L) :: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
- type mismatch; found : com.tagged.vor.toJSON.type required: ?{def apply(x$1: ? >: | |
A): ?} Note that implicit conversions are not applicable because they are ambiguous: | |
both method inst1 in trait PolyInst of type [A](fn: shapeless.Poly)(implicit cse: | |
fn.ProductCase[shapeless.::[A,shapeless.HNil]])A => cse.Result and macro method apply | |
in object Poly of type (f: Any)shapeless.Poly are possible conversion functions from | |
com.tagged.vor.toJSON.type to ?{def apply(x$1: ? >: A): ?} | |
- Unable to convert expression Expr[Nothing](toJSON) to a polymorphic function | |
value | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.json4s._ | |
import org.json4s.native.JsonMethods._ | |
import shapeless._ | |
import poly._ | |
import ops.hlist._ | |
import syntax.singleton._ | |
import record._ | |
object Record { | |
def keyAsString[F, V](f: FieldType[F, V])(implicit wk: shapeless.Witness.Aux[F]) = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val sql = """select grandparent_id, parent_id, child_id | |
from children | |
order by grandparent_id, parent_id, child_id""" | |
def elementsR[R](invoker: scala.slick.jdbc.Invoker[R]): Process[Task, R] = | |
resource(Task.delay(invoker.elements()))( | |
src => Task.delay(src.close)) { src => | |
Task.delay { if (src.hasNext) src.next else throw End } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def yipWhenL[I,O,O2](ord: (I,O) => Ordering)(f: (I,Option[O]) => O2): Wye[I,O,O2] = { | |
val fbL = tee.passL[I] map (f(_,None : Option[O])) | |
def go(io : Option[I], oo : Option[O]): Wye[I,O,O2] = { | |
io match { | |
case None => awaitL[I].flatMap { i => go(Some(i), oo) } | |
case Some(i) => oo match { | |
case None => awaitR[O].flatMap(o => go(io,Some(o))) // TODO receiveROr(fbL)... | |
case Some(o) => ord(i,o) match { | |
case Ordering.LT => emit(f(i,None)) then go(None,oo) | |
case Ordering.EQ => emit(f(i,oo)) then go(None,None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void testSort(UnivInteger len) { | |
// For Random | |
val mult = 7**5; | |
val md = 2**31 - 1; | |
var ran = Random.start(len, mult, md); | |
println("Seed = " + len + ", mult = " + mult + ", md = " + md); | |
type MySorter is Sorting<Vector<UnivInteger>>; | |
var Vector<UnivInteger> vec = []; |
OlderNewer