Skip to content

Instantly share code, notes, and snippets.

View svetlyak40wt's full-sized avatar
💭
Making Ultralisp.org

Alexander Artemenko svetlyak40wt

💭
Making Ultralisp.org
View GitHub Profile
@svetlyak40wt
svetlyak40wt / et_accessor.py
Created May 8, 2009 07:59
Little helper, to access ElementTree nodes as attributes.
#########################################################
# 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."""
#!/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')
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/
#!/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)
@svetlyak40wt
svetlyak40wt / export_cookies.py
Created July 28, 2009 10:51
Firefox cookies saver
#!/usr/bin/env python
# Firefox3 and Chrome cookies converter.
# This script based on another one, from post
# http://blog.schlunzen.org/2008/06/19/firefox-3-und-cookiestxt/
#
# Thanks to:
# dvj@github, for the Chrome support
import optparse
import os
# 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
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))
# 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
#!/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
[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