Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Hamann michitux

View GitHub Profile
@michitux
michitux / rotate.patch
Created Apr 27, 2020
Patch to rotate resized images in DokuWiki based on EXIF orientation
View rotate.patch
--- a/inc/media.php 2018-12-28 17:46:14.000000000 +0100
+++ b/inc/media.php 2018-08-20 21:05:55.000000000 +0200
@@ -1084,6 +1084,15 @@
$w = (int) $info[0];
$h = (int) $info[1];
+ if ($meta) {
+ $orientation = media_getTag('Orientation', $meta);
+ if ($orientation == 3 || $orientation == 6) {
+ $tmp = $h;
@michitux
michitux / Profiling-deleted-nodes.ipynb
Created Jul 24, 2017
Example for broken NetworKit profiles with deleted nodes
View Profiling-deleted-nodes.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@michitux
michitux / export-git-patches.sh
Last active Sep 27, 2021
Export a series of git commits into patches.
View export-git-patches.sh
# Inspired by http://blog.worldofcoding.com/2013/03/formatting-git-patches-for-partially.html
# This calls git log to get a list of commits that affect a certain file pattern and then exports each of them into a file
# If the exported commits shall be limited to these files, another pathspec could be added in the second git log call.
# The code is split into several lines to make it more readable, but all ";" are there such that all line breaks could be removed.
c=0;
git log --oneline --reverse -- your/pathspec.* |cut -d' ' -f1 | while read a;
do
c=$[c+1];
@michitux
michitux / anotherTest.pyx
Last active Oct 22, 2019
Simple example that shows a compilation problem with Cython (see error.log for the error message), fixedTest.pyx shows a workaround. anotherTest.pyx is another failing example.
View anotherTest.pyx
# This file also fails to compile with error error: redefinition of ‘std::vector<int, std::allocator<int> > __pyx_convert_vector_from_py_int(PyObject*)’. Note that it only fails when I have another definition without the fused type.
from libcpp.vector cimport vector
cdef extern from "test.h":
cdef cppclass _TestClassInt "TestClass<int>":
vector[double] toDouble(const vector[int] &items) except +
cdef cppclass _TestClassChar "TestClass<char>":
vector[double] toDouble(const vector[char] &items) except +
@michitux
michitux / indexer.patch
Created Apr 8, 2013
Backported GIF output fix (https://github.com/splitbrain/dokuwiki/commit/25cfdf73de200b6ae57a47960bc3100e4aba3c7b) for DokuWiki 2012-01-25b "Angua" both as patch and as the resulting file lib/exe/indexer.php
View indexer.patch
diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php
index 95e2af0..9edd8be 100644
--- a/lib/exe/indexer.php
+++ b/lib/exe/indexer.php
@@ -16,15 +16,16 @@ if(!defined('NL')) define('NL',"\n");
// check if user abort worked, if yes send output early
$defer = !@ignore_user_abort() || $conf['broken_iua'];
-if(!$defer){
+$output = isset($_REQUEST['debug']) && $conf['allowdebug'];
@michitux
michitux / iexec
Created Mar 1, 2013
Simple script for executing a command whenever a file in the current directory (or a subdirectory of it) that matches a certain expression (using grep) is changed. The script uses inotifywait (from inotify-tools), i.e. it waits efficiently using inotify. The rationale for watching the whole directory is that editors like VIM work with temporary …
View iexec
#!/bin/bash
command="$1"
expression="$2"
$command
inotifywait -r -m --format '%f' -e close_write "$PWD" | while read file; do
if echo "$file" | grep "$expression"; then
$command
@michitux
michitux / s9y2blogger.php
Created Sep 16, 2012
PHP script to generate a Blogger Import file from a Serendipity database, it does some automatic conversion of utf-8 using iconv
View s9y2blogger.php
<?php
class s9y2blogger {
private $database = NULL;
private $errors = array();
private $curEntry = array(); // current entry of the parser
private $inPublished = false;
public function __construct() {
@michitux
michitux / arte_download.rb
Created Feb 16, 2011
Simple script for downloading Arte videos. Use at your own risk (and respect the copyright of Arte), it requires rtmpdump.
View arte_download.rb
#!/usr/bin/ruby
require 'net/http'
require 'cgi'
require 'rexml/document'
require 'optparse'
require 'time'
options = {
:lang => 'de',
@michitux
michitux / goQR.js
Created Jul 26, 2010
Bookmarklet for quickly creating QR-codes from URLs using QR-Server
View goQR.js
/* This bookmarklet tries to find the first selected link and opens the QR code. When no link is selected the current URL is used. */
javascript:(function(){%20function%20openqr(url){window.open('http://api.qrserver.com/v1/create-qr-code/?data='+encodeURIComponent(url)+'&size=700x700&qzone=6');}%20var%20selected,dl,i;%20dl%20=%20document.links;%20if%20(window.getSelection%20&&%20window.getSelection().containsNode)%20{%20/*%20mozilla%20*/%20for(i=0;%20i<dl.length;%20++i)%20{%20if%20(window.getSelection().containsNode(dl[i],%20true))%20{%20selected%20=%20true;%20openqr(dl[i].href);%20break;%20}%20}%20}%20if%20(!selected)%20{%20/*ie,%20or%20mozilla%20with%20no%20links%20selected%20*/%20openqr(document.URL);%20}%20})();
/* This bookmarklet uses the current URL. On some pages the above bookmarklet doesn't work/always uses an unwanted URL. If you experience this issue or don't need selected links try this one. */
javascript:(function(){window.open('http://api.qrserver.com/v1/create-qr-code/?data='+encodeURICompo
@michitux
michitux / JamendoOGGDownloadBookmarklet.js
Last active Dec 26, 2016
Bookmarklet for downloading the normally hidden OGG version of any Jamendo album.
View JamendoOGGDownloadBookmarklet.js
javascript:window.location.href='http://www.jamendo.com/get/album/list/album/archiverestricted/redirect/?ids='+/\/list\/a(\d+)/.exec(window.location.href)[1]+'&are=ogg3';void(0)