Skip to content

Instantly share code, notes, and snippets.

@jonas
jonas / DateInterval.scala
Last active June 8, 2016 14:11
WIP porting Luigi's DateInterval to Scala
import org.joda.time.DateTime
import org.joda.time.DateTimeFieldType
import org.joda.time.format.{ DateTimeFormat, DateTimeFormatter }
import scala.util.Try
object utcDateTime {
val UTC = org.joda.time.DateTimeZone.UTC
def apply(year: Int, month: Int = 1, day: Int = 1, hour: Int = 0): DateTime =
@jonas
jonas / Typesafe-config-settings.scala
Last active October 13, 2015 10:56
Read Typesafe config settings using approach from http://rapture.io/ 's CLI module
scala> val config = com.typesafe.config.ConfigFactory.parseString("""
| a.b.c = 42
| d.e.f = hello world
| g.h.i = 2m
| """)
config: com.typesafe.config.Config = Config(SimpleConfigObject({"a":{"b":{"c":42}},"d":{"e":{"f":"hello world"}},"g":{"h":{"i":"2m"}}}))
scala> val Alpha = Setting[Int]("a.b.c")
Alpha: commands.common.SimpleSetting[Int] = a.b.c

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@jonas
jonas / BufferTest.scala
Last active August 29, 2015 13:56
Test and output for debugging scala-js/scala-js#268
//...
it("should support Buffer !! - #268") {
val a = scala.collection.mutable.Buffer.empty[Int]
for (i <- 0 to 10) {
val p : Int = a.length / 2
expect(s"${a.length} / 2 -> $p, $i").toEqual("...")
a.insert(p, i)
expect(a.mkString(", ")).toEqual("...")
}
@jonas
jonas / scala-js-game-2.patch
Created December 1, 2013 02:01
Scala.js Game 2 patch
diff --git a/src/main/resources/00boot.js b/src/main/resources/00boot.js
index 9f2a0bf..d8961f5 100644
--- a/src/main/resources/00boot.js
+++ b/src/main/resources/00boot.js
@@ -1,3 +1,3 @@
-function cp(){};
-function ScalaJSBundle(){};
-ScalaJS.modules.example_ScalaJSExample().main();
+function xcp(){};
+function xScalaJSBundle(){};
@jonas
jonas / build.sbt
Created November 30, 2013 23:27
Scalac test case: .../src/main/scala/not_found.scala:19: not found: value x$1
name := "Scala Test Case: not found"
@jonas
jonas / progresstinate.sh
Created October 24, 2012 15:31
Show progress spinner based on chatty commands
# Usage:
# progresstinate "Building $SERVER_WAR" \
# mvn clean install
progresstinate() {
msg="$1"; shift; args="$@"; symbol="-"
printf "$msg [$symbol]"
"$@" | while read line; do
symbol="$(echo "$symbol" | tr -- '-/|\\' '/|\\-')"
printf "\b\b$symbol]"
done