Skip to content

Instantly share code, notes, and snippets.

View jepio's full-sized avatar
🏠
Working from home

Jeremi Piotrowski jepio

🏠
Working from home
View GitHub Profile
@jepio
jepio / pop.sh
Created May 9, 2014 17:40
Print documents at GSI, pass printer number and filename. Needs a gsi host defined in ssh config.
#!/bin/bash
# copies a file to the gsi lx-pool,
# prints it and then removes it.
#
if [ "$#" -eq 2 ]; then
scp $2 gsi:$2
ssh gsi "pop -p$1 $2 2>&1 ; rm $2" > /tmp/log
cat /tmp/log && rm /tmp/log
else
@jepio
jepio / skippy.sh
Created May 9, 2014 18:22
Turns skippy-xd on and off. Bind to a keyboard shortcut for quick execution.
#!/usr/bin/env bash
ps -C skippy-xd &> /dev/null && pkill skippy-xd || skippy-xd
@jepio
jepio / plot.py
Last active August 29, 2015 14:01
Plot a file quickly using PyROOT.
#!/usr/bin/env python2
from ROOT import TGraph, gPad
filename = raw_input("Filename: ")
plot = TGraph(filename)
title = filename.split('.')[0]
plot.Draw()
plot.SetTitle(title)
gPad.Print(title + ".pdf")
@jepio
jepio / .vimrc
Last active August 29, 2015 14:01
My .vimrc settings.
let g:pathogen_disabled = []
call add(g:pathogen_disabled, 'cpp-enhanced')
call add(g:pathogen_disabled, 'cpp')
execute pathogen#infect()
"" Shows command as it is being entered
set showcmd
set t_Co=256
colorscheme badwolf
syntax on
@jepio
jepio / list-inst.sh
Last active August 29, 2015 14:01
A shell script to find out what's hogging all your disk space in gentoo. Requires gentoolkit but everyone has that already anyway...
#!/usr/bin/env bash
# print a size sorted list
# of all programs installed
#
## equery s '*' | sed 's/(\|)/ /g' | sort -n -k 9 | gawk '{printf("%s %.3gMB\n",$1,$9/1048576)}'
# this version is much faster:
qsize -asm | sed 's/,//g' | sort -n -k 6 | awk '{printf "%dMB %s\n",$6,$1}'
@jepio
jepio / Property.py
Created May 17, 2014 22:57
An example that shows more or less how to use the property decorator in python.
class Example(object):
def __init__(self, x=None, y=None):
self._x = x
self._y = y
@property
def x(self):
return self._x
@jepio
jepio / qsort.py
Last active August 29, 2015 14:01
A 'quick' implementation of the recursive quicksort.
""" Two python implementations of the quicksort algorithm."""
__all__ = ["sort_np", "sort_pure"]
import numpy as np
def sort_np(array):
""" For numpy arrays, with masking. """
if len(array) <= 1:
return array
pivot = array[0]
@jepio
jepio / cuda.py
Last active August 29, 2015 14:01
Shows how CUDA memory addressing could look for a block of (dimx, dimy) threads.
from __future__ import print_function
import sys
if len(sys.argv) == 1:
dimx, dimy = 4, 3
elif len(sys.argv) == 3:
dimx, dimy = [int(var) for var in sys.argv[1:3]]
else:
sys.exit('Wrong amount of parameters')
@jepio
jepio / whymask.sh
Last active August 29, 2015 14:02
A function to discover why a package is masked in portage on gentoo. Source: http://blogs.gentoo.org/news/2014/06/02/gentoo-monthly-newsletter-may-2014/#Tip_of_the_month
#!/usr/bin/env bash
whymask() {
find /usr/portage/profiles/ -name '*.mask' -exec \
awk -vRS= "/${*/\//.}/ {
print \" \" FILENAME \":\", \"\n\" \"\n\" \$0 \"\n\"
}" {} + | less
}
whymask $1
@jepio
jepio / geant4.sh
Last active August 29, 2015 14:02
A list of variables needed to get geant4 working properly in gentoo. Especially the qt4 stuff took a long time to figure out/find.
# Define geant4 env. variables
source /usr/share/Geant4-9.6.2/geant4make/geant4make.sh
echo "Geant4 Set"
# Define additional variables used by geant4, but that are different in gentoo
export QTMOC="/usr/bin/moc-qt4"
export QTFLAGS="-I/usr/include/qt4 -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL"
export QTLIBS="-L/usr/lib/qt4 -lQtCore -lQtGui"
export GLQTLIBS="-L/usr/lib/qt4 -lQtCore -lQtGui -lQtOpenGL"
echo "QT Set"