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
package euler14 | |
object Main { | |
def isCollatzSerie(n:BigInt, numElements:BigInt):(BigInt, BigInt) = { | |
if(n <= 1) | |
(n, numElements) | |
else if(n%2 == 0) | |
isCollatzSerie(n >> 1, numElements + 1) | |
else |
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
package com.maasfrensch | |
import java.io._ | |
/** | |
* Adds some useful methods to file, to be used implicitely: | |
* implicit def file2enhanced(file:File) = new EnhancedFile(file) | |
* @author [email protected] | |
*/ | |
class EnhancedFile(val file:File) { |
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
private function connectRTMP():Boolean | |
{ | |
// setup timeout | |
connectionTimer.reset(); | |
connectionTimer.start(); | |
tryNC = []; | |
tryNCTimer = new Timer(DEFAULT_NC_TIMEOUT); | |
tryNCTimer.addEventListener(TimerEvent.TIMER, nextConnect); |
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 MyString(string:String){ | |
var value = string | |
def unary_- = new MyString(new StringBuilder(value).reverse.toString) | |
override def toString = value | |
} | |
val myString = new MyString("abcd") | |
println(myString) // prints "abcd" | |
println(-myString) // prints "dcba" |
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
private static final String TW33T0R_DATE_PATTERN = "HH:mm:ss - MMM dd"; | |
private static final String TWITTER_DATE_PATTERN = "EEE MMM dd HH:mm:ss Z yyyy"; | |
/** | |
* @param d The datestring as received from the twitter api | |
* @return the date formatted in tw33t0r format | |
*/ | |
private static String reformatTwitterDateToTw33t0rRepresentation(final String d) { | |
SimpleDateFormat formatter = new SimpleDateFormat(TWITTER_DATE_PATTERN); | |
try { |
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 groovyx.net.ws.WSClient | |
def wsdlUrl = "http://localhost:8080/Quickstart_helloworld/scheduleService?wsdl" | |
def proxy = new WSClient(wsdlUrl, this.class.classLoader) | |
proxy.create() | |
println proxy.findScheduleForUrn("my:test:urn") |
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 priceCalculator(tax: Double=>Double, reduction: Double=>Double, price:Double, shipping:Double) = tax(reduction(price + shipping)) | |
def reducationCalculator(price:Double) = if(price > 50) price - 10 else price | |
val withTax = priceCalculator(_*1.19,_: Double=>Double, _:Double, _:Double) | |
val withTaxAndReduction = withTax(reducationCalculator(_), _:Double, _:Double) | |
println(withTaxAndReduction(97.5, 2.5)) |
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
declare namespace vpro="urn:vpro:guide:2009"; | |
//vpro:program[@isMovie = '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
declare namespace vpro="urn:vpro:guide:2009"; | |
<results> | |
{ | |
for $prg in //vpro:program[@isMovie='true'] | |
let $scheduleEvents := //vpro:scheduleEvent[vpro:programRef&=$prg/@id] | |
return | |
<programWithSchedule> | |
{$prg} | |
<schedule>{for $s in $scheduleEvents return $s}</schedule> |
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
/** | |
* listen to topic queue | |
* -- on incoming message | |
* --- split message into program fragments using xpath | |
* ---- extract the id from the program | |
* ---- write a program document to the xml store | |
*/ | |
from("activemq:topic:incomingVPROGuide") | |
.splitter(vpro.xpath("//vpro:program")) |
OlderNewer