Skip to content

Instantly share code, notes, and snippets.

View Synesso's full-sized avatar

Jem Mawson Synesso

View GitHub Profile
package au.com.loftinspace;
import com.googlecode.instinct.marker.annotate.Subject;
import com.googlecode.instinct.marker.annotate.Mock;
import com.googlecode.instinct.marker.annotate.Specification;
import com.googlecode.instinct.marker.annotate.BeforeSpecification;
import static com.googlecode.instinct.expect.Expect.expect;
import com.googlecode.instinct.integrate.junit4.InstinctRunner;
import java.util.List;
package au.com.loftinspace;
import com.googlecode.instinct.marker.annotate.Subject;
import com.googlecode.instinct.marker.annotate.Mock;
import com.googlecode.instinct.marker.annotate.Specification;
import com.googlecode.instinct.marker.annotate.BeforeSpecification;
import static com.googlecode.instinct.expect.Expect.expect;
import com.googlecode.instinct.integrate.junit4.InstinctRunner;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
jem@fawkes:~/projects/specs-presentation$ scala -cp lib_managed/default/specs-1.4.4.jar:lib_managed/default/mockito-core-1.7.jar:lib_managed/default/h-core-1.1.jar:lib_managed/default/junit-4.4.jar
Welcome to Scala version 2.7.3.final (Java HotSpot(TM) Client VM, Java 1.6.0_13).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import org.specs._
import org.specs._
scala> import org.specs.mock._
import org.specs.mock._
Author : Clare Marie Peden (IP: 90.212.228.97 , 5ad4e461.bb.sky.com)
E-mail : clare.marie@hotmail.com
URL :
Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=90.212.228.97
Comment:
My dad bought me a religious magnetic figurine of the Virgin Mary. When I said to him it looked like a chess-piece, he beat me up and I called the police. I was 23 at the time. I didn't have any contact with him for 4 years after that. I am now 35. Can you please send me a picture of a religious Virgin Mary chess-piece so I can prove to him that I am right? He is so old-fashioned, he refuses to believe that anything religious could possibly have anything to do with chess. He thinks chess-pieces are based on evil and not Christianity.
Thank you.
(for (i <- 100 to 999; j<- i to 999; val prod = i*j; val prodStr = prod.toString; if prodStr.equals(prodStr.reverse.toString)) yield (i, j, prodStr)).foldLeft((1,1,"1")){ (max, next) => if (max._3.toInt > next._3.toInt) max else next }
new Request.JSON({url: "moves.json.jsp", onSuccess: function(movesRawHash) {
viableMoves = new Hash(movesRawHash);
viableMoves.each(function(to, from, hash) {
console.log('adding events to ' + from)
var toElements = []
to.each(function(dest, i, ary) {toElements = toElements.include($(dest))});
new Drag.Move($(piecesPerSquare.get(from)), {
droppables: toElements,
precalculate: true,
val matches = (utm.friends ::: utm.followers).map(u => NameAndScreenName(u.name, u.screenName)).filter(_.matches(searchText.text)).sort((e1, e2) => (e1 compareTo e2) < 0).removeDuplicates
(matches.length match {
case 0 => "No matches were found"
case 1 => "Select the following item to insert a @screenname"
case _ => "Select one of these " + matches.length + " items to insert a @screenname"
}) :: matches
$ java -jar js.jar
Rhino 1.7 release 2 2009 03 22
js> load ("mootools-1.2.3-core-server.js");
js> var Cat = new Class({
> initialize: function(name){
> this.name = name;
> }
> });
js> var kitty = new Cat("Kitty");
js> print(kitty.name);
def factorise(l: Long): Map[Long, Int] = {
def innerFactorise(l: Long, primes: List[Long], factors: List[Long]): List[Long] = {
def expandPrimes: List[Long] = {
def innerExpand(candidate: Long): List[Long] = {
val maxFactor = Math.sqrt(candidate).toLong + 1l
val factors = primes.takeWhile(_ < maxFactor).dropWhile(candidate % _ != 0)
if (factors.isEmpty) primes ::: candidate :: Nil else innerExpand(candidate + 1)
}
innerExpand(primes.last + 1)
}
import java.util.regex._
import java.net._
import scala.xml._
import scala.io._
def inputValue(s: String, n: String) = {
val headless = s.substring(s.indexOf("name=%s value=\"".format(n))+ 13 + n.length)
headless.substring(1, headless.indexOf("\">"))
}