Skip to content

Instantly share code, notes, and snippets.

@jsuereth
jsuereth / incremental.scala
Last active August 29, 2015 13:59
sbt incremental task example
import sbt._
import sbinary._
import DefaultProtocol._
object Incremental {
val soupOfTheDay = taskKey[String]("Returns the soup of the day. If none is defined, asked for one and remembers until cleaned.")
val showMenu = taskKey[Unit]("Displays the menu")
def settings: Seq[Setting[_]] =
Seq(
soupOfTheDay := {
@jsuereth
jsuereth / Bintray-For-Plugins.rst
Last active December 21, 2015 22:49
Bintray plugin documentation

Bintray For Plugins

This is currently in Beta mode.

sbt hosts their community plugin repository on Bintray. Bintray is a repository hosting site, similar to github, which allows users to contribute their own plugins, while sbt can aggregate them together in a common repository.

This document walks you through the means to create your own repository for hosting your sbt plugins and then linking them into the sbt shared repository. This will make your plugins available for all sbt users without additonal configuration (besides declaring a dependency on your plugin).

@jsuereth
jsuereth / download.bash
Created June 20, 2013 16:37
scalawags youtube -> wav download script
#!/bin/bash
if test "$#" != "2"; then
echo "Usage: $0 <url> <directory>"
exit 1
fi
url=$1
directory=$2
@jsuereth
jsuereth / parse.scala
Created September 11, 2012 18:36
Parse a string to a tree
scala> import reflect.runtime.currentMirror
import reflect.runtime.currentMirror
scala> import scala.tools.reflect.ToolBox
import scala.tools.reflect.ToolBox
scala> currentMirror.mkToolBox()
res5: scala.tools.reflect.ToolBox[reflect.runtime.universe.type] = scala.tools.reflect.ToolBoxFactory$ToolBoxImpl@2288e718
scala> res5.parseExpr("def x = 'c'")
@jsuereth
jsuereth / queue.scala
Created August 8, 2012 20:04
FOR ROLAND
scala> val x = collection.mutable.Queue(1,2,3)
x: scala.collection.mutable.Queue[Int] = Queue(1, 2, 3)
scala> x filterNot (_ % 2 == 0)
res0: scala.collection.mutable.MutableList[Int] = Queue(1, 3)
scala> x
res1: scala.collection.mutable.Queue[Int] = Queue(1, 2, 3)
@jsuereth
jsuereth / build.log
Created June 6, 2012 22:36
Never want to see this....
BUILD FAILED
/var/lib/jenkins/jobs/scala-release-main/workspace/build.xml:2163: The following error occurred while executing this line:
/var/lib/jenkins/jobs/scala-release-main/workspace/build.xml:1982: Execute failed: java.io.IOException: Cannot run program "chmod": java.io.IOException: error=12, Cannot allocate memory
@jsuereth
jsuereth / sbt-proxy-all
Created May 11, 2012 20:43
Step 1 is always failure
➜ sbt -Dsbt.repo.proxy.url=http://localhost:8081/ -no-share
Detected sbt version 0.12.0-Beta2
Starting sbt: invoke with -help for other options
Getting net.java.dev.jna jna 3.2.3 ...
:: problems summary ::
:::: WARNINGS
module not found: net.java.dev.jna#jna;3.2.3
==== proxy-maven: tried
@jsuereth
jsuereth / seqextractors.scala
Created March 17, 2012 00:55
Head/Tail + Init/Last extractors mirroring append/prepend
(master *$%=) ➜ ./build/quick/bin/scala
Welcome to Scala version 2.10.0-SNAPSHOT-20120316-312-d267988ddb (OpenJDK 64-Bit Server VM, Java 1.6.0_23).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val x = Vector(1,2,3,4)
x: scala.collection.immutable.Vector[Int] = Vector(1, 2, 3, 4)
scala> val y :+ z = x
y: scala.collection.immutable.Vector[Int] = Vector(1, 2, 3)
@jsuereth
jsuereth / queue.scala
Created March 8, 2012 21:09
Lame-o Queue to show how to implement new collections
package misc
import collection.SeqLike
import scala.collection.mutable.Builder
import scala.collection.mutable.ListBuffer
import scala.collection.generic.SeqFactory
import scala.collection.generic.GenericTraversableTemplate
import scala.collection.generic.CanBuildFrom
object Queue extends SeqFactory[Queue] {
@jsuereth
jsuereth / JTrain.java
Created February 23, 2012 20:16 — forked from mpitid/JTrain.java
Implementation of a simple training program in Python, Java and Scala
// vim: set ts=4 sw=4 et:
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Iterator;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;