Skip to content

Instantly share code, notes, and snippets.

@amosr
amosr / read.c
Created November 18, 2015 02:27
12 instruction case-insensitive string equality (for reading booleans)
int read_bool (char *p)
{
static const uint64_t true_mask = 0x00000000ffffffff;
static const uint64_t true_bits = 0x0000000065757274;
static const uint64_t false_mask = 0x000000ffffffffff;
static const uint64_t false_bits = 0x00000065736c6166;
static const uint64_t to_lower = 0x2020202020202020;
uint64_t next8 = *(uint64_t *)p | to_lower;
@non
non / answer.md
Last active February 28, 2025 11:46
answer @nuttycom

What is the appeal of dynamically-typed languages?

Kris Nuttycombe asks:

I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?

I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.

I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.

@marcwebbie
marcwebbie / compile_emacs.sh
Last active August 4, 2017 06:17
Compile emacs 24 on Red Hat 6 workstations
# install needed libraries
sudo yum install texinfo libXpm-devel giflib-devel libtiff-devel libotf-devel
# compile autoconf
cd /tmp
wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.bz2
tar xjvf autoconf-2.68.tar.bz2
cd autoconf-2.68/
./configure && make && sudo make install
@jboner
jboner / latency.txt
Last active April 19, 2025 21:29
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