Skip to content

Instantly share code, notes, and snippets.

@wfaler
wfaler / namespacingWithoutPollutingGlobalNamespace
Created June 2, 2012 13:06
namespacingWithoutPollutingGlobalNamespace.coffee
# setting 'exports' as alias to global namespace
exports = this
# creating an empty object to act as a namespace for classes in this file
exports.ext = {}
# GreeterPanel is a previously defined CoffeeScript class
# namespacing and exposing GreeterPanel globally in the ext.GreeterPanel namespace
exports.ext.GreeterPanel = GreeterPanel
@wfaler
wfaler / validateanyProduct.scala
Created May 31, 2012 15:21
validateanyProduct.scala
// modify to collect errors, use Either or whatever floats your boat, just an example that throws
// IllegalArgumentException on the first null or empty String it encounters, if there is one.
// Works for any case class or collection such as List.
def validateProduct[T <: Product](product: T): Unit = product.productIterator foreach {
case null => throw new IllegalArgumentException("null attributes are not allowed for " + product)
case x: String if x.isEmpty => throw new IllegalArgumentException("Empty strings are not allowed for " + product)
case x: Product => validateProduct(x)
case _ => {}
}
@wfaler
wfaler / helloExtJS.coffee
Created May 27, 2012 11:47
helloExtJS.coffee
tpl = new Ext.Template ['Hello {firstName} {lastName}!',
' Nice to meet you!']
formPanel = new Ext.form.FormPanel
@wfaler
wfaler / build.sbt
Created April 26, 2012 12:14
build.sbt
resolvers ++= Seq(Resolver.url("sbt-plugin-releases",
new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns))
addSbtPlugin("org.ensime" % "ensime-sbt-cmd" % "0.0.10")
@wfaler
wfaler / init.el
Created April 26, 2012 12:12
init.el
(add-to-list 'load-path "~/.emacs.d/scala-mode")
(add-to-list 'load-path "~/.emacs.d/ensime/elisp")
(require 'scala-mode-auto)
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
@wfaler
wfaler / splittodays.scala
Created February 10, 2012 18:22
continuous timeline to list of days
lazy val tradingDays: List[List[Price]] = prices.groupBy(price => {
Days.daysBetween(price.dateTime, prices.last.dateTime)
}).values.toList.sortWith((a,b) => a.head.dateTime.isBefore(b.head.dateTime))
@wfaler
wfaler / gist:1773282
Created February 8, 2012 20:36
install java silently on ubuntu
sudo apt-get --yes --force-yes install openjdk-6-jdk
@wfaler
wfaler / build.sbt
Created January 24, 2012 16:19
global sbt plugins for 0.11.2
resolvers ++= Seq("sbt-idea-repo" at "http://mpeltonen.github.com/maven/", "sbt-plugin-releases" at "http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/",
Resolver.url("sbt-plugin-releases",
new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns))
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.7.3")
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.0.0")
@wfaler
wfaler / requestsearch.json
Created December 12, 2011 21:30
requestsearch.json
{"count":2,"items":[{"ref":{"id":"33816cc4c0a8000215a00d2554f8cab8","accountId":"194ad084c0a80002274b8c218ea70268","dateTime":"2011-12-12T18:20:47Z","documentTime":"2011-12-12T18:20:48Z"},"success":true,"url":"http://blog.recursivity.com/post/13499141271/textminr-progress-update","title":"Recursivity - TextMinr Progress Update"},{"ref":{"id":"334fee29c0a8000215a00d2579292428","accountId":"194ad084c0a80002274b8c218ea70268","dateTime":"2011-12-12T17:26:43Z","documentTime":"2011-12-12T17:26:46Z"},"success":true,"url":"http://blog.recursivity.com/post/13499141271/textminr-progress-update","title":"Recursivity - TextMinr Progress Update"}]}
@wfaler
wfaler / similarityrequest.json
Created December 12, 2011 21:20
similarityrequest.json
{"name":"documentsimilarity","config":["REQUEST_ID_OF_FIRST_COMPARISON_DOC", "REQUEST_ID_OF_SECOND_COMPARISON_DOC"]}