- Install
libffi
with my modified homebrew formula: https://github.com/jonsterling/homebrew/blob/master/Library/Formula/libffi.rb export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig
brew install pkg-config
cabal install libffi
cabal install idris
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.platanios.tensorflow.api._ | |
object MemLeak { | |
val rt = Runtime.getRuntime | |
def mb(bytes: Long): String = f"${bytes.toFloat / 1024 / 1024}%.1fMB" | |
def printMemory(): Unit = { | |
rt.gc() |
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 worksheets | |
//http://blog.tmorris.net/continuation-monad-in-scala/ | |
object continuations { | |
println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet | |
import Continuation._ | |
// http://hackage.haskell.org/packages/archive/mtl/2.0.1.0/doc/html/Control-Monad-Cont.html |
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
diff -r --unified play-2.0-orig/framework/build play-2.0-cygwin/framework/build | |
--- play-2.0-orig/framework/build 2012-03-12 20:25:28.000000000 -0700 | |
+++ play-2.0-cygwin/framework/build 2012-06-15 17:56:57.436000000 -0700 | |
@@ -8,4 +8,4 @@ | |
DEBUG_PARAM="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${JPDA_PORT}" | |
fi | |
-java ${DEBUG_PARAM} -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M -Dfile.encoding=UTF8 -Dplay.version="${PLAY_VERSION}" -Dsbt.ivy.home=`dirname $0`/../repository -Dplay.home=`dirname $0` -Dsbt.boot.properties=`dirname $0`/sbt/sbt.boot.properties -jar `dirname $0`/sbt/sbt-launch.jar "$@" | |
\ No newline at end of file | |
+java ${DEBUG_PARAM} -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M -Dfile.encoding=UTF8 -Dplay.version="${PLAY_VERSION}" -Dsbt.ivy.home=`dirname $0`/../repository -Dplay.home=`dirname $0` -Dsbt.boot.properties=$BOOTPROP`dirname $0`/sbt/sbt.boot.properties -jar `dirname $0`/sbt/sbt-launch.jar "$@" |
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
/** | |
* Determine terminal width (for instance with stty -a) then pass that width as | |
* the first argument. If the cursor does not move to the next line after | |
* printing the 'a' characters then the terminal does not automatically wrap | |
* when the character is printed in the last column. | |
* For instance in Ubuntu, the cursor will not be visible. | |
*/ | |
public class WrapInLastColumn { | |
public static void main(String[] args) { | |
int width = 80; |
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
#! /usr/bin/env sh | |
PLAY_VERSION="2.0" | |
if [ -z "${JPDA_PORT}" ]; then | |
DEBUG_PARAM="" | |
else | |
DEBUG_PARAM="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${JPDA_PORT}" | |
fi |
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.apache.lucene.queryParser.QueryParser | |
import org.apache.lucene.search._ | |
import org.apache.lucene.analysis._ | |
import org.apache.lucene.analysis.en.EnglishAnalyzer | |
import org.apache.lucene.analysis.tokenattributes._ | |
import org.apache.lucene.util.Version.LUCENE_35 | |
case class TextQuery(analyzer: Analyzer) { | |
val parser = new QueryParser(LUCENE_35 , "dummyfield", analyzer) | |
def fromString(searchTerms: String) = { |
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
// http://stackoverflow.com/questions/9780196/scala-creating-a-basic-dynamic-function-parser | |
import scala.util.parsing.combinator._ | |
object Expr { type VARS = Map[String, Any] } | |
import Expr._ | |
sealed trait Expr { def eval(v: VARS) : Any } | |
case class If(cond: Cond, ifTrue: Expr, ifFalse: Expr) extends Expr { | |
def eval(v: VARS) = |
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 C extends App { | |
def time[F](f: => F) = { | |
val t0 = System.nanoTime | |
val ans = f | |
printf("Elapsed: %.3f\n",1e-9*(System.nanoTime-t0)) | |
ans | |
} | |
def lots[F](n: Int, f: => F): F = if (n <= 1) f else { f; lots(n-1,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
import util.Random | |
// setup: | |
val size = 1e6.toInt | |
val sorted = (1 to size).toIndexedSeq | |
val missing = Random.nextInt(size) + 1 | |
val duplicated = Random.nextInt(size) + 1 | |
val input = Random.shuffle(sorted.filter(_ != missing) :+ duplicated) | |
// find x and y: |
NewerOlder