Skip to content

Instantly share code, notes, and snippets.

@jboner
jboner / latency.txt
Last active November 15, 2024 14:00
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
@heygarrett
heygarrett / vimrc
Last active September 6, 2019 07:02
Solarized: Night & Day
" Set colorscheme to solarized
colorscheme solarized
" Change the Solarized background to dark or light depending upon the time of
" day (5 refers to 5AM and 17 to 5PM). Change the background only if it is not
" already set to the value we want.
function! SetSolarizedBackground()
if strftime("%H") >= 5 && strftime("%H") < 17
if &background != 'light'
set background=light
@matthewmueller
matthewmueller / osx-for-hackers.sh
Last active October 16, 2024 08:37
OSX for Hackers (Mavericks/Yosemite)
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@mattmight
mattmight / lambda-reduce.rkt
Created December 4, 2014 15:32
A syntactic-reduction-based interpreter for the lambda-calculus
#lang racket
; A simple CBV syntactic reduction machine for the lamda-calculus.
; + numbers
; <exp> ::= <var>
; | <num>
; | (λ (<var>) <exp>)
; | (+ <exp> <exp>)
@gtebbutt
gtebbutt / gist:5e21f2e49592559f5043
Created December 19, 2014 14:17
Linear animation generator for Om & React
(defn animate-value
[start-val end-val duration]
(let [decrement? (< end-val start-val)
transmit-chan (chan)
cancel-chan (chan)
animation-interval 40 ;40 ms interval - 25fps
steps (/ duration animation-interval)
full-range (- start-val end-val)
per-step (util/abs (/ full-range steps))
state (atom start-val)
(def views
{:some-view SomeView
:another-view AnotherView})
(def factories
(map om/factory (vals views)))
(defui Router
static om/Ident
(ident [this {:keys [route]}]
@anandabits
anandabits / swift-responder-chain.swift
Last active March 1, 2022 23:45
A minimalist responder chain implemented in pure Swift
// Created by Matthew Johnson on 5/28/16.
// Copyright © 2016 Anandabits LLC. All rights reserved.
//
// This is a minimalist implementation of a responder chain in pure Swift.
//
// It is not intended to demonstrate the best way to
// implement event processing in Swift.
//
// The intent is to show how little code is necessary to acheive behavior
// similar to Cocoa's responder chain in pure Swift.
@akkartik
akkartik / main.lua
Last active December 24, 2023 14:50
Edit source code inside LÖVE with almost no constraints or limitations.
Slab = require 'Slab' -- idiomatic GUI: https://github.com/flamendless/Slab
-- default love.run from https://love2d.org/wiki/love.run with various callbacks wrapped in xpcall()
function love.run()
if love.load then love.load(love.arg.parseGameArguments(arg), arg) end
-- We don't want the first frame's dt to include time taken by love.load.
if love.timer then love.timer.step() end
local dt = 0