Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
from urllib2 import urlopen
import xml.etree.ElementTree as ET
from collections import OrderedDict
alias_uri = 'http://www.unicode.org/repos/cldr/trunk/common/bcp47/timezone.xml'
alias_root = ET.parse(urlopen(alias_uri)).getroot()
@scottmac
scottmac / gist:9013834
Created February 15, 2014 02:44
Fix gdft to load the preferred map rather than the last one in the font
diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c
index aa8e8d3..d09ede5 100644
--- a/ext/gd/libgd/gdft.c
+++ b/ext/gd/libgd/gdft.c
@@ -126,6 +126,7 @@ typedef struct
typedef struct
{
char *fontlist; /* key */
+ int preferred_map;
FT_Library *library;
@scottmac
scottmac / gist:3703863
Created September 12, 2012 02:32
elasticsearch 0.19.9 in a cluster with 0.19.4
[2012-09-11 19:30:02,680][WARN ][http.netty ] [Brain Drain] Caught exception while handling client http traffic, closing connection [id: 0x7ce0c4a3, /10.42.149.65:55007 => /10.60.187.73:9200]
java.lang.NoSuchMethodError: org.elasticsearch.common.compress.lzf.ChunkEncoder.<init>(I)V
at org.elasticsearch.common.compress.lzf.LZFCompressedStreamOutput.<init>(LZFCompressedStreamOutput.java:42)
at org.elasticsearch.common.compress.lzf.LZFCompressor.streamOutput(LZFCompressor.java:133)
at org.elasticsearch.common.io.stream.CachedStreamOutput$Entry.handles(CachedStreamOutput.java:72)
at org.elasticsearch.transport.support.TransportStreams.buildRequest(TransportStreams.java:111)
at org.elasticsearch.transport.netty.NettyTransport.sendRequest(NettyTransport.java:502)
at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:185)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.start(TransportShardReplicationOp
@scottmac
scottmac / gist:1886965
Created February 22, 2012 20:14
If PHP Was English
Index: Zend/zend_language_scanner.l
===================================================================
--- Zend/zend_language_scanner.l (revision 322482)
+++ Zend/zend_language_scanner.l (working copy)
@@ -916,7 +916,7 @@
break;
}
case '\\':
- case '$':
+ case '£':
CONNECTED(00000003)
depth=2 /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA
verify return:1
depth=1 /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance CA-3
verify return:1
depth=0 /C=US/ST=California/L=San Francisco/O=Milk Inc./OU=Oink/CN=*.oink.com
verify return:1
import java.util.List;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.nio.ByteBuffer;
import javax.smartcardio.*;
class ProxNRollReader {
byte[] GET_UID = {(byte)0xFF, (byte)0xCA, (byte)0x00,
(byte)0x00, (byte)0x00};
@scottmac
scottmac / serial.cpp
Created September 16, 2011 07:17
Find serial number of USB device on OS X.
#include <stdio.h>
#include <stdlib.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/usb/IOUSBLib.h>
#include <IOKit/hid/IOHIDKeys.h>
CFStringRef find_serial(int idVendor, int idProduct) {
CFMutableDictionaryRef matchingDictionary = IOServiceMatching(kIOUSBDeviceClassName);
@scottmac
scottmac / gist:1095554
Created July 20, 2011 18:22
OpenSSL Patch for Windows
diff --git a/crypto/rand/rand_win.c b/crypto/rand/rand_win.c
index 5d134e1..d74fa43 100644
--- a/crypto/rand/rand_win.c
+++ b/crypto/rand/rand_win.c
@@ -383,6 +383,11 @@ int RAND_poll(void)
if (advapi)
FreeLibrary(advapi);
+ /* If good then the Windows Crypto API worked, this does
+ the same as below so skip duplicating work */
<?php
$a = 1;
if ($a == ++$a) {
echo "they're equal? WTF??", PHP_EOL;
}
@scottmac
scottmac / elastic search query
Created March 2, 2011 23:48
{"error":"ArrayIndexOutOfBoundsException[null]","status":500}
curl -XPUT 'http://127.0.0.1:9200/test/post/2569686' -d '
{"node":32,"thread":91521,"title":"Allies in Blood \"A Universe of Change-Part 3\"","message":"\u201cGreetings Captain, Data, and young Crusher,\u201d Draal said in his less than normally booming voice. \u201cYou are no doubt aware of what is happening on Minbar.\u201d At this Picard\u2019s face darkened. \u201cYes,\u201d he whispered, \u201cI know about your probes.\u201d He waved off the looks of concern. \u201cI can hardly fault you since I have been doing the same thing,\u201d he said conspiratorially. \u201cMy people don\u2019t know and if they did right now they should bless you considering the situation. But I am getting away from purpose of you being here. Captain, without a living controller, the Great Machine will destroy itself in four days. My doctors, captors that they are, will not free me from this prison until I am well enough and the last time a controller was lost, war almost broke out. Commander Sheridan and Delenn, I beli