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 / settings.py
Created September 7, 2012 05:17
Django relative directories in settings.py
# coding=utf-8
# Django 1.4.1 settings for <project-name> project.
import os
PROJECT_DIR = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..'))
DATABASE = os.path.join(PROJECT_DIR, 'db', 'db.sqlite3')
DATABASES = {
'default': {
@JonasGroeger
JonasGroeger / sumatra.desktop
Created February 13, 2013 12:28
.desktop file for launching SumatraPDF with wine
[Desktop Entry]
Type=Application
Name=SumatraPDF
MimeType=application/pdf;
Exec=env WINEPREFIX="/home/jonas/.wine" wine start /ProgIDOpen SumatraPDF %f
NoDisplay=true
StartupNotify=true
Icon=518F_SumatraPDF.0
@JonasGroeger
JonasGroeger / pdfxchange.desktop
Created February 13, 2013 12:29
.desktop file for launching PDF-XChange Viewer with wine
[Desktop Entry]
Type=Application
Name=PDF-XChange Viewer
MimeType=application/pdf;
Exec=env WINEPREFIX="/home/jonas/.wine" wine start /ProgIDOpen PDF-XChangeViewer.1 %f
NoDisplay=true
StartupNotify=true
Icon=C055_PDFXCview.0
@JonasGroeger
JonasGroeger / doBackup.py
Last active December 13, 2015 23:59
A little script to backup your IOU Potts. Either pass the urls from command line or embed them in code at lines 45+. I made an example there. Works for iou.de and iou.ch
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'Jonas Gröger'
import argparse
import urllib.request
from urllib.error import URLError
from time import strftime
import os
@JonasGroeger
JonasGroeger / tarjan.py
Last active December 16, 2015 15:50
Tarjan's strongly connected components algorithm for python3
# From http://stackoverflow.com/a/6575693/488265
# By http://stackoverflow.com/users/577088/senderle
from itertools import chain
from collections import defaultdict
class Graph(object):
def __init__(self, edges, vertices=()):
edges = list(list(x) for x in edges)
self.edges = edges
@JonasGroeger
JonasGroeger / remote
Last active April 12, 2016 10:04
Script that allows makes a remote command seem like a local one. Useful for debugging.
#!/bin/bash
# This script executes arbitary commands on a remote server.
# Example: ./remote ls -alf
# If CMD is provided in the configuration section below
# Example (RMT_CMD="ls"): ./remote -alf
# If CMD is defined provided in the environment variables
# Example: RMT_CMD=ls ./remote -alf
@JonasGroeger
JonasGroeger / manman
Last active April 19, 2016 11:02
Jump to manpage flag
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage (i.e.): manman curl -u"
exit 3
fi
if [ $# -eq 1 ]; then
man "$1"
exit 0
@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> #
# #
#!/bin/bash
#
# This script copies the contents of the block below into a file.
# Useful for self-extracting configuration files or the like.
#
# Author: Jonas Gröger <jonas@huntun.de>
#
<<DATASECTION
quiet_update() {
DEBIAN_FRONTEND=noninteractive apt-get update -qq < /dev/null > /dev/null
}
quiet_install() {
DEBIAN_FRONTEND=noninteractive apt-get install -qq "$@" < /dev/null > /dev/null
}
quiet_install_no_recommends() {
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qq "$@" < /dev/null > /dev/null