Skip to content

Instantly share code, notes, and snippets.

View mitliagkas's full-sized avatar

Ioannis Mitliagkas mitliagkas

View GitHub Profile
@mitliagkas
mitliagkas / truncate.py
Last active August 29, 2015 14:01
Truncate vector x, only keeping the s elements of largest magnitude.
part = np.argpartition(abs(x),len(x)-s,axis=0)
x[part[:-s]] = 0
@mitliagkas
mitliagkas / yannisDefinitions.tex
Created May 29, 2014 23:43
Common latex Definitions
\newcommand{\theHalgorithm}{\arabic{algorithm}}
%\newtheorem{theorem}{Theorem}
%\newtheorem{definition}[theorem]{Definition}
%\newtheorem{assumption}[theorem]{Assumption}
%\newtheorem{proposition}[theorem]{Proposition}
%\newtheorem{lemma}[theorem]{Lemma}
%\newtheorem{corollary}[theorem]{Corollary}
@mitliagkas
mitliagkas / yannisPackages.tex
Created May 29, 2014 23:44
Commonly included latex packages
% Typesetting
%\usepackage[margin=1in]{geometry}
%\usepackage{fullpage}
\usepackage{verbatim}
% Fonts and stuff
%\usepackage{times}
%\usepackage{soul}
\usepackage{color}
%\usepackage[usenames,dvipsnames]{color}
@mitliagkas
mitliagkas / list-attributes.py
Created August 5, 2014 21:06
List all non-method object attributes along with their values
import inspect
for p in dir(sc):
if p[0]=='_':
continue
if inspect.ismethod(sc.__getattribute__(p)):
continue
print p, sc.__getattribute__(p)
print
@mitliagkas
mitliagkas / pyspark-vector-accumulator.py
Created August 6, 2014 05:46
PySpark Vector Accumulator Class
# Taken almost verbatim from PySpark's doctest
from pyspark.accumulators import AccumulatorParam
class VectorAccumulatorParam(AccumulatorParam):
def zero(self, value):
return [0.0] * len(value)
def addInPlace(self, val1, val2):
for i in xrange(len(val1)):
val1[i] += val2[i]
return val1
xnew = sc.accumulator([0.0]*p, VectorAccumulatorParam())
@mitliagkas
mitliagkas / evernoteWebClipperiPad
Created August 18, 2014 22:30
Javascript bookmark for iPad Evernote web clipper functionality
javascript:(function()%7BEN_CLIP_HOST='http://www.evernote.com';try%7Bvar%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=EN_CLIP_HOST+'/public/bookmarkClipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')%5B0%5D.appendChild(x);%7Dcatch(e)%7Blocation.href=EN_CLIP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);%7D%7D)();
@mitliagkas
mitliagkas / .screenrc
Last active July 14, 2021 00:14 — forked from alexras/.screenrc
# Screen Options ##
shell bash # Tell screen your default shell
startup_message off # Turn off start message
defscrollback = 5000
shelltitle '$ |bash' # Dynamic window titled for running program
msgwait 1 # Set messages timeout to one second
nethack on # Turn on nethack error messages
backtick 0 0 0 whoami # Set "%0`" to equal the output of "whoami"
#escape ^Oo
@mitliagkas
mitliagkas / .vimrc
Created August 28, 2014 21:18
Vim configuration
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
@mitliagkas
mitliagkas / ipyMatplotlib
Created September 2, 2014 20:49
iPython Inline Vector Graphics Plotting with Matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
@mitliagkas
mitliagkas / sshforwarding.sh
Last active August 29, 2015 14:06
SSH tunnel
ssh -N -L localhost:[localport]:[remotelisteninghostname]:[remoteport] -p [remotesshport] [remoteuser]@[remotehost]