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
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
$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.")
Exit
}
@JonasGroeger
JonasGroeger / Shutdown.bat
Last active August 29, 2015 13:59
Shows a dialog to shut down the computer in a specified time.
@echo off
setlocal
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
JonasGroeger / jsonify.py
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 <jonas.groeger@gmail.com>'
def jsonify(cls):
def to_json(obj, **kargs):
return json.dumps(obj, default=lambda o: o.__dict__, **kargs)
@JonasGroeger
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.
# ------------------------------------------------------------------------------
# Script: Clean-Temporary-Files.ps1
# Author: Jonas Gröger <jonas.groeger@gmail.com>
# 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.
# ------------------------------------------------------------------------------
Param(
@JonasGroeger
JonasGroeger / brieffenster
Created February 12, 2015 23:49
Nur das Brieffenster. Kompilieren mit xelatex.
\documentclass%%
%---------------------------------------------------------------------------
[fontsize=12pt,%% Schriftgroesse
%---------------------------------------------------------------------------
% Satzspiegel
paper=a4,%% Papierformat
enlargefirstpage=on,%% Erste Seite anders
pagenumber=headright,%% Seitenzahl oben mittig
%---------------------------------------------------------------------------
% Layout
@JonasGroeger
JonasGroeger / transfer.plugin.zsh
Last active August 29, 2015 14:23
ZSH plugin for transfer.sh (with clipboard function)
#
# Defines transfer alias and provides easy command line file and folder sharing.
#
# Authors:
# Remco Verhoef <remco@dutchcoders.io>
# Jonas Gröger <jonas.groeger@gmail.com>
#
if (( ! $+commands[curl] )); then
return 1
@JonasGroeger
JonasGroeger / logObjectAsJson with XStrea
Created May 29, 2012 21:09
How to print the field name and value of an arbitrary object.
public static void logObjectAsJSON(String tag, Object o) {
// In order for this to work you need the XStream library located at http://xstream.codehaus.org/
XStream x = new XStream(new Sun14ReflectionProvider(new FieldDictionary(new ImmutableFieldKeySorter())), new JsonHierarchicalStreamDriver());
Log.d(tag, x.toXML(o));
}
@JonasGroeger
JonasGroeger / HTTPClient POST
Created May 31, 2012 20:38
HTTPPost request using the apache http client
// We are going to post to this url.
HttpPost post = new HttpPost("http://example.com/login");
// 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
JonasGroeger / gist:2942552
Created June 16, 2012 21:32
Remove specific pages from pdf
// 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
JonasGroeger / cantor.hs
Created June 22, 2012 16:31
Cantorsche Paarungsfunktion
module Cantor (
c,
cx,
cy,
d,
h,
c_umkehr,
findmax)
where