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
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, |
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 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 |
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
$ 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); |
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
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) | |
} |
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.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("\">")) | |
} |
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.io.File | |
object Finder { | |
def find(fileStr: String): List[File] = find(new java.io.File(fileStr)) | |
def find(file: File): List[File] = { | |
if (file.isDirectory) file.listFiles.foldLeft(Nil: List[File]) {(acc, next) => find(next) ::: acc} else List(file) | |
if (next.isDirectory) find(next) :: acc else next :: acc2dd | |
} | |
} |
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
(1 until 1000).filter(i=> i%3==0 || i%5==0).reduceLeft(_+_) |
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
def fib(all: List[Int]): List[Int] = { | |
val next = all.last + all.init.last | |
if (next > 4000000) all else fib(all ::: List(next)) | |
} | |
fib(1::2::Nil).filter(_%2==0).reduceLeft(_+_) |
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
Source.fromURL("http://www.asx.com.au/asx/research/ASXListedCompanies.csv").getLines.drop(3).map(_.split("\"")).map(c => (c(1).trim, c(2).substring(1, 4), c(3).trim)).filter(!_._3.equals("GICS Sector Code Not Applicable")).filter(!_._3.equals("Classification Pending")).map(t => (t._1.split(" ").map(w => if (w.equals(t._2)) w else w.toLowerCase).map(w => if (w.equals("and") || w.equals("of")) w else w.capitalize).mkString(" "), t._2, t._3)).foreach(println) |
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
patterns: stylesheet:String_escaped:1:\\\\['"]::2:^String_double_quoted|String_single_quoted$:#006699::0:0: | |
patterns: stylesheet:String_single_quoted:1:':':1:^top|Braces$:#006699::1:2: | |
patterns: stylesheet:String_double_quoted:1:":":1:^top|Braces$:#006699::1:2: | |
patterns: stylesheet:Symbols:1:[\\,]::2:^top|Import|Media|Braces$:#000000::1:1: | |
patterns: stylesheet:Plaintext:1:[a-z]+::2:^Braces$:#000000::1:1: | |
patterns: stylesheet:Reference Class:1:1::3:^Reference$:#cc0000::1:2: | |
patterns: stylesheet:Reference:1:\\!([\\w\\-]+)::2:^Braces$:#0099cc::1:1: | |
patterns: stylesheet:Unit:1:1::3:Length$:#009966::2:2: | |
patterns: stylesheet:Length:1:\\-?[0-9.](\\%|cm|deg|em|ex|g?rad|in|k?hz|mm|ms|pc|pt|px)?(?![a-z\\-\:])::2:^Braces$:#009966::1:1: | |
patterns: stylesheet:Misc:1:\\b(above|absolute|always|attr|auto|avoid|(?\:base|in|over|under)line|below|bidi\\-override|blink|block|bold(?\:er)?|both|bottom|capitalize|(?\:small\\-)?caption|center|child|circle|(?\:no\\-)?(?\:open|close)\\-quote|code|collapse|compact|continuous|counter|cr |