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
#include <stdio.h>
int main(int argc, char* argv[])
{
int i = 10;
printf("Hello World!\n");
// Сколько раз???
while(i--)
@svetlyak40wt
svetlyak40wt / gist:15067
Created October 6, 2008 15:58
Simple script, to install refactoring plugin for Vim
#!/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 October 9, 2008 11:18
Metaclass to add __repr__
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 October 16, 2008 08:13
Django middleware to remove links to the current page
@svetlyak40wt
svetlyak40wt / drupal-lighttpd-rewrite.conf
Created October 16, 2008 17:28
working url rewrite for drupal under lighttpd
# 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 October 22, 2008 06:37
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.

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 November 11, 2008 10:30
IPython debugger. This is a slightly changed ipdb code.
# 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
@svetlyak40wt
svetlyak40wt / fabfile.py
Created November 12, 2008 12:59
My script for http://aartemenko.com deployment.
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 November 14, 2008 11:33
XKB config with typography and Alt+Space language switching
xkb_keymap "rusadv"
{
xkb_keycodes
{
include "xfree86"
};
xkb_types
{
include "default"
@svetlyak40wt
svetlyak40wt / github-reps.py
Created April 17, 2009 07:40
Simple script to collect GitHub stats about user's repositories.
#!/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