Skip to content

Instantly share code, notes, and snippets.

@mrfratello
mrfratello / .hgignore
Created August 25, 2016 09:40
Mercurial: ignore files in a specific folder but not the folder itself
^some_folder/(?!\.keep).+$
@espeed
espeed / fbme.py
Last active May 20, 2019 09:36
Facebook Graph API Example in Python
# Facebook Graph API Example in Python
# by James Thornton, http://jamesthornton.com
# Facebook API Docs
# https://developers.facebook.com/docs/graph-api/using-graph-api#reading
# Get Your Facebook Access Token Here...
# https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=me
# Before running this script...
@davesque
davesque / profile.py
Created September 20, 2013 21:58
Simple profiling context manager
import cProfile
import contextlib
import os
@contextlib.contextmanager
def profile(filename='~/python.profile', *args, **kwargs):
profile = cProfile.Profile(*args, **kwargs)
profile.enable()
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@originell
originell / extract_exceptions.py
Created February 27, 2012 10:29
Python Traceback Extractor from text/log files.
"""
Extract unique Python-Exceptions with their Traceback from a log/text file.
Usage::
python extract_exceptions.py -f logfile.txt
Furthermore it supports excluding exceptions you don't want to have::
python extract_exceptions.py -f logfile.txt -e ValueError,AttributeError