Skip to content

Instantly share code, notes, and snippets.

@cgreer
cgreer / bag_of_little_bootstraps.py
Last active April 13, 2025 14:06
Bag of Little Bootstraps (w/ example usage)
import random
from typing import (
List,
Dict,
Callable,
Union,
)
import numpy
@yegappan
yegappan / VimScriptForPythonDevelopers.MD
Last active October 12, 2025 01:36
Vim script for Python Developers

Vim Script for Python Developers

This is a guide to Vim Script development for Python developers. Sample code for the various expressions, statements, functions and programming constructs is shown in both Python and Vim Script. This is not intended to be a tutorial for developing Vim scripts. It is assumed that the reader is familiar with Python programming.

For an introduction to Vim Script development, refer to usr_41.txt, eval.txt and Learn Vimscript the Hard Way

For a guide similar to this one for JavaScript developers, refer to Vim Script for the JavaScripter

This guide only describes the programming constructs that are present in both Python and Vim. The constructs that are unique to Vim (e.g. autocommands, [key-mapping](https://vimhelp.org/map.txt.html#key-m

@cgreer
cgreer / run_from_cmd_line.py
Last active December 23, 2015 03:38
Quickly run a function in a script from the command line without option parsing (useful for pipeline creation)
'''
USAGE:
Let's say you have a "find_words_with_letter" function (not method) in a script called "script_name.py"...
def find_words_with_letter(fileName, letter = "g"):
#fxn code here
...you can then call the function in the script from the command line - function name 1st argument, function args follow.
@ColtonProvias
ColtonProvias / gist:5079405
Created March 4, 2013 02:05
S3 uploader for Python 3
"""
S3 Uploader for Python 3
Colton J. Provias
Usage:
f = open('sample.png', 'rb')
contents = f.read()
response, url = upload_to_s3('AWSKEY', 'AWSSECRET', 'mybucket', 'image.png', contents, 'image/png')
"""
@jboner
jboner / latency.txt
Last active November 14, 2025 11:14
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
@ngs
ngs / table.mkdn
Created May 24, 2012 16:04
Unicode character table

A

Description Entity Preview
A With Acute, Latin Capital Letter Á Á
A With Acute, Latin Small Letter á á
A With Breve, Latin Small Letter ă ă
A With Caron, Latin Small Letter ǎ ǎ
A With Circumflex, Latin Capital Letter  Â
A With Circumflex, Latin Small Letter â â