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
import inspect | |
def mixin(cls, *funcs): | |
""" | |
Mix the specified class into the current class. If function names (as | |
strings) are passed, then only those functions are mixed in. | |
mixin() MUST be called within a class definition. | |
Example: |
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
import sbt._ | |
import Keys._ | |
import org.clapper.sbt.lwm.LWM._ | |
object TestBuild extends Build { | |
override lazy val projects = Seq(root) | |
lazy val root = Project( | |
"root", file(".") | |
).settings (LWM.settings : _*).settings( | |
LWM.targetDirectory in LWM.Config <<= baseDirectory(_ / "target2") |
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
# Get a printable version of all properties in an object. Ignores function | |
# properties. DO NOT MAKE THIS A PROPERTY OF Object! | |
window.objectToString = (obj) -> | |
t = typeof obj | |
if (t is "number") or (t is "boolean") | |
"#{obj}" | |
else if window.isArray(obj) | |
window._arrayToString(obj) | |
else if t is "string" | |
'"' + obj + '"' |
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 |
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
# 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
# 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
// 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
; 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
class ClassDumper | |
{ | |
type Meth = | |
{ | |
def getParameterTypes: Array[Class[_]] | |
def getName: String | |
} | |
def methodToString(m: Meth): String = | |
{ |