Skip to content

Instantly share code, notes, and snippets.

@wimleers
wimleers / dps-seedbox1-rsync.sh
Created November 29, 2010 12:01
Script that syncs a directory tree recursively to another server, to a single target ("flat") directory, using rsync.
#!/bin/sh
LOGFILE=/data/logs/dps-seedbox1-rsync/$(date "+%Y-%m").log
EXCLUDES_COMMON="--exclude lost+found --exclude .ssh --exclude .bash_history"
EXCLUDES_MORE="--exclude other --exclude BASE --exclude applications"
# Append a header first, so we know when this script was run.
date "+%n%n=====%nSyncing DriverPacks to seedbox1 at %Y-%m-%d %H:%M:%S" > $LOGFILE
# Sync the DriverPacks themselves to the seedbox' 'data' folder. However, we
@wimleers
wimleers / gist:716034
Created November 25, 2010 22:40
Set this error handler before erroneous code and you'll get a nice report of the exact error, including a brief stack trace. Simple & nice. Who knew. Stupid PHP.
function handler($errno, $errstr, $errfile, $errline) {
throw new Exception($errstr, $errno);
}
set_error_handler('handler');
#-------------------------------------------------
#
# Project created by QtCreator 2010-11-20T18:00:03
#
#-------------------------------------------------
QT += core
QT -= gui
#include <QDateTime>
#include <QTime>
#include <QTextStream>
#define NUM_CALLS 1000
int main(int argc, char *argv[]) {
QTextStream cout(stdout);
QTime timer;
@wimleers
wimleers / opentracker.torrent.php
Created November 19, 2010 15:31
.torrent creator in PHP, for easier Drupal integration in the future.
<?php
/**
* Converts a specified structure into its bencoded form. Acceptable values
* include: integers, strings, arrays, and assoc. arrays.
* Note that associative arrays are encoded into dictionaries while
* non-associative arrays are encoded into lists.
*
* This was copied from http://drupal.org/project/bittorrent
@wimleers
wimleers / .htaccess
Created November 19, 2010 14:15
.htaccess/httpd.conf additions for .torrent support
application/x-bittorrent .torrent
@wimleers
wimleers / opentracker-reload-whitelist.sh
Created November 19, 2010 14:12
Send a signal to opentracker to reload its whitelist
#!/bin/sh
kill -s HUP `pidof opentracker`
@wimleers
wimleers / gist:706420
Created November 19, 2010 11:52
OpenTracker stats
http://tracker.driverpacks.net:6969/stats?mode=tpbs&format=ben
-> per torrent: hash (ben-encoded), complete, downloaded, incomplete
http://tracker.driverpacks.net:6969/stats?mode=tpbs&format=txt
-> per torrent: hash, seeders, leechers
http://tracker.driverpacks.net:6969/stats?mode=statedump
-> per torrent: hash, base (time in minutes since epoch when the torrent last had >0 peers, *60 = unix timestamp), downloaded
@wimleers
wimleers / gist:702387
Created November 16, 2010 19:55
How to convert from a custom date format into a UTC string using Qt.
QDateTime timeConvertor;
QString customDateString = "14-Nov-2010 05:27:03 +0100";
QString dateTime = customDateString.left(20);
int timezoneOffset = customDateString.right(5).left(3).toInt();
timeConvertor = QDateTime::fromString(dateTime, "dd-MMM-yyyy HH:mm:ss");
// Mark this QDateTime as one with a certain offset from UTC, and set that
// offset.
timeConvertor.setTimeSpec(Qt::OffsetFromUTC);
@wimleers
wimleers / .htaccess
Created November 2, 2010 13:29
Improved .htaccess for Drupal.
# Disable the server signature.
ServerSignature Off
# No-www.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]