Skip to content

Instantly share code, notes, and snippets.

@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@awidegreen
awidegreen / vim_cheatsheet.md
Last active June 17, 2024 03:41
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@willurd
willurd / web-servers.md
Last active June 26, 2024 11:15
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@aras-p
aras-p / preprocessor_fun.h
Last active June 21, 2024 12:20
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@mikesmullin
mikesmullin / x86-assembly-notes.md
Last active June 19, 2024 16:42
Notes on x86-64 Assembly and Machine Code

Mike's x86-64 Assembly (ASM) Notes

Assembling Binary Machine Code

Operating Modes:

These determine the assumed/default size of instruction operands, and restricts which opcodes are available, and how they are used.

Modern operating systems, booted inside Real mode,

@fukuroder
fukuroder / wave_play_wasapi_shared.cpp
Last active July 8, 2021 06:38
wave file player (WASAPI shared mode)
/*
* wave_play_wasapi_shared.cpp
*
* Created by fukuroda (https://github.com/fukuroder)
*/
// windows API
#include <windows.h>
#include <audioclient.h>
#include <mmdeviceapi.h>
@Kartones
Kartones / postgres-cheatsheet.md
Last active June 26, 2024 18:01
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@hadess
hadess / 0001-mmc-sdhci-Disable-run-time-PM.patch
Last active January 7, 2023 18:30
Baytrail-T Wi-Fi stability patch
From df5bb0eca11e6ab072908b6e0d2e7d9e01d1eb84 Mon Sep 17 00:00:00 2001
From: Dong Aisheng <b29396@freescale.com>
Date: Wed, 24 Jun 2015 21:28:48 +0200
Subject: [PATCH] mmc: sdhci: get runtime pm when sdio irq is enabled
SDIO cards may need clock to send the card interrupt to host.
Thus, we get runtime pm when sdio irq is enabled to prevent the clock
resource is released and put it when sdio irq is disabled.
Signed-off-by: Dong Aisheng <b29396@freescale.com>
@t-mat
t-mat / minimal_vst2x_host.cpp
Last active June 7, 2024 06:22
WIN32 : Minimal VST 2.x host in C++11.
// Win32 : Minimal VST 2.x Synth host in C++11.
//
// This is a simplified version of the following project by hotwatermorning :
// A sample VST Host Application for C++ Advent Calendar 2013 5th day.
// https://github.com/hotwatermorning/VstHostDemo
//
// Usage :
// 1. Compile & Run this program.
// 2. Select your VST Synth DLL.
// 3. Press QWERTY, ZXCV, etc.
@samrat
samrat / sdl2_stbtt.c
Last active September 4, 2023 12:30
Drawing text into a bitmap w/ stb_truetype
#include "SDL.h"
/*
Compilation:
============
gcc -g --std=c99 -o sdl2_stbtt sdl2_stbtt.c `sdl2-config --cflags --libs` -lm
Usage:
======
./sdl2_stbtt /usr/share/fonts/TTF/LiberationMono-Regular.ttf