Skip to content

Instantly share code, notes, and snippets.

View schmichael's full-sized avatar

Michael Schurter schmichael

View GitHub Profile
@schmichael
schmichael / bobserver.py
Created July 9, 2013 16:26
reverse dns lookup is stoopid
"""Usage: python bobserver.py"""
from SimpleHTTPServer import SimpleHTTPRequestHandler, BaseHTTPServer
class BobServer(BaseHTTPServer.HTTPServer):
def address_string(self):
return ':'.join(self.client_address[:2])
if __name__ == '__main__':
BaseHTTPServer.test(SimpleHTTPRequestHandler, BobServer)
package main
import (
"flag"
"log"
"crypto/hmac"
"crypto/rand"
"crypto/sha512"
"encoding/binary"
"net"
def lower(f):
x = []
for item in f():
x.append(item.lower())
return tuple(x)
@schmichael
schmichael / gist:7379338
Created November 8, 2013 23:32
Transparently compress and upload a file in golang
package main
import (
"bufio"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
@schmichael
schmichael / README.txt
Created December 2, 2013 04:19
My worst bug ever
What Happened
=============
On 4/1/2009, Michael instructed Alex to run "./manage.py syncdb" in order to
create a new table in the database. Unfortunately Michael had not removed
fixtures containing test data. When Alex ran syncdb, it quietly reloaded this
test data which overwrote existing data (based on primary keys).
The most devastating issue was that the serial sequences defined in
serialnum_serialprefix were overwritten. This caused serials created after
4/1 to overwrite existing hubs.
#!/bin/sh
curl -XDELETE "http://localhost:9200/test"
# Create a mapping with 2 nested fields
curl -XPOST "http://localhost:9200/test" -d'
{
"mappings" : {
"testtype" : {
Initializing FastSayer...
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/pmxbot/pmxbot/pmxbot/saysomething.py", line 86, in init_class
pmxbot.logging.Logger.store,
AttributeError: type object 'Logger' has no attribute 'store'
diff -r cc4ea1f34cc2 pmxbot/saysomething.py
--- a/pmxbot/saysomething.py Mon Oct 28 15:31:21 2013 -0400
+++ b/pmxbot/saysomething.py Tue Jan 07 22:18:09 2014 +0000
@@ -2,6 +2,7 @@
from __future__ import absolute_import
+import time
import threading
import random
19:46 < sfduder> ok, i think i found the issue... joda depends on an annotation from joda-convert but it's an optional dep
19:46 < sfduder> so when it gets shaded into the ES jar, that annotation doesn't make it over
19:46 < sfduder> which breaks scalaa