Skip to content

Instantly share code, notes, and snippets.

@jtai
jtai / parse-tcpdump-udp-port-53.php
Last active January 16, 2019 16:06
Quick and dirty script to parse output of /usr/sbin/tcpdump -vvv -s 0 -l port 53
<?php
// quick and dirty argument parsing
foreach ($argv as $arg) {
if ($arg == '-f') {
define('FOLLOW', true);
}
if ($arg == '-h') {
define('HISTOGRAM', true);
}
@jtai
jtai / openfire2prosody.php
Created November 14, 2011 10:21
Script to convert Openfire user export file to Prosody's file format
<?php
if ($argc < 3) {
die("Usage: openfire2prosody.php INPUT_XML OUTPUT_PATH\n");
}
$xml = simplexml_load_file($argv[1]);
foreach (array($argv[2], $argv[2] . '/accounts', $argv[2] . '/roster') as $path) {
if (!is_dir($path)) {
@jtai
jtai / gist:1362577
Created November 13, 2011 19:49
If there is more than one <HTML> opening tag, skip to the last one
--- pidgin-2.10.0.orig/libpurple/protocols/oscar/oscar.c.orig 2011-11-13 11:52:07.000000000 +0000
+++ pidgin-2.10.0/libpurple/protocols/oscar/oscar.c 2011-11-13 11:45:04.000000000 +0000
@@ -1605,6 +1605,21 @@
tmp = g_strdup(args->msg);
/*
+ * If there is more than one <HTML> opening tag, skip to the last one
+ * This cleans up garbage like: <HTML><BODY><HTML><BODY BGCOLOR="#ffffff"><FONT>message</FONT></BODY></HTML>
+ */
+ while (purple_markup_find_tag("html", tmp + 6, &start, &end, &attribs))