Skip to content

Instantly share code, notes, and snippets.

@michiel
michiel / latency.txt
Created October 4, 2020 06:12 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
import svgwrite
import math
import json
class Pyramid:
def __init__(self, data, filename, height=500):
self.data = data
self.filename = filename
self.height = height
self.width = 2 * height
@michiel
michiel / weasel-words.json
Created July 30, 2020 10:50
List of weasel words
[
"all the time",
"as much as",
"believe",
"best practice",
"can",
"can be",
"claim",
"could",
"cutting-edge",
@michiel
michiel / cisq-model.puml
Created July 2, 2020 01:23
CISQ Quality Model
@startuml
skinparam linetype poly
rectangle "Quality Dimension" {
agent Reliability
agent Security
agent Efficiency
agent Maintainability
agent Size
@michiel
michiel / list-active-cloudfront-deployments.sh
Created April 8, 2020 03:27
List active cloudfront deployments with AWS CLI and jq
#!/bin/sh
AWS_PROFILE=my-profile
AWS_REGION=ap-southeast-2
aws --profile=$AWS_PROFILE \
--region=$AWS_REGION \
cloudfront list-distributions \
| jq '.DistributionList.Items[].Origins.Items[] | {Id: .Id, OriginPath: .OriginPath}'
@michiel
michiel / run-gource.sh
Created February 5, 2020 05:14
Decent HD gource settings
#!/bin/bash
# Using ffmpeg 2.8
SIZE=1920x1080
SPEED=.5
CAMERA_MODE=track
FRAMERATE=30
gource \
-r $FRAMERATE \
@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
// based on http://onais-m.blogspot.nl/2014/10/automatic-graph-layout-with-javascript.html
var jsp = jsPlumb.getInstance();
// construct dagre graph from JsPlumb graph
/* global dagre */
var g = new dagre.graphlib.Graph();
g.setGraph({});
g.setDefaultEdgeLabel(function() { return {}; });
$('.xnode').each(
@michiel
michiel / How I Do PlantUML.md
Created November 18, 2019 23:28 — forked from jerieljan/How I Do PlantUML.md
PlantUML with Style -- How I do PlantUML

I use PlantUML a lot. It's what I use for drawing all sorts of diagrams and it's handy because of its easy markup (once you get used to it) while making things easy to maintain as projects grow (thanks to version control)

This gist details how I do my PlantUML workspace in a project.

  • The idea is to keep a globals directory for all diagrams to follow (like the "stylesheet" below) to keep things consistent.
  • The stylesheet.iuml file keeps the use of colors consistent through use of basic FOREGROUND, BACKGROUND and ACCENT colors.
  • The style-presets.iuml file defines these colors so you can make "presets" or "themes" out of them.
  • As stated in the stylesheet.iuml, you'll need the Roboto Condensed and Inconsolata fonts for these to work properly.
@michiel
michiel / example.sql
Created August 17, 2019 12:17 — forked from jcushman/example.sql
Store JSON history with the fast-json-patch library and Postgresql triggers
-- Enable pl/v8:
CREATE EXTENSION plv8;
-- Create json history table:
CREATE TABLE json_history (id BIGSERIAL PRIMARY KEY, tstamp timestamp DEFAULT now(), table_name text, column_name text, target_id bigint, transform json);
-- Create test table:
CREATE TABLE test_json (id BIGSERIAL PRIMARY KEY, data JSON);
-- Enable history tracking on test_json.data: