Skip to content

Instantly share code, notes, and snippets.

View thanodnl's full-sized avatar

Nils Dijk thanodnl

  • Microsoft
  • Amsterdam, The Netherlands
View GitHub Profile
@thanodnl
thanodnl / auth.go
Created June 19, 2018 17:30
golang middleware auth
package auth
import (
"net/http"
"context"
"github.com/thanodnl/area51/authrouter/middleware"
)
const (
UsernameHeader = "username"
#!/usr/bin/env python
import json
from pprint import pprint
fname = 'file.json'
with open(fname) as f:
for line in f:
data = json.loads(line)
pprint(data)
break

Keybase proof

I hereby claim:

  • I am thanodnl on github.
  • I am thanodnl (https://keybase.io/thanodnl) on keybase.
  • I have a public key whose fingerprint is D804 4ED7 0E3E F54B 306A CE0B 7DEB C138 AAB6 C1E5

To claim this, I am signing this object:

@thanodnl
thanodnl / .gitignore
Last active August 29, 2015 13:56
elasticsearch aggs bug
*.out
node_modules/**
$ curl 'http://localhost:9200/52b1e8c1f8b9d73130000004/_search?pretty=true' -d '{
> "size": 0,
> "facets": {
> "participants": {
> "terms": {
> "field": "actor.displayName",
> "size": 10
> }
> }
> },
@thanodnl
thanodnl / AutoListener.java
Created October 20, 2011 22:22
AutoListener
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
@thanodnl
thanodnl / Range.java
Created June 27, 2011 16:03
Generic range class
/**
* Create a range of comparable components. This range is automatically circular
* if the upper bound is smaller than the lower bound.
* You can for example make a range of type {@link String} as shown below
* <p>
* <code>
* Range&lt;String&gt; r = new Range&lt;String&gt;({@link RangeCheck#INCLUDE_LOWER}, "hello", "world");
* </code>
* <p>
* An object is said to be this in this range when its natural order is between
#!/usr/bin/env python
# Nils Dijk, 2011
def bucket(iterable, key):
"""Creates buckets from iterables
Iterates through all elements in iterable and offers it to the callable key.
Key is supposed to generate a key for the element offered, this key is used
as the key in a dictionary where the element is appended to.
package nl.thanod;
/**
* A single file JSON encoder/decoder from and to native java objects.
*/
import java.io.EOFException;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field;