Skip to content

Instantly share code, notes, and snippets.

View proceduralia's full-sized avatar

Pierluca D'Oro proceduralia

View GitHub Profile
@jboner
jboner / latency.txt
Last active March 7, 2025 20: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
@tckmn
tckmn / gist:8078a34e3287ec32dadf
Created November 8, 2014 16:31
(Almost) all Nethack messages, more gooder version (much better)
pager.c:344 pline("Cannot open data file!")
pager.c:467 pline("? Seek error on 'data' file!")
pager.c:482 pline("I don't have any information on those things.")
pager.c:578 pline("Please move the cursor to %s.", what_is_an_unknown_object)
pager.c:581 pline("Pick an object.")
pager.c:815 pline("%s", out_str)
pager.c:825 pline("I've never heard of such things.")
pager.c:865 pline("That is %s%s%s.", an(defsyms[trap_to_defsym(tt)].explanation), !trap->madeby_u ? "" : (tt == WEB) ? " woven" : <x> <x> <x> (tt == HOLE || tt == PIT) ? " dug" : " set", !trap->madeby_u ? "" : " by you")
pager.c:876 pline("I can't see a trap there.")
pager.c:891 pline("Cannot open data file!")
@vasanthk
vasanthk / System Design.md
Last active March 6, 2025 11:22
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
from keras.models import Sequential
from keras.layers import Dense
from keras.utils.io_utils import HDF5Matrix
import numpy as np
def create_dataset():
import h5py
X = np.random.randn(200,10).astype('float32')
y = np.random.randint(0, 2, size=(200,1))
f = h5py.File('test.h5', 'w')
@wangruohui
wangruohui / Install NVIDIA Driver and CUDA.md
Last active February 20, 2025 01:42
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS
@sbarratt
sbarratt / torch_jacobian.py
Created May 9, 2019 19:40
Get the jacobian of a vector-valued function that takes batch inputs, in pytorch.
def get_jacobian(net, x, noutputs):
x = x.squeeze()
n = x.size()[0]
x = x.repeat(noutputs, 1)
x.requires_grad_(True)
y = net(x)
y.backward(torch.eye(noutputs))
return x.grad.data
@kmhofmann
kmhofmann / installing_nvidia_driver_cuda_cudnn_linux.md
Last active January 10, 2025 22:30
Installing the NVIDIA driver, CUDA and cuDNN on Linux

Installing the NVIDIA driver, CUDA and cuDNN on Linux (Ubuntu 20.04)

This is a companion piece to my instructions on building TensorFlow from source. In particular, the aim is to install the following pieces of software

on an Ubuntu Linux system, in particular Ubuntu 20.04.

@manuel-delverme
manuel-delverme / jaxpr_graph.py
Last active August 4, 2021 13:52 — forked from niklasschmitz/jaxpr_graph.py
visualizing jaxprs
import jax
from jax import core
from graphviz import Digraph
import itertools
styles = {
'const': dict(style='filled', color='goldenrod1'),
'invar': dict(color='mediumspringgreen', style='filled'),
'outvar': dict(style='filled,dashed', fillcolor='indianred1', color='black'),
@montasaurus
montasaurus / llmc.sh
Last active February 18, 2025 21:43
AI Shell Command Generator
llmc() {
local system_prompt='Output a command that I can run in a ZSH terminal on macOS to accomplish the following task. Try to make the command self-documenting, using the long version of flags where possible. Output the command first enclosed in a "```zsh" codeblock followed by a concise explanation of how it accomplishes it.'
local temp_file=$(mktemp)
local capturing=true
local command_buffer=""
local first_line=true
local cleaned_up=false # Flag to indicate whether cleanup has been run
cleanup() {
# Only run cleanup if it hasn't been done yet