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
// Konverter tekst: Tirsdag, ukenr 49, år 2006 | |
// til dato | |
Date gjettSlakteDato(String tekst, Date compareToDate) { | |
def ukedag = ["Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag", "Søndag"] | |
def split = tekst.split(",") | |
String d = ukedag.findIndexOf {it == split[0]} + 1 | |
String ww = split[1][-2..-1] | |
String y = split[2][-1] | |
return convertDateFormat(y+ww+d, compareToDate) | |
} |
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
(function ($) { | |
jQuery.noConflict(); | |
var sheepImage = new google.maps.MarkerImage('sau.png', | |
new google.maps.Size(37, 25), // marker size | |
new google.maps.Point(0,0), // origin | |
new google.maps.Point(18, 12)); // anchor is the middle of the image | |
var shape = { | |
coord: [1, 1, 1, 37, 25, 37, 25 , 1], | |
type: 'poly' |
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
<html> | |
<head> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> | |
<link rel="stylesheet" href="ullami.css" type="text/css"> | |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script type="text/javascript" src="ullami.js"></script> | |
</head> | |
<body> |
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 alphabet = ('A'..'Z')+ ['Æ','Ø','Å'] | |
def combinations = [:] | |
alphabet.each { first -> | |
alphabet.each { second -> | |
alphabet.each { third -> | |
def str = "" + first + second + third | |
def hash = str.hashCode() | |
if (combinations[hash]) { | |
println combinations[hash]+" has same hashcode as "+str+"!!!!!! ("+hash+")" | |
} |
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 Y = { le -> ({ f -> f(f) })({ f -> le { x -> f(f)(x) } }) } | |
def factorial = Y { fac -> | |
{ n -> n <= 2 ? n : n * fac(n - 1) } | |
} | |
assert 2432902008176640000 == factorial(20G) |
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
(defn normalize | |
"Transforms a tabular form to a normalised hierarchical form." | |
([kw values-kw coll] | |
(normalize kw values-kw [] coll)) | |
([kw values-kw promoted-keys coll] | |
(normalize kw values-kw promoted-keys identity coll)) | |
([kw values-kw promoted-keys f coll] | |
(map | |
(fn [[k v]] | |
(merge {kw k |
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
UTF-8: æøåÆØÅ | |
ISO-8859-1: ʯÂ∆ÿ≈ | |
MacRoman: æøåÆØÅ | |
I korthet: | |
* non-UTF-8 aapnet i UTF8 gir svarte spoersmaalstegn | |
* non-ISO aaapnet i ISO: UTF8: diverse A-tegn, MacRoman: 3/4 (R) E etc | |
* non-Mac aapnet i Mac: UTF-8: Kvadratrot, ISO: E, delta Y mattesymboler |
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
// Tested in groovy 2.4.3 | |
import groovy.transform.TypeChecked | |
@TypeChecked | |
interface F1<A, B> { // Function1 | |
abstract B f(A a); | |
} | |
@TypeChecked | |
interface Functor<T, A> { // Egentlig Functor<T<A>> men det går ikke i java/groovy | |
abstract <A,B> T<B> map(F1<A, B> f) |
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 shapeless.examples | |
import shapeless._ | |
import poly._ | |
import labelled._ | |
sealed trait Message | |
case class Ping(id: Long, sender: String) extends Message | |
case class Pong(id: Long, receiver: String) extends Message |
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.nio.ByteBuffer | |
public static byte[] bytes(long l) { | |
ByteBuffer.allocate(Long.BYTES).putLong(l).array(); | |
} | |
def pretty(byte[] b) { | |
def sb = new StringBuilder() | |
for(i=0;i<b.length;i++){ | |
sb.append(String.format("\\x%02X", b[i])) |
OlderNewer