Skip to content

Instantly share code, notes, and snippets.

View Luzifer's full-sized avatar

Knut Ahlers Luzifer

View GitHub Profile
@Luzifer
Luzifer / github_status.py
Created August 15, 2013 16:58
Script to output last 5 status messages from status.gitub.com to be used for example with GeekTool or similar
#!/usr/bin/env python
import urllib, json
from dateutil.parser import parse
from textwrap import wrap
messages_url = 'https://status.github.com/api/messages.json'
data = json.loads(urllib.urlopen(messages_url).read())
status_char = {
@Luzifer
Luzifer / gist:6131936
Created August 1, 2013 14:32
Moving files named in schema %Y%m%d_something.pdf into folders %Y/%m/filename.pdf
for i in *.pdf; do I=$(echo $i | sed "s/^\(\([0-9]\{4\}\)\([0-9]\{2\}\).*\)$/\2\/\3\/\1/"); mkdir -p $(dirname $I) && mv $i $I; done
@Luzifer
Luzifer / gist:5656916
Created May 27, 2013 12:53
How to retrieve a list of MacPorts packages installed by user usable for installing on new mac
$ port installed requested 2>/dev/null | grep @ | sed "s/^ *\([a-zA-Z0-9-]*\).*/\1/" | sort | uniq | xargs
@Luzifer
Luzifer / scan2preview.sh
Last active December 17, 2015 05:39
Imports an image from a twain sane scanner, converts to jpg and saves it to the desktop of the current user, then opens it with Preview.app
#!/bin/bash
targetfile="scan_$( date +"%Y-%m-%d_%H-%M-%S" ).jpg"
# Get image from scanner
scanimage --format=tiff --resolution 300 > /tmp/scan.tiff
# TODO: Search for correct error message (need it to be thrown by scanimage before implementing)
if [ $(grep -q 'cups' /tmp/scan.tiff ) ]; then
# Calculate size of file without error message
@Luzifer
Luzifer / fetch_timelapse_hootoo.py
Created April 12, 2013 12:39
This script is designed to work with an HooToo IPCamera you can for example buy at http://goo.gl/V3H2W - It will take one picture every n seconds and store them named by current time in one folder so you later on can assemble them into a timelapse video.
#!/usr/bin/env python
# This script is designed to work with an HooToo IPCamera you can for example
# buy at http://goo.gl/V3H2W - It will take one picture every n seconds and
# store them named by current time in one folder so you later on can assemble
# them into a timelapse video.
#
# Copyright (C) 2013 Knut Ahlers <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@Luzifer
Luzifer / gist:5228528
Created March 23, 2013 17:17
Little sniplet to render a "DRAFT" text into every page of a TeX document. Use before \begin{document}
\usepackage{eso-pic}
\makeatletter
\AddToShipoutPicture{%
\setlength{\@tempdimb}{.5\paperwidth}%
\setlength{\@tempdimc}{.5\paperheight}%
\setlength{\unitlength}{1pt}%
\put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){%
\makebox(0,0){\rotatebox{45}{\textcolor[gray]{0.85}%
{\fontsize{4cm}{4cm}\selectfont{DRAFT}}}}%
@Luzifer
Luzifer / gist:4189557
Created December 2, 2012 16:20
Delicious Bookmark Link incl. automatic description setting
javascript:(function(){d=function(){m=document.getElementsByName('description');if(m.length>0){return%20m[0].getAttribute('content');}%20else%20return%20'';};f='http://delicious.com/save?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&v=5&';a=function(){if(!window.open(f+'noui=1&jump=doclose','deliciousuiv5','location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()
@Luzifer
Luzifer / dropbox_tex_worker.py
Created November 12, 2012 17:48
Upstart daemon to autogenerate LaTeX documents added to Dropbox
import os, time, subprocess, sys
from datetime import datetime
my_path = os.path.realpath(__file__)
my_version = os.path.getmtime(my_path)
startdir = '/home/luzifer/Dropbox/tex-convert'
gentex_command = '/home/luzifer/bin/gentex'
def log(string):
@Luzifer
Luzifer / dropbox_cam_cleanup.py
Created November 3, 2012 18:53
Tiny script to cleanup "Camera Uploads" folder on OSX / Linux into subfolders
#!/usr/bin/env python
import os
from time import time
from datetime import datetime
camfolder = os.path.expanduser('~/Dropbox/Camera Uploads')
for filename in os.listdir(camfolder):
# OSX folder icons are contained in this directory.
@Luzifer
Luzifer / exportstickies.py
Created September 17, 2012 12:21
Little python script to export your dashboard stickies to text only format to copy to another location
#!/usr/bin/env python
import json, subprocess, os, re, HTMLParser
exportcmd = 'plutil -convert json -o - %s' % os.path.expanduser('~/Library/Preferences/widget-com.apple.widget.stickies.plist')
out = json.loads(subprocess.check_output(exportcmd.split(' ')))
stickies = []
htmlparser = HTMLParser.HTMLParser()