Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Making Ultralisp.org

Alexander Artemenko svetlyak40wt

💭
Making Ultralisp.org
View GitHub Profile
View gist:14602
#include <stdio.h>
int main(int argc, char* argv[])
{
int i = 10;
printf("Hello World!\n");
// Сколько раз???
while(i--)
@svetlyak40wt
svetlyak40wt / gist:15067
Created Oct 6, 2008
Simple script, to install refactoring plugin for Vim
View gist:15067
#!/bin/bash
# Plant rope vim's plugin
# This is a script to install or update 'ropevim'
# Copyright Alexander Artemenko, 2008
# Contact me at svetlyak.40wt at gmail com
function create_dirs
{
mkdir -p src
@svetlyak40wt
svetlyak40wt / gist:15750
Created Oct 9, 2008
Metaclass to add __repr__
View gist:15750
def general_repr(self):
'''Returns class's representation as string.
Example usage:
class Test(object):
__repr__ = general_repr
def __init__(self):
self.test = "Hello world"
t = Test()
print 'instance: %r' % t'''
@svetlyak40wt
svetlyak40wt / django-middleware-remove-selflinks.py
Created Oct 16, 2008
Django middleware to remove links to the current page
View django-middleware-remove-selflinks.py
@svetlyak40wt
svetlyak40wt / drupal-lighttpd-rewrite.conf
Created Oct 16, 2008
working url rewrite for drupal under lighttpd
View drupal-lighttpd-rewrite.conf
# working url rewrite for drupal under lighttpd
# taken from http://drupal.org/node/20766#comment-44462
url.rewrite-final = (
"^/system/test/(.*)$" => "/index.php?q=system/test/$1",
"^/([^.?]*)\?(.*)$" => "/index.php?q=$1&$2",
"^/([^.?]*)$" => "/index.php?q=$1"
)
@svetlyak40wt
svetlyak40wt / README.markdown
Created Oct 22, 2008
This is a simple utility for easier debug. When you don't know, which attributes have an object in the template, just apply this filter to it.
View README.markdown

This is a simple utility for easier debug. When you don't know, which attributes have an object in the template, just apply this filter to it:

{{object|filter}}

You will see something like that:

['Meta', '__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__metaclass__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__unicode__', '__weakref__', '_changed_data', '_errors', '_get_changed_data', '_get_errors', '_get_media', '_html_output', '_meta', 'add_initial_prefix', 'add_prefix', 'as_p', 'as_table', 'as_ul', 'auto_id', 'base_fields', 'changed_data', 'clean', 'data', 'declared_fields', 'empty_permitted', 'error_class', 'errors', 'fields', 'files', 'full_clean', 'has_changed', 'initial', 'instance', 'is_bound', 'is_multipart', 'is_valid', 'label_suffix', 'media', 'non_field_errors', 'prefix', 'save', 'validate_unique']

Now you can remove the filter and call actual method o

@svetlyak40wt
svetlyak40wt / debug.py
Created Nov 11, 2008
IPython debugger. This is a slightly changed ipdb code.
View debug.py
# This is a slightly changed ipdb (http://pypi.python.org/pypi/ipdb) code.
# Shell creation was moved to the set_trace function, because the issue
# with standart unittest module. Now it is usable.
try:
import sys
from IPython.Debugger import Pdb
from IPython import ipapi
from IPython.Shell import IPShell
View fabfile.py
def production():
config.fab_hosts = ['aartemenko.com']
config.fab_user = 'pythonist'
def testing():
config.fab_hosts = ['localhost',]
def aartemenko():
config.project = 'aartemenko'
config.packages = [
@svetlyak40wt
svetlyak40wt / .xkb_config
Created Nov 14, 2008
XKB config with typography and Alt+Space language switching
View .xkb_config
xkb_keymap "rusadv"
{
xkb_keycodes
{
include "xfree86"
};
xkb_types
{
include "default"
@svetlyak40wt
svetlyak40wt / github-reps.py
Created Apr 17, 2009
Simple script to collect GitHub stats about user's repositories.
View github-reps.py
#!/usr/bin/env python
import sys
from lxml import etree as ET
username = 'svetlyak40wt'
if len(sys.argv) == 2:
username = sys.argv[1]
url = 'http://github.com/api/v1/xml/%s' % username