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
package myproject | |
package snippet | |
import net.liftweb._ | |
import common.Logger | |
import http._ | |
import js._ | |
import JsCmds._ | |
import JE._ |
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
package lib | |
import sys.process.{Process, stringToProcess} | |
class Shell { | |
var elems = Vector[String]() | |
var cwd = "/tmp" | |
def >(str: String) = elems :+= str | |
def run() = elems.map( cmd => { |
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
".playerDeckCard" #> cards.map ( card => | |
".card [data-keyname]" #> card.keyname.is & | |
".card [data-cardname]" #> card.name.is & | |
... | |
) |
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
// returns a new array where every object is the result of the passed function applied to corresponding element in the original array | |
Array.prototype.map = function(fn){ | |
var nArr=[]; | |
for(i=0; i<this.length; i++){ | |
nArr[i] = fn(this[i]) | |
}; | |
return nArr | |
} | |
// to use it, define a function taking one argument and processing it: |
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
interface Array<T> { | |
flatMap <U>( fn: (a:any) => Maybe<U>): Array<U>; | |
// currently limited because I cannot write Array<T extends Maybe<Z>> and have flatten return Array<Z> | |
flatten (): Array<any>; | |
} | |
// the runtime | |
Array.prototype.flatMap = | |
function <U>(fn: (a:any) => Maybe<U>):Array<U> { | |
var res:Array<U> = []; |
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 BlackBox { | |
def value = "Some content" | |
} |
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 scalaz._ | |
import Scalaz._ | |
val isThisCool: Boolean @@ CoolStuff = Tag(true) | |
def requiresCoolStuff(in: Boolean @@ CoolStuff) = in | |
// type checks | |
requiresCoolStuff(isThisCool) |
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 Id = Int | |
def insertA():Either[Exception, Id] = {println("running A"); Right(1)} | |
def insertB(a: Id):Either[Exception, Id] = {println("running B with " + a); Left(new Exception("Oops"))} | |
def insertC(b: Id):Either[Exception, Id] = {println("running C with " + b); Right(3)} | |
for { | |
a <- insertA().right | |
b <- insertB(a).right | |
c <- insertC(b).right |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
#!/bin/sh | |
exec scala "$0" "$@" | |
!# | |
/* | |
* Copyright (c) 2011-15 Miles Sabin | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at |
OlderNewer