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
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
{ | |
"_id": "_design/news", | |
"_rev": "1-3487605953", | |
"language": "javascript", | |
"views": { | |
"articles": { | |
"map": "function(doc) {\n var newsitem = doc.newsitem\n if(newsitem && newsitem.tags.indexOf('artikel') != -1){\n emit(null, newsitem.title);\n }\n}" | |
} | |
} | |
} |
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
<html> | |
<body> | |
<h1>blaat</h1> | |
<script type="text/javascript" charset="utf-8"> | |
window.onload = function() { alert('hi there!') } | |
</script> | |
</body> | |
</html> |
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.examples | |
import javax.portlet._ | |
import CollectionExtensions._ | |
class MyPortlet extends GenericPortlet { | |
var normalView = null:PortletRequestDispatcher | |
override def init(config:PortletConfig):Unit = { |
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
object Main { | |
implicit def extendString(string:String) = new MyString(string) | |
def main(args: Array[String]) :Unit = { | |
val testValue = "1000"; | |
println(testValue.getClass().getName()) // prints java.lang.String | |
println(testValue.isNumeric) // prints true | |
println(testValue.lastIndexOf("0")) // prints 3 | |
println(testValue.getClass().getName()) // prints java.lang.String | |
} |
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
// Somple simple examples of using regular expressions in combination with pattern matching in Scala | |
// | |
// runs correctly on scala 2.8-nightly and 2.7.6.final | |
val RegionExpr = """.*?[aieoué][^aieoué](.+)""".r // string after first non-vowel following a vowel | |
"vergadering" match { | |
case RegionExpr(matchedGroup) => println("matched group: " + matchedGroup) // prints "gadering" | |
case _ => | |
} |
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
object Time { | |
def apply[T](name: String)(block: => T) { | |
val start = System.currentTimeMillis | |
try { | |
block | |
} finally { | |
val diff = System.currentTimeMillis - start | |
println("# Block \"" + name +"\" completed, time taken: " + diff + " ms (" + diff / 1000.0 + " s)") | |
} | |
} |
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
mvn -o dependency:tree | cut -c 7- | egrep '[\\\+\|].*' | sed 's/^[^a-z]*//g' | awk -F':' '{print "cp `find ~/.m2/repository -name " $2"-"$4".jar` lib/"}' | sh |
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
// ---- Implementation | |
import java.beans.Introspector | |
object BeanUtils { | |
val pathSeperator = """\.""" | |
def readValue(obj: Object, path: String): String = { | |
val res = path.split(pathSeperator).foldLeft(obj) { | |
(a: Object, prop: String) => |