Skip to content

Instantly share code, notes, and snippets.

View JonasGroeger's full-sized avatar
Working from home

Jonas Gröger JonasGroeger

Working from home
View GitHub Profile
JonasGroeger / Activate.ps1
Last active August 29, 2015 13:56
Very simple virtualenv activate.ps1 for Powershell in Windows. Save in your project directory and set WORKON_HOME environment variable to your virtual environment folder, i.e. C:\Users\Jonas\.venvs
View Activate.ps1
$workon_home_env__var_name = "WORKON_HOME"
$venv_file_name = ".venv"
$workon_home = $null
# Test if env-var exists
if(!(Test-Path Env:\$workon_home_env__var_name)) {
$Host.UI.WriteErrorLine("You must set the environment variable '" + $workon_home_env__var_name + "'. It must point to your virtual environment folder.")
JonasGroeger / Shutdown.bat
Last active August 29, 2015 13:59
Shows a dialog to shut down the computer in a specified time.
View Shutdown.bat
@echo off
REM Generic .bat file to launch .ps1 files.
REM Name the .bat file like the .ps1 file and you are done.
set this_file_no_extension=%~n0
set ps1_file=%this_file_no_extension%.ps1
JonasGroeger /
Created April 16, 2014 22:41
A decorator to serialize objects. Apply the decorator to the class.
# coding=utf-8
import json
__author__ = 'Jonas Gröger <>'
def jsonify(cls):
def to_json(obj, **kargs):
return json.dumps(obj, default=lambda o: o.__dict__, **kargs)
JonasGroeger / Clean-Temporary-Files.ps1
Last active August 29, 2015 14:01
Removes temporary LaTeX files. Can be customized to remove arbitrary files by extension or name.
View Clean-Temporary-Files.ps1
# ------------------------------------------------------------------------------
# Script: Clean-Temporary-Files.ps1
# Author: Jonas Gröger <>
# Date: 12.04.2014
# Keywords: LaTeX, Clean, Delete, Remove, Temporary, Files
# Comments: Removes temporary files created by LaTeX etc. You can tweak it by
# adding extensions or specific files.
# ------------------------------------------------------------------------------
JonasGroeger / brieffenster
Created February 12, 2015 23:49
Nur das Brieffenster. Kompilieren mit xelatex.
View brieffenster
[fontsize=12pt,%% Schriftgroesse
% Satzspiegel
paper=a4,%% Papierformat
enlargefirstpage=on,%% Erste Seite anders
pagenumber=headright,%% Seitenzahl oben mittig
% Layout
JonasGroeger / transfer.plugin.zsh
Last active August 29, 2015 14:23
ZSH plugin for (with clipboard function)
View transfer.plugin.zsh
# Defines transfer alias and provides easy command line file and folder sharing.
# Authors:
# Remco Verhoef <>
# Jonas Gröger <>
if (( ! $+commands[curl] )); then
return 1
JonasGroeger / logObjectAsJson with XStrea
Created May 29, 2012 21:09
How to print the field name and value of an arbitrary object.
View logObjectAsJson with XStrea
public static void logObjectAsJSON(String tag, Object o) {
// In order for this to work you need the XStream library located at
XStream x = new XStream(new Sun14ReflectionProvider(new FieldDictionary(new ImmutableFieldKeySorter())), new JsonHierarchicalStreamDriver());
Log.d(tag, x.toXML(o));
JonasGroeger / HTTPClient POST
Created May 31, 2012 20:38
HTTPPost request using the apache http client
View HTTPClient POST
// We are going to post to this url.
HttpPost post = new HttpPost("");
// We are going to use the apache httpclient
HttpClient client = new DefaultHttpClient();
// The request is going to have some parameters.
final HttpParams params = new BasicHttpParams();
// Set the redirecting parameter in params to false. This will make sure we dont follow redirects like 302 and the result we get from the server later is the actual one and not some follow up resource.
JonasGroeger / gist:2942552
Created June 16, 2012 21:32
Remove specific pages from pdf
View gist:2942552
// Use in.pdf, extract pages 1-5, 10-19 and 26-end and output in out.pdf
pdftk in.pdf cat 1-5 10-19 26-end output out.pdf
JonasGroeger / cantor.hs
Created June 22, 2012 16:31
Cantorsche Paarungsfunktion
View cantor.hs
module Cantor (