Skip to content

Instantly share code, notes, and snippets.

@baverman
baverman / xml2dict.py
Last active January 4, 2016 09:09 — forked from anonymous/xml2dict.py
# Simple xml to dict parser
#
# It's usable only for small documents due low performance
# comparing with lxml
from xml.etree import cElementTree as etree
from cStringIO import StringIO
def builder(ptag, attrib, pchild):
child = []
@baverman
baverman / tcolor.py
Last active January 4, 2016 06:29
xterm 256 color palette translation
#!/usr/bin/env python2
import sys
COLORS = [
('16', '000000'),
('17', '00005f'),
('18', '000087'),
('19', '0000af'),
('20', '0000d7'),
('21', '0000ff'),
@baverman
baverman / nya.py
Created October 29, 2012 11:24
Next episodes downloader from http://www.nyaa.eu/
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import re
import sys
import os.path
from urllib2 import build_opener
from urllib import urlencode
from lxml import html