Skip to content

Instantly share code, notes, and snippets.

@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 / generate_html_chars.sh
Created April 15, 2016 08:50
Creates a list of HTML Chars
echo "<ul>" > chars.html
for i in {0..65536}
do
echo "<li>&#38;#$i; = &#$i;<li>" >> chars.html
done
echo "</ul>" >> chars.html
@mperlet
mperlet / watch_web_change.sh
Created April 15, 2016 09:48
My Hue-Light blinks if tracking-info (hermes, dhl) changes!
url="http://www.google.com"
if [ ! -e tmp ]; then
curl --silent "$url" > tmp
fi
for i in {0..259200}
do
curl --silent "$url" | diff tmp -
if [ $? -ne 0 ]; then
echo "It Changes!"
curl --silent "$url" > tmp
@mperlet
mperlet / simple_template.py
Created April 26, 2016 13:08
Replace $$key$$ with value in file test.txt with: *python simple_template.py test.txt key=value*
import sys
content = open(sys.argv[1], 'r').read()
for k,v in map(lambda kv:kv.split("="),sys.argv[2:]):
content = content.replace('$$%s$$' % k, '%s' % v)
print(content)
for i in *.svg; inkscape -A $(echo $(basename -s .svg $i).pdf) $i;
python -c "import sys;import os;import time;map(lambda x:os.system('clear;' + ' '.join(sys.argv[1:]))==time.sleep(1), xrange(0,99999999))" date
@mperlet
mperlet / T.py
Created June 12, 2016 11:15
simple python stopwatch
import time
class T(object):
def __init__(self):
self.now = time.time()
def end(self):
print(time.time() - self.now)
@mperlet
mperlet / Benchmark.sh
Created September 8, 2016 07:58
Shellscript to run a cmd n-times and write time-output to txt file
#!/bin/bash
if [ -z "${TIMES}" ];
then
echo "TIMES is unset, use export TIMES=10";
TIMES=10
else
echo "TIMES is set to $TIMES";
fi