Skip to content

Instantly share code, notes, and snippets.

@jboner
jboner / latency.txt
Last active July 5, 2024 02:48
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
# This piece of code is a rebound of https://github.com/ForbesLindesay/curry
# Author: Kavin Yao <kavinyao@gmail.com>
# License: MIT
import inspect
def curry(func, num_params=-1):
"""Simple, unlimited curry.
The curried function is not called until desired number of arguments is passed.
Note: **kwarg is not supported
"""
@iani
iani / additive_synth
Last active June 21, 2019 02:03
Additive Synthesis Basics on SuperCollider
// One Sine:
{ SinOsc.ar(400, 0, 0.1) }.play;
// Two Sines:
(
{ SinOsc.ar(400, 0, 0.1) }.play;
{ SinOsc.ar(800, 0, 0.1) }.play;
)
// Two Sines added, in one synth:
@rbxbx
rbxbx / rakoff_quote.txt
Last active December 10, 2020 05:51
David Rakoff on terminating his relationship with his longtime therapist
Should you happen to be possessed of a certain verbal acuity coupled with a
relentless, hair-trigger humor and surface cheer spackling over a chronic
melancholia and loneliness – a grotesquely caricatured version of your deepest
Self which you trot out at the slightest provocation to endearing and glib
comic effect, thus rendering you the kind of fellow who is beloved by all yet
loved by none, all of it to distract, however fleetingly, from the cold and
dead-faced truth that with each passing year you face the unavoidable certainty
of a solitary future in which you will perish one day while vainly attempting
the Heimlich maneuver on yourself over the back of a kitchen chair – then this
confirmation that you have triumphed again and managed to gull yet another
@prakhar1989
prakhar1989 / richhickey.md
Last active November 8, 2023 17:19 — forked from stijlist/gist:bb932fb93e22fe6260b2
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

@polymeris
polymeris / lisp.lua
Created September 15, 2015 15:10
Toy Lisp interpreter in Lua / LPEG
local lpeg = require'lpeg'
local P, R, S = lpeg.P, lpeg.R, lpeg.S --patterns
local C, Ct = lpeg.C, lpeg.Ct --capture
local V = lpeg.V --variable
local parser = P {
'program', -- initial rule
program = Ct(V'sexpr' ^ 0),
wspace = S' \n\r\t' ^ 0,
atom = V'boolean' + V'integer' + V'string' + V'symbol',
{
var t, output;
t = PulseCount.ar(Impulse.ar(8000));
}.play
@Avaq
Avaq / combinators.js
Last active July 4, 2024 07:20
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@thejmazz
thejmazz / .babelrc
Created February 16, 2016 18:17
async/await with webpack+babel
{
"presets": ["es2015"],
"plugins": ["transform-async-to-generator"]
}
@nybblr
nybblr / 1-easy.js
Last active July 13, 2022 03:40
3 examples of using Async Generators and Async Iteration in JavaScript!
// Create a Promise that resolves after ms time
var timer = function(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
// Repeatedly generate a number starting
// from 0 after a random amount of time
var source = async function*() {