View et_accessor.py
######################################################### | |
# Title: Simple ElementTree accessor # | |
# Author: Alexander Artemenko <svetlyak.40wt@gmail.com> # | |
# Site: http://aartemenko.com # | |
# License: New BSD License # | |
# Original: http://gist.github.com/108704 # | |
######################################################### | |
class Accessor(object): | |
"""Easy to use ElementTree accessor.""" |
View group_by_n.py
#!/usr/bin/env python | |
def group_by_n(iter_or_collection, n): | |
""" This function returns iterator which iterates over tuples by n | |
>>> rr = 'abcdefghijklmnopqrstuvwxyz' | |
>>> for i in group_by_n(rr, 3): | |
... print tuple(i) | |
('a', 'b', 'c') | |
('d', 'e', 'f') | |
('g', 'h', 'i') |
View Live URLs
For the Birds - http://nycbirdlist.org/ | |
Code monkeys - http://djapp.org/ | |
Freelancer - http://tnycnt.com/ | |
Sword of Truth - http://leafychat.com/ | |
wwswd - http://wwswd.com/ | |
East meets West - http://whohasmy.net/ | |
crunkd - http://getcrunkd.com:88/ | |
Ra - http://www.ntrie.com/ | |
arctangent - http://rudestword.com/ | |
Slugs - http://flicasa.com/ |
View urllib2-debug.py
#!/usr/bin/env python | |
"""Example of custom header and debugging for urllib2's request.""" | |
import urllib2 | |
request = urllib2.Request('http://aartemenko.com') | |
request.add_header('User-Agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11') | |
h=urllib2.HTTPHandler(debuglevel=1) | |
opener = urllib2.build_opener(h) |
View django_versions.py
# Simple way to see which version of django apps you have | |
# Author: Alexander Artemenko | |
import pkg_resources | |
from django.conf import settings | |
def get_version(app): | |
try: | |
d = pkg_resources.get_distribution(app) | |
return d.project_name, d.version |
View parse_css_color.py
def parse_color(s): | |
""" Parses color string in format #ABC or #AABBCC to RGB tuple. """ | |
l = len(s) | |
assert(l in (4,5,7,9)) | |
if l in (4,5): | |
return tuple(int(ch * 2, 16) for ch in s[1:]) | |
else: | |
return tuple(int(''.join(a), 16) for a in zip(*[iter(s[1:])]*2)) |
View pylint_utf8_issuefix.py.patch
# HG changeset patch | |
# User Alexander Artemenko <svetlyak.40wt@gmail.com> | |
# Date 1269880368 -14400 | |
# Node ID 71abc0ecd0283583cde79914c65a92712c8cda53 | |
# Parent cdd571901fea51f7677d6f744ea9cd2d82c57d68 | |
Fixes issue 4683. Non-ASCII characters count double if utf8 encode. | |
diff -r cdd571901fea -r 71abc0ecd028 checkers/format.py | |
--- a/checkers/format.py Mon Mar 29 11:27:19 2010 +0200 | |
+++ b/checkers/format.py Mon Mar 29 20:32:48 2010 +0400 |
View araxisgitmerge.sh
#!/bin/bash | |
# Remote araxis merge script | |
# -------------------------- | |
# Author: Alexander Artemenko <svetlyak.40wt@gmail.com> | |
# | |
# Save this script somewhere on the remote server, | |
# for example as ~/usr/bin/araxisgitmerge. | |
# | |
# Add these lines on your desktop's ~/.ssh/config |
View svetlyak_buildout.cfg
[buildout] | |
parts = | |
env | |
django | |
media | |
project-name = svetlyak | |
project-dir = ${env:HOME}/projects/${buildout:project-name} | |
develop = ${buildout:project-dir} | |
find-links = http://pypi.aartemenko.com | |
unzip = true |