Skip to content

Instantly share code, notes, and snippets.

View Luzifer's full-sized avatar

Knut Ahlers Luzifer

View GitHub Profile
@Luzifer
Luzifer / pullrequests.py
Last active August 29, 2015 13:57
Little script to list open pull-requests on GitHub across all repositories
#!/usr/bin/env python
# Get an own access token from https://github.com/settings/applications
# and put it here to get this script working
access_token = 'nopeyoucantgetmine'
import urllib, urllib2, json, os, sys
rows, columns = [int(elem) for elem in os.popen('stty size', 'r').read().split()]
@Luzifer
Luzifer / README.md
Created September 23, 2014 12:48
issh - CLI script to access an EC2 instance via SSH using the instance ID

Luzifer / issh

I was tired to search the IP for an autoscaling or ELB instance in the EC2 instances table, copy and then SSH to it so I wrote a small script to help me with this. The goal was to provide just the instance ID (and if required also username and port) to ssh into the instance.

Requirements

  • Python 2 (Tested 2.7)
  • boto

Demo

@Luzifer
Luzifer / gist:1008413
Created June 4, 2011 22:10
This script cleans a directory containing debian packages up leaving only the three newest versions. Package filenames must follow "<package>_<version>-<build>.deb" format and package name must not contain underscores.
#!/usr/bin/env python
import sys, os
def extract_pkg(package_file):
result = {}
package_file = package_file.replace('.deb', '')
(result['package'], tmp) = package_file.split('_')
(tmp, result['build']) = tmp.split('-')
tmp = tmp.split('.')
@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 / 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 / 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 / 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 / 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 <knut@ahlers.me>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@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 / 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