Skip to content

Instantly share code, notes, and snippets.

@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@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
@michiel
michiel / transport-dynamodb-data.sh
Created March 26, 2020 00:13
Export and import DynamoDB data across environments
#!/bin/sh
SOURCE_TABLE=xxx-mydata-accp
TARGET_TABLE=xxx-mydata-prod
AWS_PROFILE=default
AWS_REGION=ap-southeast-2
# Step 1 - export and transform
aws --profile=$AWS_PROFILE \
@michiel
michiel / lat_lng_jitter.js
Last active March 7, 2023 16:51
Add jitter to latitude/longitude
//
// Make a few assumptions and add noise to latitude/longitude position
// Ex, console.log(jitter(-26.4853429150483, -49.072945734375, 5));
//
var rad_Earth = 6378.16;
var one_degree = (2 * Math.PI * rad_Earth) / 360;
var one_km = 1 / one_degree;
function randomInRange(from, to, fixed) {
@michiel
michiel / fluent-bit-nest.md
Last active November 9, 2022 16:03
fluent-bit example config/output for https://github.com/fluent/fluent-bit/pull/531

Nest/Lift

Nest 1

[INPUT]
    Name mem
    Tag  mem.local

[OUTPUT]

Name stdout

@michiel
michiel / collect.sh
Created August 16, 2017 22:21
expect + ssh + scp with password to collect data from a list of servers
#!/bin/bash
PASSWORD="password"
USERNAME="username"
SSHPORT=22
@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;

Transparent Git Encryption

This document has been modified from its [original format][m1], which was written by Ning Shang (geek@cerias.net). It has been updated and reformatted into a [Markdown][m2] document by [Woody Gilk][m3] and [republished][m4].

Description

When working with a remote git repository which is hosted on a third-party storage server, data confidentiality sometimes becomes

@michiel
michiel / clock.sh
Created June 6, 2018 05:47
terminal world clock
#!/bin/bash
function clock() {
clear
TZ=US/Pacific date "+LA : %Y/%m/%d %a — %I:%M %p"
TZ=US/Eastern date "+New York : %Y/%m/%d %a — %I:%M %p"
TZ=Europe/Amsterdam date "+Amsterdam : %Y/%m/%d %a — %I:%M %p"
TZ=Asia/Bangkok date "+Bangkok : %Y/%m/%d %a — %I:%M %p"
TZ=Japan date "+Tokyo : %Y/%m/%d %a — %I:%M %p"
TZ=Australia/Melbourne date "+Melbourne : %Y/%m/%d %a — %I:%M %p"
@michiel
michiel / arch.dot
Created July 29, 2021 23:23
Architecture concerns (graphviz)
digraph architecture {
layout="neato";
node [fontname = "Helvetica"];
edge [fontname = "Helvetica"]; splines=true;
overlap=false;
nodesep="0.2";
ranksep="0.4";
label="Architecture";
labelloc="t";
fontname="Lato";