Skip to content

Instantly share code, notes, and snippets.

View adamretter's full-sized avatar
🎩
Down the Code Mine

Adam Retter adamretter

🎩
Down the Code Mine
View GitHub Profile
object Blah extends App {
trait ArgProvider {
}
case class ColumnReference(value: String) extends ArgProvider
abstract class Rule(name: String, val argProviders: ArgProvider*)
(:~
: Neat examples of zero-padding a one digit month, for later
: construction of xs:date etc.
:)
(: Example 1: When given a single digit month :)
let $month := '4'
return
substring(concat('0', $month), string-length($month))
package wlhn
import com.twitter.hashing.KeyHasher
object BloomApp extends App {
/**
* A bloom filter is used to test whether an element is a member of a set.
*
@adamretter
adamretter / AllCombinations.scala
Created May 28, 2014 21:12
All permutations of all combinations of input
object AllCombinations extends App {
/**
* Returns all permutations of all combinations
* of everything in the input data
*
* For example, given the `data` List('a', 'b', 'c')
* will return the result:
*
* List(
xquery version "3.0";
module namespace ranges = "http://github.com/adamretter/ranges";
(:~
: Produces sequences of ranges ($from, $to)
: which span a $range-size
: all the way from $range-from upto $range-to
:
: This can be very useful when working
@adamretter
adamretter / random-hex.xq
Created July 2, 2014 15:58
XQuery for Random hex string
(:~
: Generates a string of random hex digits
: @author Adam Retter <adam@exist-db.org>
:)
let $len := 20 (: how long a string to generate :)
return
codepoints-to-string(((1 to $len) ! util:random(16)) ! (.[. lt 10]+48, .[. ge 10]+87))
@adamretter
adamretter / presentations.csvs
Created July 15, 2014 08:44
CSV Schema for csvconf.com/presentations.csv
version 1.0
@totalColumns 4
room: is("Galeria") or is("1") or is("2")
start: regex("(([0-1][0-9])|(2[0-3])):[0-5][0-9]")
name: notEmpty
title: notEmpty
/*
CSV Schema for http://csvconf.com/presentations.csv
*/
@adamretter
adamretter / schedule.csvs
Created July 15, 2014 08:45
CSV Schema for csvconf.com/schedule.csv
version 1.0
@totalColumns 4
Time: regex("(([0-1][0-9])|(2[0-3])):[0-5][0-9] - (([0-1][0-9])|(2[0-3])):[0-5][0-9]")
Galeria: notEmpty
"Room 1":
"Room 2":
/*
CSV Schema for http://csvconf.com/schedule.csv
*/
@adamretter
adamretter / schedule.csvs
Created July 15, 2014 08:59
CSV Schema for csvconf.com/schedule.csv
version 1.0
@totalColumns 4
Time: regex("(([0-1][0-9])|(2[0-3])):[0-5][0-9] - (([0-1][0-9])|(2[0-3])):[0-5][0-9]")
Galeria: notEmpty
"Room 1":
"Room 2":
/*
CSV Schema for http://csvconf.com/schedule.csv
*/
@adamretter
adamretter / word-distance.scala
Created August 15, 2014 13:57
WLHN - Finding the minimum distance between 2 words
package wlhn
/**
* West London Hack Night 2014-08-13
* Finding the minimum distance
* between any two words in a Shakespeare
* play
*/
object Dijkstra {