Skip to content

Instantly share code, notes, and snippets.

View anderseriksson's full-sized avatar

Anders Eriksson anderseriksson

View GitHub Profile
//console
//hide
//setup
//output
create (_0:`MetaDataRoot`)
create (_1 {type:"Person"})
create (_2 {name:"name"})
@anderseriksson
anderseriksson / gist:2917150
Created June 12, 2012 12:07
mvn test essentials
-Dmaven.test.skip=true
-Dtest=MyTest
@anderseriksson
anderseriksson / gist:2887027
Created June 7, 2012 06:54
Debugging Spring RequestMappingHandlerMapping
log4j.logger.org.springframework.web.servlet.mvc=DEBUG
@anderseriksson
anderseriksson / gist:2870611
Created June 4, 2012 20:17
how to make Informix avoid ipv6 on osx
air:etc informix$ netstat -an | grep 9088
tcp6 0 0 ?.9088 *.* LISTEN
air:etc informix$ pwd
/Applications/IBM/informix/etc
air:etc informix$ touch IFX_DISABLE_IPV6
air:etc informix$ onmode -ky
air:etc informix$ oninit
air:etc informix$ netstat -an | grep 9088
tcp4 0 0 192.168.0.93.9088 *.* LISTEN
@anderseriksson
anderseriksson / gist:2492570
Created April 25, 2012 19:30
Mastermind resolver in Scala
package mastermind
import collection.Seq
object MasterMindKata extends App {
def getPlusV1(z: Seq[(Char, Char)]): String = {
val res = for (t <- z) yield {
if (t._1 == t._2) {
@anderseriksson
anderseriksson / filterNotFirst.scala
Created April 24, 2012 20:25
filterNotFirst function in Scala
def filterNotFirst(s: Seq[Any], v: Any): Seq[Any] = {
s.diff(Seq(v))
}
assert(filterNotFirst(Seq(1,2,2,2,3), 2) == Seq(1,2,2,3))
assert(filterNotFirst(Seq('a','a'), 'a') == Seq('a'))
@anderseriksson
anderseriksson / gist:2419282
Created April 19, 2012 07:07
Generate password on OSX command line
openssl rand -base64 8 |md5 |head -c8;echo
@anderseriksson
anderseriksson / gist:2362555
Created April 11, 2012 21:01
Parallell top 5 using aggregate
(1 to 10000000).par.aggregate( List[Int]() ) ( (list: List[Int], b: Int ) => (list:+b).sortWith(_>_).take(5) , (a: List[Int], b: List[Int]) => (a ::: b).sortWith(_>_).take(5) )
@anderseriksson
anderseriksson / gist:2302967
Created April 4, 2012 15:42
Top 5 foldLeft in Scala
(1 to 1000).foldLeft(List(0)) {(c,r) => (c:+r).sortWith(_>_).take(5)}
@anderseriksson
anderseriksson / gist:2297914
Created April 4, 2012 05:14
Beräkna kontrollsiffran i ett personnummer med Scala (Luhn-algoritmen)
/**
*
* @param args personnumemr in the format yymmdd-nnnn
*/
def main(args: Array[String]) {
if (args.length > 0) {
val sum = args(0).toList.filter(_ != '-').map(_ - '0').take(9).foldLeft(0,2)((r,c) => {
(r._1 + (c * r._2) / 10 + (c *r._2) % 10 , if (r._2 ==2) 1 else 2)
})._1 % 10
val checkSum = if (sum == 0) 0 else 10 - sum