Skip to content

Instantly share code, notes, and snippets.

View lenards's full-sized avatar

Andrew Lenards lenards

  • Tucson, AZ
View GitHub Profile
@jboner
jboner / latency.txt
Last active May 18, 2024 15:58
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
@artgillespie
artgillespie / rmws
Created November 24, 2011 20:52
Remove trailing whitespace from all source files under the current dir
#!/bin/sh
#
# Removes trailing whitespace from all source files in the current directory and its children.
# Note the `-i .bak` switch to sed. This will create a backup copy alongside any modified files
# like `Somefile.cpp.bak` Simply remove the `.bak` argument to `-i` to prevent the backup
# files from being generated
#
/usr/bin/find . -type f -and \( -name '*.m' -or -name '*.h' -or -name '*.mm' -or -name '*.cpp' -or -name '*.c' \) -and -print0 | xargs -0 sed -i .bak -E "s/[[:space:]]+$//"
@wrunk
wrunk / jinja2_file_less.py
Last active September 19, 2023 15:05
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@myano
myano / cs.py
Created June 30, 2011 01:25
Quick example of ncurses in Python!
#!/usr/bin/env python
import curses
import curses.textpad
import time
stdscr = curses.initscr()
#curses.noecho()
#curses.echo()
@ChillyBwoy
ChillyBwoy / cookie.js
Created May 26, 2011 00:35
Cookie functions for underscore.js