Skip to content

Instantly share code, notes, and snippets.

@bemasher
bemasher / ArcInfo - SVG.py
Created February 17, 2011 01:07
Converts ARC/INFO ungenerate cartographic boundary files to SVG. Currently requires tweaking for each file, not a universal system since the metadata isn't always the same format between different sets.
import sys, lxml
from lxml.builder import E
def parseMetadata(filename, select=1, records=6):
data = open(filename).read().strip().split('\n')
ids = map(lambda x: x.strip(), data[::records])
selected = map(lambda x: x.replace('"', '').strip(), data[select::records])
metaDict = {}
for x in xrange(len(ids)):
metaDict[ids[x]] = selected[x]
@bemasher
bemasher / Memory.py
Created May 30, 2011 00:48
Newegg System Memory analysis script.
import threading
import urllib, urllib2
import json, re
from Queue import Queue
class GetURL(threading.Thread):
def __init__(self, urlQueue, jsonQueue):
threading.Thread.__init__(self)
self.urlQueue = urlQueue
@bemasher
bemasher / Parenthesis.py
Created May 31, 2011 00:15
Determines if an lxml element is between parenthesis (in text) or is italic (html)
def isValidLink(node):
parenth_re = re.compile("\([^\)]*?{}[^\(]*?\)".format(node.text), re.S)
parent_text = ''.join(map(lambda x: (x.text or "") + (x.tail or ""), node.getparent().getchildren()))
return parenth_re.search(parent_text) is not None and node.getparent().tag != "i"
@bemasher
bemasher / BitGo.go
Created June 23, 2011 06:18
The beginning to a bittorrent tracker implemented in Google's Go.
package main
import (
"http"
"io"
"log"
)
func AnnounceHandler(w http.ResponseWriter, req *http.Request) {
req.ParseForm()
@bemasher
bemasher / config.yml
Created June 27, 2011 07:05
FlexGet configuration file.
presets:
tvshows:
deluge:
path: /home/username/tv shows/
main_file_only: yes
series:
- Archer
- Community
- Big Bang Theory
- Bones
@bemasher
bemasher / config.yml
Created June 28, 2011 07:30
FlexGet configuration file.
presets:
tvshows:
deluge:
path: /home/username/tv shows/
main_file_only: yes
series:
- Archer
- Community
- Big Bang Theory
- Bones
@bemasher
bemasher / config.yml
Created June 30, 2011 04:53
FlexGet configuration file (without deluge).
presets:
tvshows:
series:
- Archer
- Community
- Big Bang Theory
- Bones
- Castle
- Fairly Legal
- Game of Thrones
@bemasher
bemasher / SearchResult.json
Created August 3, 2011 03:54
Parsing JSON received from an http request in go.
{
"SubCategoryId": 65,
"HasHasSimilarItems": false,
"NavigationContentList": [
{
"NavigationItemList": [
{
"SubCategoryId": -1,
"Description": "Discount Item",
"StoreDepaId": -1,
@bemasher
bemasher / go.xml
Created August 10, 2011 07:05
Go is the better structured and long-winded version. Python is the simpler and much more trouble-prone.
<Person>
<Name>Doug</Name>
<Age>23</Age>
<YChromosone>true</YChromosone>
</Person>
@bemasher
bemasher / README.txt
Created August 15, 2011 04:11
Linear and concurrent julia set renderers in Google's Go.
On an Intel Core 2 Duo E6600 @ 2.4Ghz the rendering portion took place in:
Linear = 24.107s
Concurrent = 9.063s
Both produce images whose SHA256 sum's are both:
3c68084ae742cfc7070e871ca721cb90694c28e886b77b4f289c8e84d18f124a