This file contains hidden or 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
val (scalatestArtifact, scalatestVersion) = buildScalaVersion match | |
{ | |
case "2.7.7" => ("scalatest", "1.2") | |
case "2.8.0" => ("scalatest", "1.3") | |
case "2.8.1" => ("scalatest", "1.3") | |
case "2.9.0" => ("scalatest_2.9.0", "1.4.1") | |
case n => error("Unsupported Scala version " + n) | |
} | |
val scalatest = "org.scalatest" % scalatestArtifact % scalatestVersion % "test" |
This file contains hidden or 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
require 'rubygems' | |
require 'sinatra' | |
require 'json' | |
get '/', :provides => 'json' do | |
data = {"key1" => ["a", "b"], | |
"key2" => 10} | |
JSON::dump(data) | |
end |
This file contains hidden or 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
class Foo | |
attr_reader :a, :b | |
def initialize | |
@a = 'a-Foo' | |
@b = 'b-Foo' | |
end | |
end | |
class Bar | |
attr_reader :a, :c |
This file contains hidden or 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
class ClassDumper | |
{ | |
type Meth = | |
{ | |
def getParameterTypes: Array[Class[_]] | |
def getName: String | |
} | |
def methodToString(m: Meth): String = | |
{ |
This file contains hidden or 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
; I've been trying to convert my Scaladoc comments from Java style to Scala style. | |
; i.e., from: | |
; /** | |
; * This amazing method washes your hair, trims your beard, and | |
; * and brushes your teeth. | |
; */ | |
; | |
; to: | |
; | |
; /** This amazing method washes your hair, trims your beard, and |
This file contains hidden or 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
// So, given this declaration: | |
import java.io.File | |
val scalaDirs = new File("target").listFiles.filter(_.getName.startsWith("scala")) | |
// Why does this work: | |
scalaDirs.take(1).map(new File(_, "classes")).toList(0) | |
// but this fails to compile? |
This file contains hidden or 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
# Load a config-local.yml configuration file, which has special | |
# configuration directives per environment. | |
require 'rails' | |
CONFIG_LOCAL = 'config-local.yml' | |
OPTIONS = { | |
:listen_port => 3000, | |
# Default email addresses. |
This file contains hidden or 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
# A stack, using bash arrays. | |
# --------------------------------------------------------------------------- | |
# Create a new stack. | |
# | |
# Usage: stack_new name | |
# | |
# Example: stack_new x | |
function stack_new | |
{ |
This file contains hidden or 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
# RFC1422-compliant Javascript UUID function. Generates a UUID from a random | |
# number (which means it might not be entirely unique, though it should be | |
# good enough for many uses). See http://stackoverflow.com/questions/105034 | |
uuid = -> | |
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) -> | |
r = Math.random() * 16 | 0 | |
v = if c is 'x' then r else (r & 0x3|0x8) | |
v.toString(16) | |
) |
This file contains hidden or 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 ThinkingAboutThisApproach { | |
object Types { | |
type Converter[T] = (String, ArgSpec) => Either[String, T] | |
} | |
import Types._ | |
class ArgOption[T](val name: String, val desc: String, val cvt: Converter[T]) { | |
override def toString = "ArgOption<%s>" format name |