Skip to content

Instantly share code, notes, and snippets.

@raphiz
raphiz / README.md
Last active January 26, 2016 12:21
Moodle HSR Autologin Raw

Autologin for https://moodle.hsr.ch/ with the power of userscripts.

Please note that you should from a security point of view store the username and password using the browsers built-in password manager! To do so, store the before installing these scripts and remove the highlighted two lines from moodle_autologin_2.js. Otherwise, replace the and values with your credentials.

@raphiz
raphiz / euklid.py
Created January 24, 2016 14:10
A quick & dirty implementation of the Euclidean algorithm in python
#!/usr/bin/env python
# coding=utf-8
from tabulate import tabulate
a = 180
b = 101
def euklid(x_p, y_p, q_p=None, r_p=None, u_p=None, s_p=None, v_p=None, t_p=None, result=None):
@raphiz
raphiz / pdf_remove_watermark.py
Created September 28, 2015 19:52
PDF watermark removal
from PyPDF2 import PdfFileReader, PdfFileWriter
from PyPDF2.pdf import ContentStream
from PyPDF2.generic import TextStringObject, NameObject
from PyPDF2.utils import b_
wm_text = 'Persönliches Exemplar von'
replace_with = ''
# Load PDF into pyPDF
source = PdfFileReader(open('input.pdf', "rb"))
@raphiz
raphiz / deploy.sh
Last active August 29, 2015 14:25
FTP Deplozment Script
#!/usr/bin/env bash
# Abort if a command fails!
set -e
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ ! -n "$HOST" ];then
echo "missing option \"HOST\", aborting"
exit 1
@raphiz
raphiz / nsupdate.sh
Last active February 2, 2020 12:53
Update script for nsupdate.info (For Synology NAS systems)
#!/usr/bin/env sh
DOMAIN="domain.nsupdate.info"
TOKEN="MYTOKEN"
# Evaluate the current remote IP and the one that is currently registerd
CURRENT=$(curl -s https://ipv4.nsupdate.info/myip)
SAVED=$(python2 -c "import socket; print socket.gethostbyname('$DOMAIN')")
LOGFILE=$( cd "$( dirname "${0}" )" && pwd )/log.txt
TEMPFILE=$( cd "$( dirname "${0}" )" && pwd )/tmp
@raphiz
raphiz / deploy.sh
Created December 28, 2014 22:46
Easily deploy Composer Apps to a remote FTP server using curlftpfs, rsync and git
#!/usr/bin/env bash
# Requires: fuse, curlftpfs, rsync, git and composer
set -u
REPOSITORY="https://github.com/raphiz/php-raphael.li.git"
FTP_HOST="myhost.com"
FTP_USER="user"
FTP_PASS="secrit"
FTP_SUBFOLDER="httpdocs"
@raphiz
raphiz / android-backup-extractor.sh
Created December 28, 2014 21:56
Converts the contents of a .ab android backup file into a .tar archive
#!/usr/bin/env bash
#
# Converts the contents of a .ab android backup file into a .tar archive
#
# Usage: android-backup-extractor.sh SOURCE <DESTINATION>
#
# Requirements: dd, openssl
# License: MIT
# Autor: Raphael Zimmermann (http://raphael.li)
#
@raphiz
raphiz / synchronize_ftp.sh
Created November 12, 2014 22:24
Synchronize FTP server with a local directory (Linux)
#!/usr/bin/env bash
# Requires: curlftpfs, unison and fuse.
# Configuration:
MOUNTPOINT=/mnt/my_ftp_share/
LOCAL="/home/user/directory"
FTP_HOST="example.com"
FTP_USER="user"
FTP_PASS="secrit"