Skip to content

Instantly share code, notes, and snippets.

@ericlagergren
ericlagergren / spectre.c
Created January 4, 2018 03:57 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@ericlagergren
ericlagergren / stringscontext.go
Created May 2, 2016 05:09 — forked from mholt/stringscontext.go
Functions from the 'strings' package as template actions. Feel free to copy+paste into your project as a starting point.
// Functions from Go's strings package usable as template actions
// with text/template.
//
// This approach assumes you have some context type as a receiver,
// but if you just need the functions check out the FuncMap variant
// below.
//
// Commented functions are not deemed useful in template actions.
// Haven't actually used this, but this is one possible way of doing it.
// Another option is to fill a FuncMap with most of the strings package.
@ericlagergren
ericlagergren / InstallGo
Last active February 24, 2016 01:47 — forked from mohae/InstallGo
Installs the current release of Go
#!/bin/bash
#
# For more info see https://golang.org/doc/install.html, the instructions there are all
# that is needed to install Go.
#
# DO NOT RUN with sudo; Go should be installed under the user not root. Using sudo will
# cause problems.
set -euo pipefail
@ericlagergren
ericlagergren / latency.txt
Created October 25, 2015 08:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
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
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
$ ssh -A vm
$ git config --global url."[email protected]:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "[email protected]:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!
<!-- ios standalone web app -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- ios status bar appearance, options: black, black-translucent -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!-- ios icon, just one size because ios will scale it, remove "-precomposed" if you want ios to add effects -->
<link href="[email protected]" sizes="144x144" rel="apple-touch-icon-precomposed">
<!-- ios startup images -->