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 java.util.{Calendar, Date} | |
import Calendar._ | |
class TimeIncrement(val increment: Int /* FIXME */, val amount: Int) | |
class IntDate(val number: Int) { | |
def days = new TimeIncrement(DATE, number) | |
} |
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
case class Employee(val dailyRate: Double) { | |
def getDailyRate = dailyRate | |
} | |
trait Calculator { | |
def calculate(dailyRate: Double, noOfDays: Int): Double | |
} | |
trait Calendar { | |
def noOfDays: Int |
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 java.util.ArrayList; | |
import java.util.List; | |
class Employee { | |
private Double dailyRate; | |
public Employee(Double dailyRate) { | |
this.dailyRate = dailyRate; | |
} | |
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
class User(val firstName: String, val lastName: String) | |
trait UserDao { | |
def findByFirstName(firstName: String): User | |
} | |
object defaultUserDao extends UserDao { | |
override def findByFirstName(firstName: String) = new User(firstName, "Lewis") | |
} |
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 EventAttacher = Class.create({ | |
events: "click,focus".split(","), | |
initialize: function(element, handler) { | |
this.element = $(element); | |
this.handler = handler; | |
this.events.each(this._buildObservationMethod.bind(this)); | |
}, | |
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
Array.prototype.toList = function() { | |
var list = new Element("ul") | |
$A(this).each(function(e) { list.appendChild(new Element("li").update(e)) } ) | |
return list | |
} | |
document.body.appendChild([1,2,3].toList()) |
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
trait XmlRenderer { | |
val handlers = Map( | |
"span" -> ((n: Node) => | |
<handled> | |
<div class="boink"> | |
{n.label} | |
</div> | |
</handled> | |
) | |
) |
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
/* | |
* An object for building an object of handler methods, which can | |
* can then be added via Element.addMethods. Example result: | |
* | |
* { | |
* mousedown: function(element, fn) { | |
* element = $(element); | |
* element.observe("mousedown", fn.bind(element)); | |
* return element; | |
* }, |
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
/* | |
* Extension that makes it easy to convert an array to a "hash" | |
* (a bland JSON object), given an array of desired keys. | |
*/ | |
Array.prototype.toObject = function(keys) { | |
var obj = {}; | |
for(var i = 0; i < keys.length; i++) { | |
obj[keys[i]] = this[i]; | |
} | |
return obj; |
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
/* | |
* Recursive xml transformation util. Provides a simplistic tool for | |
* registering transforms as functions, which will be called recursively | |
* on each node of the tree. | |
*/ | |
import scala.xml._ | |
trait XmlRenderer { | |
val handlers: Map[(Node) => Boolean, (Node) => Node] |
OlderNewer