Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathias Perlet mperlet

View GitHub Profile
@mperlet
mperlet / show_uptime.sh
Last active Dec 26, 2015
Shows System Uptime
View show_uptime.sh
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 Oct 23, 2013
Copy-Links-To-Textarea
View copylinks.js
@mperlet
mperlet / slapsens.sh
Last active Dec 30, 2015
execute commands if microphone input >= the level variable
View slapsens.sh
#!/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 Jan 4, 2016
Python-Script that downloads all public flickr-photos from a user
View fickr.py
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 Mar 16, 2014
moves files //> mvr *
View mover.sh
function mvr() {
spath="/MEDIASHARE/Serien/"
select d in $spath*/; do
test -n "$d" && break;
echo ">>> Invalid Selection";
done
mv "$@" "$d"
ls
}
View 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 Jun 26, 2014
Converts a list to a django queryset
View django_list_to_queryset.py
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 []
View droppi2.py
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 Jul 18, 2014
>python link_parser.py <url> <jquery_selector>
View link_parser.py
@mperlet
mperlet / picraf.sh
Created Aug 28, 2014
Picraf ist ein kleines Shell-Script welches mit 2 optionalen Parametern ein Zeitraffer Video erstellt. Verwendet wird fswebcam und ffmpeg.
View picraf.sh
#!/bin/bash
if [[ "$1" == "" ]]; then
to=1440
else
to=$1
fi
if [[ "$2" == "" ]]; then
waitsek=60
else
You can’t perform that action at this time.