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 / test-concurrency.scala
Created August 1, 2014 21:12
Test concurrency fun
import sbt._
import Keys._
object TestBuild extends Build {
lazy val root = Project(id = "root", base = file(".")).aggregate(project1, project2).settings(defaultSettings:_*).settings(
concurrentRestrictions in Global := Seq(
Tags.limit(Tags.ForkedTestGroup, 1)
)
)
@jsuereth
jsuereth / spec.md
Last active August 29, 2015 14:04
DOGE lambda language

Lambda DOGE

A really dumb idea put into an even dumber spec.

Notes: Grammar is probably ambiguous. Too lazy to actually implement right now, but was playing with syntactic ideas to stay true to the Meme AND to lambda calculus.

Basic Grammar

Any whitespace acts as a token delimiter.

@jsuereth
jsuereth / sbt-with-java
Created March 30, 2015 13:41
Script for loading sbt with a particular JDK in ubuntu.
#!/bin/bash
declare -r java_dirs=$(ls /usr/lib/jvm)
declare -r default_java=java-6-openjdk-amd64
function findJavaHome() {
if test "$1" == ""; then
java_version="$default_java"
else
java_version="$1"
@jsuereth
jsuereth / apart.scala
Last active August 29, 2015 14:26
Frustrating case class issue
scala> case class Foo private(x: Int)
defined class Foo
scala> Foo(5)
res5: Foo = Foo(5)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.scala-tools.maven-scala-plugin</groupId>
<artifactId>testJavaAndScala</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Test for Java + Scala compilation</name>
Welcome to Scala version 2.8.0.r0-b20090301210344 (Java HotSpot(TM) Client VM, Java 1.6.0_10).
Type in expressions to have them evaluated.
Type :help for more information.
scala> trait ReponseHelper[A];
defined trait ReponseHelper ^
scala> def doSomething[A](x : ReponseHelper[_ <: A]) : A = null.asInstanceOf[A]
doSomething: [A](ReponseHelper[_ <: A])A ^
josh@suereth-desktop:~/projects/blog/s99$ scala
Welcome to Scala version 2.7.1.final (OpenJDK Client VM, Java 1.6.0_0).
Type in expressions to have them evaluated.
Type :help for more information.
scala> def x(one:Int, two:Int, three:Int, four:Int, five:Int, six:Int, seven:int, eight:int, nine:Int, ten:Int, eleven:Int, twelve:Int, thirteen:Int, fourteen:Int, fifteen:Int, sixteen:Int, seventeen:Int, eighteen:Int, nineteen:Int, twenty:Int, twentyone:Int, twentytwo:Int, twentythree:Int) = one + two
x: (Int,Int,Int,Int,Int,Int,int,int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int)Int
scala> x _
<console>:6: error: missing arguments for method x in object $iw;
Welcome to Scala version 2.8.0.r21454-b20100411185142 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_15).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val x : Int => Unit = y => println(y)
x: (Int) => Unit = <function1>
scala> x(v1 = 2)
2
scala> class Foo {
| type T = this.type
| def cloneit : T = {
| val x = new Foo
| x match {
| case y : T => y
| case _ => error("ZOMG")
| }
| }
| }