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
public class TernaryNpe {
public static void main(String args[]) {
final String a = "a";
final String aa = "aa";
final String b = null;
final String bb = "";
/* Test Case 1 */
static std::string copyString(JNIEnv* env, jstring js) {
const char *utf = env->GetStringUTFChars(js, NULL);
std::string name = std::string(utf);
env->ReleaseStringUTFChars(js, utf);
return name;
}
@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 {
@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 / 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 / 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 / random-hex.xq
Created July 2, 2014 15:58
XQuery for Random hex string
(:~
: Generates a string of random hex digits
: @author Adam Retter <[email protected]>
:)
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))
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 / 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(
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.
*