This file contains hidden or 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 scala.collection.mutable.Map | |
val phonebook = Map("peter" -> "12345") | |
phonebook += ("henk" -> "12300") // adds, but doesn't re-assign | |
println(phonebook) |
This file contains hidden or 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.finalist.eip.examples; | |
import java.util.Arrays; | |
import java.util.List; | |
import javax.jms.ConnectionFactory; | |
import org.apache.activemq.ActiveMQConnectionFactory; | |
import org.apache.camel.CamelContext; | |
import org.apache.camel.EndpointInject; |
This file contains hidden or 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")) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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); |