Skip to content

Instantly share code, notes, and snippets.

@mperlet
mperlet / show_uptime.sh
Last active December 26, 2015 03:19
Shows System Uptime
function show_ut {
last -F $USER |
grep ":0 .* :0" |
sed 's/\s\s*/ /g' |
cut -d" " -f4-15 |
grep $(LANG=en_US date "+%b") |
grep -v "(00:00)"
asd=$(last -F $USER |
grep ":0 .* :0" |
@mperlet
mperlet / copylinks.js
Created October 23, 2013 17:30
Copy-Links-To-Textarea
@mperlet
mperlet / slapsens.sh
Last active December 30, 2015 19:09
execute commands if microphone input >= the level variable
#!/bin/bash
level=$1
i=0
while true;
do
l_value=$(rec -n stat trim 0 .5 2>&1 | awk '/^RMS amplitude/ { printf $3 }';)
is_loud=$(echo $l_value | awk -v lev="$level" '{ if ($0 >= lev) printf "1"; else printf "0" }')
@mperlet
mperlet / fickr.py
Last active January 4, 2016 08:49
Python-Script that downloads all public flickr-photos from a user
from pyquery import PyQuery as pq
import sys, os, re, unicodedata
def slugify(value):
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = re.sub('[^\w\s-]', '', value).strip().lower()
return re.sub('[-\s]+', '-', value)
url = u'http://www.flickr.com/photos/'
@mperlet
mperlet / mover.sh
Created March 16, 2014 16:33
moves files //> mvr *
function mvr() {
spath="/MEDIASHARE/Serien/"
select d in $spath*/; do
test -n "$d" && break;
echo ">>> Invalid Selection";
done
mv "$@" "$d"
ls
}
@mperlet
mperlet / last.py
Last active August 29, 2015 14:02
last.py
import commands
import datetime
import time
import sys
user = commands.getoutput('echo $USER')
last = commands.getoutput('last -F $USER | grep ":0 .* :0" | sed "s/\s\s*/ /g" | grep -v "(00:00)"').split('\n')
last = [x.replace('%s :0 :0 ' % user, '') for x in last]
@mperlet
mperlet / django_list_to_queryset.py
Created June 26, 2014 13:54
Converts a list to a django queryset
def list_to_queryset(model_list):
if len(model_list) > 0:
return model_list[0].__class__.objects.filter(
pk__in=[obj.pk for obj in model_list])
else:
return []
from dropbox import client, rest, session
import os,sys
#Const
APP_KEY = ''
APP_SECRET = ''
ACC_KEY = ''
ACC_SECRET = ''
ACCESS_TYPE = 'dropbox'
folder_to_sync = '/'
@mperlet
mperlet / link_parser.py
Created July 18, 2014 08:53
>python link_parser.py <url> <jquery_selector>
@mperlet
mperlet / picraf.sh
Created August 28, 2014 06:36
Picraf ist ein kleines Shell-Script welches mit 2 optionalen Parametern ein Zeitraffer Video erstellt. Verwendet wird fswebcam und ffmpeg.
#!/bin/bash
if [[ "$1" == "" ]]; then
to=1440
else
to=$1
fi
if [[ "$2" == "" ]]; then
waitsek=60
else