Skip to content

Instantly share code, notes, and snippets.

View mbirth's full-sized avatar
:shipit:
Hiding in the shadows…

Markus Birth mbirth

:shipit:
Hiding in the shadows…
  • London, UK
View GitHub Profile
@mbirth
mbirth / index.php
Created February 1, 2021 20:41
PHP proxy for AWStats.pl when your host doesn't allow cgi-bin or .pl scripts but PHP
<?php
# Put this in the same directory where AWStats' cgi-bin dir is!
$config = 'your.default.config';
$output = 'main';
$cmd = './awstats.pl';
# Mandatory parameter
@mbirth
mbirth / README.md
Created April 26, 2017 14:56
AES implementations in Python3, PHP and JavaScript

Python3: AES / Rijndael

Usually, you should use PyCrypto from the python-crypto package. But if you want to code in Python3, there's no fast hybrid((i.e. mostly C-code, partly Python-code)) implementation of such a library.

Using Google, you will most probably stumble on Bram Cohen's Rijndael implementation in pure Python. I took his code and made it Python3 ready by replacing all xrange() by range(), all divisions (/) by integer-divisions (//) and made the string.join() working. There were no more changes neccessary.

@mbirth
mbirth / tt2srt.py
Last active May 6, 2019 19:30 — forked from adammw/tt2srt.py
Timed Text Captions to SRT Subtitles converter script
#!/usr/bin/env python
# Usage: python tt2srt.py source.xml output.srt
# FROM: https://gist.github.com/adammw/915259
from xml.dom.minidom import parse
import sys
def fixTime(time):
# 00:00:00.000
return time.replace(".", ",")
#!/bin/bash
#Inspired by http://blog.neutrino.es/2012/git-copy-a-file-or-directory-from-another-repository-preserving-history/
#Copy a file or directory out of a git repository, preserving history!
#Creates DESTINATIONPATH with patches that can be applied with git am
#e.g.
#0001-Add-new-theme-Gum.patch
#0002-Add-syntax-highlighting-for-Gum-theme.patch
#0003-Gum-Fix-tag-URLs-not-being-slugified-and-therefore-b.patch
#0004-Gum-Add-Disqus-support.patch
#0005-Gum-Use-article-title-as-the-title-of-the-generated-.patch
@mbirth
mbirth / GetADUsersExcel.vba
Last active November 12, 2015 23:54
Queries the Active Directory (via LDAP) for users belonging to ExampleGroup or one of its subgroups. The resulting users are written into the first Excel sheet.
' Based on a VBA script of Jim Ward
Sub LDAPQueryDevices()
Dim grouppaths(500) As String
Dim groupnames(500) As String
Dim headers2 As Variant
headers2 = Array("GroupName", "Name", "Login", "DN", "Group1", "Group2")
Const xlAscending = 1
Const xlDescending = 2
@mbirth
mbirth / db-inno-files.php
Created July 12, 2013 09:53
This script will fetch a list of all InnoDB tables from MySQL and check if they are in separate files (as per innodb_file_per_table setting) or still in the ibdata1 file (which always grows, but never shrinks). So you can decide whether to do a cleanup (http://stackoverflow.com/questions/3927690/howto-clean-a-mysql-innodb-storage-engine) or not.
<?php
if (posix_getuid() != 0) {
echo 'Run as root!' . PHP_EOL;
exit(1);
}
$mysql_host = 'localhost';
$mysql_port = '3309';
$mysql_user = 'username';
@mbirth
mbirth / print_r_tree.php
Last active December 19, 2015 00:28
PHP Snippet to return a string like print_r($var, true) - but more readable and with JSON parsing
<?php
function print_r_tree(&$var, $level=0)
{
$result = '';
if (is_array($var) || is_object($var)) {
$result = gettype($var) . ' <span style="color: #aaa;">(' . count($var) . ' entries)</span>' . PHP_EOL;
foreach ($var as $key=>$value) {
$result .= str_repeat('|', $level) . '+<strong>' . $key . '</strong>: ' . print_r_tree($value, $level+1);
}