Skip to content

Instantly share code, notes, and snippets.

View nothingmuch's full-sized avatar
🤔

Yuval Kogman nothingmuch

🤔
View GitHub Profile
@ryancdotorg
ryancdotorg / rsabd.py
Last active February 2, 2025 10:05
backdoored rsa key generation
#!/usr/bin/env python
import sys
import gmpy
import curve25519
from struct import pack
from hashlib import sha256
from binascii import hexlify, unhexlify
package main
import (
"fmt"
"math"
"os"
"sort"
"strings"
)
@jsl
jsl / gist:8668369
Created January 28, 2014 14:11
Running microKanren in Guile
; You need to load a library for the assp function to run the microKanren code in Guile:
(import (rnrs))
(load "microKanren.scm")
(load "miniKanren-wrappers.scm")
(load "microKanren-test-programs.scm")
((call/fresh (lambda (q) (== q 5))) empty-state)
; $3 = ((((#(0) . 5)) . 1))
@aras-p
aras-p / preprocessor_fun.h
Last active May 3, 2025 13:47
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@luke-jr
luke-jr / combined_and_debt_transactions.md
Created April 18, 2013 03:38
Combined and debt transactions

Terminology

Btransaction
blockchain transaction (a "normal" transaction)
Ctransaction
combined transaction (also a valid Btransaction)
Dtransaction
@jboner
jboner / latency.txt
Last active May 10, 2025 11:02
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