Tools

#!/usr/bin/python
 
# Original Code
# <a href="http://github.com/turian/py80legsformat" title="http://github.com/turian/py80legsformat">http://github.com/turian/py80legsformat</a> by Joseph Turian
 
import csv
import hashlib
import os
import struct
import sys
import zipfile
from cStringIO import StringIO
from optparse import OptionParser
 
class EightyLegs:
    def __init__(self, filename):
        self.filename = filename
        self.directory = filename.split('.')[0]
 
    def read(self, file):
        assert(struct.calcsize("i")) == 4
 
        l = file.read(2*4)
        (classID, versionID) = struct.unpack("ii", l)
        assert (classID, versionID) == (218217067, 1)
 
        l = "not EOF"
        data = []
        l = file.read(1*4)
        while l != "":
            (URLSIZE,) = struct.unpack("i", l)
            url = file.read(URLSIZE).decode("utf-8")
            l = file.read(1*4)
            (DATASIZE,) = struct.unpack("i", l)
            data = str(file.read(DATASIZE))
            yield (url, data)
            l = file.read(1*4)
 
    def read_zip(self, file):
        zip = zipfile.ZipFile(file, 'r')
        for info in zip.infolist():
            fname = info.filename            
            if fname.endswith('.80'):
                data = zip.read(fname)
                for r in self.read(StringIO(data)):
                    yield r
 
    def parse(self):
        if not os.path.exists(self.directory):
            os.makedirs(self.directory)
 
        tsv = csv.writer(open("%s.tsv" % self.directory, 'w'), delimiter='\t', lineterminator='\n')
 
        if self.filename.endswith('.zip'):
            e = self.read_zip(open(self.filename))
        else:
            e = self.read(open(self.filename))
 
        for url, data in e:
            print url
            f = open("%s/%s.html" % (self.directory, hashlib.md5(url).hexdigest()), 'w')
            f.write(data)
            tsv.writerow([hashlib.md5(url).hexdigest(), url])
 
def main():
    usage = 'Usage: %prog -f 19970_20966_a_1.zip or %prog -f 19970_20966_a_1.80'
    parser = OptionParser(usage=usage)
    parser.add_option('-f', '--file', dest='filename', help='input file')
 
    (options, args) = parser.parse_args()
 
    if options.filename is None:
        parser.print_help()
        sys.exit(0)
 
    legs = EightyLegs(options.filename)
    legs.parse()
 
if __name__ == '__main__':
    main()

perl -ne 'm/^([^#][^\s=]+)\s*(=.*|)/ && printf("%-35s%s\n", $1, $2)' /etc/my.cnf

Ksplice allows system administrators to apply security patches to the Linux kernel without having to reboot. Ksplice takes as input a source code change in unified diff format and the kernel source code to be patched, and it applies the patch to the corresponding running kernel. The running kernel does not need to have been prepared in advance in any way.

A challenge I faced recently was "scaling up on demand" (without manual intervention). EC2 was the my platform of choice because I could write a small script to manage all my machines. EC2 being Xen based also allowed me to create custom images of my application servers.

  1. Hook into the load balancer's health monitor
  2. If the load goes over 70% launch a new ec2 instance
  3. If the load goes under 50% remove an instance

Example:

When a giant such as Microsoft initiates research projects on technology, it pretty clear that it’s going to be the future. I recently stumbled upon a page that talks about their research in the field of Wireless Mesh Networks. As it seems they have been at it for a while now.

Microsoft seems to have applied its “Embrace, Extend and Extinguish” ideology to this. Mesh Connectivity Layer (MCL) started its life as a version of the Dynamic Source Routing Protocol (DSR). DSR has been extensively modified to improve its behavior, most significantly to support link quality metrics.

Not to long ago I was looking out for a good open source project management software for a friend. He was using Basecamp, but did not like it, cause it was not free software and working for a organization which really pushes for free software, he was in the market looking for alternatives. This is when I stumbled on something called ActiveCollab.

For a long time I have been looking for a good application to store my notes. I used a neat Mac application by the name of MyNotes to keep track of my notes. I still think its a very good application, but the only shortcoming of this application is that it does not support Google Search :) Let me tell you this is not a bad thing.

I was hanging out with a friend from Yahoo today evening, and decided to publish some of my Google Hacks :) So here is one of them. This is a quick and dirty way to store notes with Google.

Syndicate content
Drupal theme by Kiwi Themes.