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 / clean.py
Last active June 10, 2021 14:31
Python: Clean files from a directory. Currently used for LaTeX projects.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Licensed under the MIT License (Expat) @ https://www.tldrlegal.com/l/mit
"""
A one-function module to clean up files in folders.
Args:
-q, --quiet Suppresses output to stdout.
@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 / Rename-Me-To-Match-Your-PS1-File
Last active May 26, 2023 11:18
Generic .bat file to launch .ps1 file with same name in same directory. Example: You have "start.ps1" to do something. Download this Gist and save as "start.bat". The latter will launch "start.ps1" by double-clicking.
@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 / 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 / disable-mouse-accel.sh
Last active April 28, 2016 08:04
Script to disable the mouse acceleration on Ubuntu (and probably other distributions).
#!/usr/bin/env bash
################################################################################
# Description #
# Script to disable the mouse acceleration on Ubuntu (and probably other #
# distributions). #
# #
# Author #
# Jonas Gröger <jonas.groeger@gmail.com> #
# #
@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 / gen-ubuntu-sources-list.py
Created June 16, 2015 09:16
Generates '/etc/apt/sources.list' compatible lists for Ubuntu releases
#!/usr/bin/env python3
import argparse
import getpass
import os
import time
import sys
KNOWN_CODENAMES = ['lucid', 'precise', 'trusty', 'utopic', 'vivid', 'wily']