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

@browny
browny / simple_socket_example.c
Last active July 12, 2024 23:58
simple socket example in C
/* --- Usage --- */
g++ server.c -o server
g++ client.c -o client
./server
./client 127.0.0.1
/* --- server.c --- */
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active July 14, 2024 15:27
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@neauoire
neauoire / gist:200d97396805dda71154
Last active September 12, 2021 01:01
Pico8 Cube
-- 3D CUBE
-- BY ALICEFFEKT
angle = 0
function _update()
angle += 2
if angle > 360 then
angle = 0
end
// motion_add(dir, spd):
vx += spd * cos(dir);
vy -= spd * sin(dir);
// setting speed to spd:
var current_speed;
current_speed = sqrt(vx*vx + vy*vy);
vx *= spd / current_speed;
@angusjf
angusjf / countryFlagsNamesAndDialCodes.json
Last active October 19, 2023 22:33
Country Emoji Flags, Names and Dial Codes JSON Mapping
{
"ad": {
"flag": "🇦🇩",
"name": "Andorra",
"dialCode": "+376"
},
"ae": {
"flag": "🇦🇪",
"name": "United Arab Emirates",
"dialCode": "+971"
@OrionReed
OrionReed / dom3d.js
Last active July 18, 2024 03:49
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯