Skip to content

Instantly share code, notes, and snippets.

@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)
@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 / 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
#include <stdio.h>
#include <iostream>
#include <unistd.h>
using namespace std;
class programming
{
private:
#include <cstdio>
#include <unistd.h>
#include <math.h>
#define L_value 20e-6
#define C_value 50e-12
#define dt 10e-10
#define SLEEP_MS 10
#define U_0 5.0
using std::printf;
#include <stdio.h>
#include <unistd.h>
#include <math.h>
#define L_value 20e-6
#define C_value 50e-12
#define dt 10e-10
#define SLEEP_MS 10
#define U_0 5.0
float glob_f = 0.0;
@mperlet
mperlet / c_function_pointer.c
Created October 20, 2015 13:18
Beispiel für functionpointer in c
#include <stdio.h>
#include <math.h>
double f1(double x) {return x*x*x;}
double xq(double x) {return x*x;}
double sin_func(double x) {return sin(x);}
double f(double begin, double end, double pieces, double (*fp)(double))
@mperlet
mperlet / change_none_unique_minidlna_title.sh
Created August 18, 2015 13:38
Problem: minidlna use the title from the metadata, sometimes its better when the title = the filename. This script change the title from "'HERE THE NONE UNIQUE TITLE'" to the filename.
for line in $(sqlite3 /root/minidlna/files.db "SELECT ID,PATH FROM DETAILS WHERE TITLE='HERE THE NONE UNIQUE TITLE';");
do
id=$(echo $line | cut -d"|" -f1);
path=$(echo $line | cut -d"|" -f2);
echo $id;
echo $path;
sqlite3 /root/minidlna/files.db "UPDATE DETAILS SET TITLE='$(basename $path)' WHERE ID=$id;";
done;
@mperlet
mperlet / add_photo_to_flickr_group.js
Created August 18, 2015 13:32
js:add photo to all your flickr groups. Import first jQuery and open your group list
$.each($('.album-selection-list').children(),function(index, element){ setTimeout(function(){$(element).click()}, index*1000);});
for s in $(ls *.{part1.rar,part01.rar}); do unrar x -pserienjunkies.org $s; done