Skip to content

Instantly share code, notes, and snippets.

View Luzifer's full-sized avatar

Knut Ahlers Luzifer

View GitHub Profile
@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 / 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 / traveltime.py
Last active December 23, 2015 17:49
Need a quick overview how long you will need by car from geolocation xx.xxxx,yy.yyyy to xx.xxxx,yy.yyyy? Just ask: python traveltime.py xx.xxxx,yy.yyyy xx.xxxx,yy.yyyy
#!/usr/bin/env python
import urllib, json, sys
if len(sys.argv) < 3:
print 'Usage: %s <lat,lon> <lat,lon>' % sys.argv[0]
sys.exit(2)
url = 'http://maps.googleapis.com/maps/api/directions/json?origin=%s&destination=%s&sensor=false' % (sys.argv[1], sys.argv[2])
@Luzifer
Luzifer / collectWindows.applescript
Last active January 8, 2016 14:57
Collect OSX windows from not present screens to main
-- Example list of processes to ignore: {"xGestures"} or {"xGestures", "OtherApp", ...}
property processesToIgnore : {}
-- Get the size of the Display(s), only useful if there is one display
-- otherwise it will grab the total size of both displays
tell application "Finder"
set _b to bounds of window of desktop
set screen_width to item 3 of _b
set screen_height to item 4 of _b
end tell
@Luzifer
Luzifer / check_uberspace_balance.py
Last active August 5, 2018 20:01
Simple inofficial library to fetch Uberspace account data for monitoring money on account or whatever…
#!/usr/bin/env python2.7
from uberspace import *
import argparse, sys, math
ST_OK = 0
ST_WARN = 1
ST_CRIT = 2
ST_UNKN = 3
@Luzifer
Luzifer / sendmail.aug
Created December 29, 2013 17:32
Augeas lens to parse /etc/mail/sendmail.conf file
(*
Module: Sendmail
Parses simple key = "value" conffiles
Author: Knut Ahlers <[email protected]>
About: License
This file is licenced under the LGPL v2+, like the rest of Augeas.
*)
@Luzifer
Luzifer / check_reboot_required.py
Last active January 2, 2016 10:29
Simple Nagios check for NRPE / PeriodicNoise to check whether an Ubuntu server required reboot
#!/usr/bin/env python
import apt, os, re, sys, subprocess
if os.path.exists('/var/run/reboot-required'):
print 'reboot-required marker file exists'
sys.exit(1)
kernels = []
@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 / 001_usage.md
Last active August 21, 2021 18:13
Fish-Shell: Switch AWS environments

Fish-Shell: Switch AWS environments

How to use

  1. Set up the folder ~/.awsenv/ with the folder structure shown below
  2. Create a credentials.txt for every environment folder (see an example below)
  3. Ensure no other user than yourself can view those files
  4. Create the function set_aws in ~/.config/fish/functions/set_aws.fish (see an example below)
  5. Now load any environment using set_aws <environment> like set_aws private

File structure

@Luzifer
Luzifer / README.md
Last active May 13, 2016 10:29
A simple clone of the Dashing-Milkman widget which does not require API access to the API but uses the non-event iCalendar whose URL you can get on your dashboard.

Preview

Description

A simple clone of the Dashing-Milkman widget which does not require API access to the API but uses the non-event iCalendar whose URL you can get on your dashboard.

Dependencies