Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephan Zimmer zimmerst

  • BWH Hotel Group AB
  • Stockholm
View GitHub Profile
@zimmerst
zimmerst / shortenAuthors
Last active Apr 29, 2021
used to shorten *bibtex* files; parses a bibtex library and replaces excessive number of authors with 'others', leading to the typical *et al* behavior. All credit goes to the creators of bibtexparser :)
View shortenAuthors
# author: stephan zimmer
# license: GPL
# date: 2018-01-27
# comment: script to shorten long (automatic) bibliographies to shorter names.
# requirement: https://bibtexparser.readthedocs.io
# usage: python shortenAuthors.py <bibfile> <number of names>
from argparse import ArgumentParser
from bibtexparser import loads as bib_loads, dumps as bib_dumps
from bibtexparser.bwriter import BibTexWriter
@zimmerst
zimmerst / slack-svn-notify
Created May 31, 2017
notification script to keep track of svn changes
View slack-svn-notify
#!/RAID/USERS/zimmer/sw/python2.7/bin/python2.7
from slackweb import Slack
from tempfile import NamedTemporaryFile
from subprocess import Popen
from sys import exit as sys_exit
from time import ctime-hook.py
def svnlook(arg,repo,multiline=True):nw slack-commit-hook.py
command="svnlook {arg} {repo}".format(arg=arg,repo=repo)
tmp_err = NamedTemporaryFile(dir="/tmp", delete=True)
View source_bash.py
#####
# @brief: example to show how one would emulate equivalent to source script.sh, creates env dump and updates internal dictionary
# @todo: python executable itself needs to be reloaded
#####
from subprocess import Popen, PIPE
from os.path import isfile
from os import environ
from ast import literal_eval
@zimmerst
zimmerst / removeOrphans.py
Created Jun 1, 2016
remove orphans & duplicates - but no removal yet.
View removeOrphans.py
from progressbar import ProgressBar, ETA, Percentage, Bar
widgets = [Percentage(), Bar(), ETA()]
from sys import exit as sys_exit
from DmpWorkflow.core.models import JobInstance, Job
from DmpWorkflow.core import db
db.connect()
all_jobs = Job.objects.all()
n_registered_instances = sum([JobInstance.objects.filter(job=j).count() for j in all_jobs])
View rootnotes.py
"""
Helper module for displaying ROOT canvases in ipython notebooks
Usage example:
# Save this file as rootnotes.py to your working directory.
import rootnotes
c1 = rootnotes.default_canvas()
fun1 = TF1( 'fun1', 'abs(sin(x)/x)', 0, 10)
c1.SetGridx()