Skip to content

Instantly share code, notes, and snippets.

View kpsychas's full-sized avatar

Konstantinos Psychas kpsychas

View GitHub Profile
@oyvindio
oyvindio / ProfileResultHandler.py
Created October 7, 2010 12:50
pstats to png call graph
import sys
from gprof2dot import gprof2dot
import pygraphviz as pgv
import os.path
PRUNE = True
DEFAULT_NODE_TRESHOLD = 0.5
DEFAULT_EDGE_TRESHOLD = 0.1
if __name__ == '__main__':
@indexzero
indexzero / readme-outline.md
Created November 14, 2011 08:26
A quick outline of a README.md

README.md Outline

  • Header and a Brief description (should match package.json)
  • Example (if applicable)
  • Motivation (if applicable)
  • API Documentation: This will likely vary considerably from library to library.
  • Installation
  • Tests
  • Contributors
  • License
@tausen
tausen / gist:1517302
Created December 24, 2011 13:02
MATLAB fancy plotting
%% FANCY PLOTTING %%
% Code by Mathias Tausen, 2011 %
% Contact: mathias.tausen@gmail.com %
% Version: beta 0.5 rev1, 191211 %
%----------------------------------------------------------%
% Eases the process of plotting data with MATLAB %
% %
% How to use: %
% - Specify the data files in the files cell, syntax: %
% files = {'file1';'file2';'file3'}; %
@jassinm
jassinm / pyprofling
Created March 21, 2012 19:29
python profiling
python -m cProfile -o rep.prof <script.py>
python -c 'import pstats; p=pstats.Stats('rep.prof'); p.sort_stats('cumulative').print stats(10)'
@jboner
jboner / latency.txt
Last active July 6, 2024 23:38
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
@arvearve
arvearve / gist:4158578
Created November 28, 2012 02:01
Mathematics: What do grad students in math do all day?

Mathematics: What do grad students in math do all day?

by Yasha Berchenko-Kogan

A lot of math grad school is reading books and papers and trying to understand what's going on. The difficulty is that reading math is not like reading a mystery thriller, and it's not even like reading a history book or a New York Times article.

The main issue is that, by the time you get to the frontiers of math, the words to describe the concepts don't really exist yet. Communicating these ideas is a bit like trying to explain a vacuum cleaner to someone who has never seen one, except you're only allowed to use words that are four letters long or shorter.

What can you say?

@durden
durden / dump_stats.py
Created December 12, 2012 23:02
Dump Python pstats file to stdout sorted by cumulative stat
if __name__ == "__main__":
import sys
import pstats
stats = pstats.Stats(sys.argv[1])
stats.strip_dirs()
stats.sort_stats('cumulative')
stats.print_stats()
@damianavila
damianavila / remove_output.py
Created April 3, 2013 22:05
Remove output from IPython notebook from the command line (dev version 1.0)
"""
Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ]
Modified from remove_output by Minrk
"""
import sys
import io
import os
from IPython.nbformat.current import read, write
@aras-p
aras-p / preprocessor_fun.h
Last active June 21, 2024 12:20
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,
@atsuya046
atsuya046 / strategy.py
Created January 21, 2014 04:47
GoF design pattern with Python. - Strategy
# http://stackoverflow.com/questions/963965/how-is-this-strategy-pattern
# -written-in-python-the-sample-in-wikipedia
"""
In most of other languages Strategy pattern is implemented via creating some
base strategy interface/abstract class and subclassing it with a number of
concrete strategies (as we can see at
http://en.wikipedia.org/wiki/Strategy_pattern), however Python supports
higher-order functions and allows us to have only one class and inject
functions into it's instances, as shown in this example.
"""