Skip to content

Instantly share code, notes, and snippets.

@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))
@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 / 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 / gearmand.spec.diff
Created January 19, 2012 01:50
Update gearmand.spec for Gearman 0.27
--- gearmand.spec 2012-01-18 20:02:44.184424387 -0500
+++ gearmand.spec 2012-01-18 20:42:24.221426555 -0500
@@ -22,8 +22,8 @@
%endif
Name: gearmand
-Version: 0.14
-Release: 3%{?dist}
+Version: 0.27
+Release: 1%{?dist}
@jtai
jtai / gearman.ini
Created January 19, 2012 18:24
RPM packaging for gearman 1.0.1 PECL extension based on IUS php53u-pecl-apc spec file
extension=gearman.so
@jtai
jtai / escape.js
Created February 8, 2012 21:58
Escape lucene special chars
string.replace(/[+\-!(){}\[\]^"~*?:\\]|&&|\bAND\b|\|\||\bOR\b/ig, ' ').replace(/\s+/g, ' ').trim();
@jtai
jtai / parser.php
Created March 27, 2012 03:53
Cache-Control header parser
<?php
class Parser
{
public function parse($string)
{
$this->string = trim($string);
$directives = array();
@jtai
jtai / Descriptors.java
Created April 17, 2013 23:44
Java program to print out open / max file descriptors
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.reflect.Method;
class Descriptors {
public static void main(String [ ] args) {
OperatingSystemMXBean osMxBean = ManagementFactory.getOperatingSystemMXBean();
try {
Method getMaxFileDescriptorCountField = osMxBean.getClass().getDeclaredMethod("getMaxFileDescriptorCount");
Method getOpenFileDescriptorCountField = osMxBean.getClass().getDeclaredMethod("getOpenFileDescriptorCount");
@jtai
jtai / elasticsearch.log
Created June 8, 2013 18:45
Elasticsearch log output when nodes are running different JVM versions
[2013-04-24 00:59:53,539][WARN ][action.index ] [hostname] Failed to perform index on replica [logstash-2013.04.24][3]
org.elasticsearch.transport.RemoteTransportException: Failed to deserialize exception response from stream
Caused by: org.elasticsearch.transport.TransportSerializationException: Failed to deserialize exception response from stream
at org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:171)
at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:125)
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:787)
at org.elasticsear
@jtai
jtai / elasticsearch.log
Created June 8, 2013 22:28
Elasticsearch log output when threadpool.index.queue_size is reached
[2013-04-28 19:52:08,944][WARN ][action.index ] [hostname] Failed to perform index on replica [logstash-2013.04.28][5]
org.elasticsearch.transport.RemoteTransportException: [otherhost][inet[/10.0.0.1:9300]][index/replica]
Caused by: org.elasticsearch.common.util.concurrent.EsRejectedExecutionException: rejected execution of [org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler]
at org.elasticsearch.common.util.concurrent.EsAbortPolicy.rejectedExecution(EsAbortPolicy.java:35)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:821)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1372)
at org.elasticsearch.transport.netty.MessageChannelHandler.handleRequest(MessageChannelHandler.java:212)
at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:111)
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleCh