This file contains 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
var evaluatorString = | |
'(function(stuff) {'+ | |
' return eval("(function() {"'+ | |
'+stuff+'+ | |
'"return "+evaluatorString+";'+ | |
'})();");'+ | |
'})'; | |
var scope1 = eval(evaluatorString); | |
var scope2 = scope1('var myVar = 42;'); |
This file contains 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
sys = require('sys') | |
print = sys.print | |
class A | |
bar: -> | |
print "A's bar\n" | |
this.baz() | |
baz: -> |
This file contains 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
var A, B, a, b, print, sys; | |
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { | |
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } | |
function ctor() { this.constructor = child; } | |
ctor.prototype = parent.prototype; | |
child.prototype = new ctor; | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
sys = require('sys'); |
This file contains 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
scala> val agent = new org.smop.mechanize.Mechanize | |
agent: org.smop.mechanize.Mechanize = org.smop.mechanize.Mechanize@612e3937 | |
scala> agent.get("http://www.smop.org/") | |
res0: org.apache.http.HttpResponse = org.apache.http.message.BasicHttpResponse@3ab5b692 | |
scala> agent.isSuccess | |
res1: Boolean = true | |
scala> agent.isHtml |
This file contains 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 a = List(1,2,3,4) | |
val b = List("A","B","C","D") | |
val c = Map() ++ a.zip(b) |
This file contains 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 io.Source | |
import java.io.File | |
object Stuff { | |
val Import = """.*@import\s*"(.*?)".*""".r | |
def allLessFiles(initial: File): Set[File] = | |
Set(initial) ++ Source.fromFile(initial).getLines().flatMap[File](_ match { | |
case Import(file) => allLessFiles(new File(initial.getParentFile, file)) | |
case _ => Set.empty |
This file contains 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
// Compile this with scala 2.9.x and an extra option: | |
// scalac -Xexperimental dyn.scala | |
/** | |
* Example to show off the Dynamic trait. | |
* | |
* Create an instance, call methods on it (the methods return this | |
* so you can chain calls), then call result. | |
**/ | |
class ListBuilder extends Dynamic { |
This file contains 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
@(helloForm: Form[(String,Int,Option[String])]) | |
@import helper._ | |
@main(title = "The 'helloworld' application") { | |
<h1>Configure your 'Hello world':</h1> | |
@form(action = routes.Application.sayHello, args = 'id -> "helloform") { |
This file contains 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
// some data to interpolate | |
val attributes = Attributes("a"->"data wins", "b" -> "data loses") | |
val attributeValue = "one" | |
val nodes = Group(Elem("hi", Attributes()), Text(" there")) | |
// Scala 2.10's pluggable string interpolation | |
// Here xml"" means: create an Anti-XML element | |
val xml = xml"""<foo a="overridden" $attributes b="literal wins">blie <b attr=$attributeValue/> bla $nodes</foo>""" |
This file contains 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
name := "delegation" | |
scalaVersion := "2.10.0" | |
libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _) |
OlderNewer