Skip to content

Instantly share code, notes, and snippets.

@michiel
michiel / docker-rm-all.sh
Created September 28, 2015 18:26
Delete all docker containers and images
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@michiel
michiel / kafka-consumer.java
Created October 11, 2015 17:46 — forked from terrancesnyder/kafka-consumer.java
Simple example of publishing avro messages to Kafka.
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.avro.io.BinaryDecoder;
import org.apache.avro.io.BinaryEncoder;
import org.apache.avro.io.DecoderFactory;
@michiel
michiel / pad_data.r
Last active December 21, 2015 09:24
Pad timeseries data in R
# based on https://bocoup.com/weblog/padding-time-series-with-r
pad_data <- function(data, attr='date', value='value', by='hour') {
sorted.data <- data[order(data[[attr]]),]
info.data.length <- length(sorted.data[[attr]])
info.date.min <- sorted.data[[attr]][1]
info.date.max <- sorted.data[[attr]][info.data.length]
library(ggplot2)
library(scales)
render_graph <- function(data) {
ggplot(data=data, aes(x=date, y=value)) +
geom_line(shape=1) +
scale_x_datetime(labels = date_format("%m/%d %H:%M"))
}
library(xts)
@michiel
michiel / java-init.sh
Created January 6, 2016 11:16
Java service script
#!/bin/sh
SERVICE_NAME=ServiceName
PATH_TO_JAR=/srv/app/location/service-jar.jar
PID_PATH_NAME=/tmp/$SERVICE_NAME-pid
case $1 in
start)
echo "Starting $SERVICE_NAME ..."
if [ ! -f $PID_PATH_NAME ]; then
@michiel
michiel / rethinkdb-getall.md
Created February 15, 2016 10:10 — forked from coffeemug/rethinkdb-getall.md
Using the `getAll` command to query multiple keys in RethinkDB 1.7.

Querying by multiple keys

The previous releases of RethinkDB allowed querying indexes as follows:

// Three ways to get the user with primary key 5
r.table('users').get(5)
r.table('users').getAll(5)
r.table('users').getAll(5, {index: 'id'})
@michiel
michiel / transducer-rxjs-ramda.js
Created February 22, 2016 15:52
transducer in es6 with ramda and rxjs
const Rx = require('rx');
const R = require('ramda');
const seq = Rx.Observable.range(1, 10);
const isEven = (x) => x % 2 === 0;
const add1 = (x) => x + 1;
const transducer = R.compose(
R.map(add1),
@michiel
michiel / keycloak.sh
Created May 13, 2016 15:01 — forked from paoloantinori/keycloak.sh
Keycloak Admin API Rest Example
#!/bin/bash
export TKN=$(curl -X POST 'http://localhost:8080/auth/realms/master/protocol/openid-connect/token' \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin" \
-d 'password=admin' \
-d 'grant_type=password' \
-d 'client_id=admin-cli' | jq -r '.access_token')
curl -X GET 'http://localhost:8080/auth/admin/realms' \
@michiel
michiel / protocol-fix.txt
Created May 27, 2016 09:43 — forked from eculver/protocol-fix.txt
How to deal with tmux "protocol version mismatch"
$ tmux attach
protocol version mismatch (client 7, server 6)
$ pgrep tmux
3429
$ /proc/3429/exe attach
@michiel
michiel / jsonSchemaInterface.ts
Created August 3, 2016 14:20 — forked from enriched/jsonSchemaInterface.ts
TypeScript interface for Json-Schema V4
/**
* MIT License
*
* Copyright (c) 2016 Richard Adams (https://github.com/enriched)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is