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
@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:
@michiel
michiel / pagination_example.sql
Created April 8, 2018 12:48 — forked from ssokolow/pagination_example.sql
Reasonably efficient pagination without OFFSET (SQLite version)
-- Reasonably efficient pagination without OFFSET
-- SQLite version (Adapted from MS SQL syntax)
-- Source: http://www.phpbuilder.com/board/showpost.php?p=10376515&postcount=6
SELECT foo, bar, baz, quux FROM table
WHERE oid NOT IN ( SELECT oid FROM table
ORDER BY title ASC LIMIT 50 )
ORDER BY title ASC LIMIT 10
@michiel
michiel / .block
Last active November 16, 2017 02:11 — forked from mbostock/.block
Minimap Demo
license: gpl-3.0
@michiel
michiel / rust-update-docs-hook
Created September 21, 2017 22:34 — forked from Stebalien/rust-update-docs-hook
A post-commit hook to update a rust project's gh-pages.
#!/bin/bash
set -e
[[ "$(git symbolic-ref --short HEAD)" == "master" ]] || exit 0
msg() {
echo "> $@"
}
dir="$(pwd)"
tmp="$(mktemp -d)"
@michiel
michiel / katharsis-custom-serializer.js
Created December 12, 2016 15:06 — forked from sivakumar-kailasam/katharsis-custom-serializer.js
Ember data serializer changes to work with katharsis, thanks to @dfalling
import DS from 'ember-data';
export default DS.JSONAPISerializer.extend({
// This returns the key as-is to the model, instead of converting between a dasherized JSONAPI and a camelCased JS model.
keyForAttribute(key) {
return key;
},
keyForRelationship(key) {
return key;
@michiel
michiel / pandoc.css
Created December 1, 2016 07:53 — forked from killercup/pandoc.css
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
@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 / 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