Skip to content

Instantly share code, notes, and snippets.

@jboner
jboner / latency.txt
Last active June 10, 2024 11:57
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
@dmeliza
dmeliza / scalebars.py
Last active February 7, 2023 00:33
matplotlib: add scale bars to axes
# -*- coding: utf-8 -*-
# -*- mode: python -*-
# Adapted from mpl_toolkits.axes_grid1
# LICENSE: Python Software Foundation (http://docs.python.org/license.html)
from matplotlib.offsetbox import AnchoredOffsetbox
class AnchoredScaleBar(AnchoredOffsetbox):
def __init__(self, transform, sizex=0, sizey=0, labelx=None, labely=None, loc=4,
pad=0.1, borderpad=0.1, sep=2, prop=None, barcolor="black", barwidth=None,
**kwargs):
@gizmaa
gizmaa / Plot_Examples.md
Last active June 10, 2024 02:44
Various Julia plotting examples using PyPlot
@carlobaldassi
carlobaldassi / XCompose_greek
Created February 12, 2014 08:15
Greek letters in .XCompose
<Multi_key> <space> <a> : "α" U03B1 # GREEK SMALL LETTER ALPHA
<Multi_key> <a> <space> : "α" U03B1 # GREEK SMALL LETTER ALPHA
<Multi_key> <space> <b> : "β" U03B2 # GREEK SMALL LETTER BETA
<Multi_key> <b> <space> : "β" U03B2 # GREEK SMALL LETTER BETA
<Multi_key> <space> <c> : "ξ" U03BE # GREEK SMALL LETTER XI
<Multi_key> <c> <space> : "ξ" U03BE # GREEK SMALL LETTER XI
<Multi_key> <space> <d> : "δ" U03B4 # GREEK SMALL LETTER DELTA
<Multi_key> <d> <space> : "δ" U03B4 # GREEK SMALL LETTER DELTA
<Multi_key> <space> <e> : "ε" U03B5 # GREEK SMALL LETTER EPSILON
<Multi_key> <e> <space> : "ε" U03B5 # GREEK SMALL LETTER EPSILON
@satra
satra / distcorr.py
Created October 16, 2014 15:40
Distance Correlation in Python
from scipy.spatial.distance import pdist, squareform
import numpy as np
from numbapro import jit, float32
def distcorr(X, Y):
""" Compute the distance correlation function
>>> a = [1,2,3,4,5]
>>> b = np.array([1,2,9,4,4])
@karpathy
karpathy / min-char-rnn.py
Last active June 9, 2024 20:26
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@dermotmcguire
dermotmcguire / A4 CSS page template.markdown
Created September 14, 2015 08:48
A4 CSS page template
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active June 10, 2024 04:09
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@gansanay
gansanay / hdf_vs_feather.ipynb
Last active June 26, 2023 12:25
Compare HDF5 and Feather performance (speed, file size) for storing / reading pandas dataframes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.