2011-04-26

Python: how to remove duplicates from list

# -*- coding: utf-8 -*-
qi=[1,1,3,1,6,4,5,1,6] #some elements repeat
qi.sort() #sort urls (just for fun)
qi_normal=set(qi) #this removes duplicate URL's
print "list wit repeated elemnts:", qi
print "list without repeted ellemnts:",qi_normal

Python: How to remove \n (end of line) symbol

# -*- coding: utf-8 -*-
str = [u"afaaas\n", "adasf \t"]
print "withouth strip():", str
print "with strip:\n", str[0].strip()
print str[1].strip()

as you can see .strip() also remove \t

2011-04-25

Python: read utf-8 file

This how I read utf-8 (without BOM) file in python:
import codecs
txtfile = codecs.open("bla.txt", "r", "utf-8")
t= txtfile.read()
txtfile.close()
print t

2011-04-24

Erlang frameworks comparison

http://chicagoboss.org/projects/chicagoboss/wiki/Comparison_of_Erlang_Web_Frameworks
http://stackoverflow.com/questions/1822518/current-state-of-erlang-web-development-frameworks-template-languages

Interesting info:
http://brainslugs.blogspot.com/2008/02/yaws-erlang.html

Tut for beginers:
http://www.giantflyingsaucer.com/blog/?p=251
http://www.rsdn.ru/article/erlang/GettingStartedWithErlang.xml

mochiweb:
http://habrahabr.ru/blogs/erlang/111252/

2011-04-17

Pylons error in windows 7: "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0 : ordinal not in range(128)"

to solve this issue i delete all cyrillic sections (smth. like this "аудио/x-gsm") in the windows registry:

[HKEY_CLASSES_ROOT\CLSID\{4063BE15-3B08-470D-A0D5-B37161CFFD69}\EnableFullPage\MIME]
and
[HKEY_CLASSES_ROOT\MIME\Database\Content Type]

pylons installation error "ImportError: No module named _weakrefset"

in go-pylons.py add after line 43

if sys.version_info[:2] >= (2, 7):
REQUIRED_MODULES.extend(['_weakrefset'])

Console 2 for Windows

I like it, maybe you like it to, so try it if you can't stand standart windows console:
http://sourceforge.net/projects/console/

If you know some other consoles for windows, plz let me know.

Description:
"Console is a Windows console window enhancement. Console features include: multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles"

2011-04-13

Django error on windows: "Error loading MySQLdb module: No module named MySQLdb"

If you got this error "Error loading MySQLdb module: No module named MySQLdb" in Django on windows... just install this
http://www.codegood.com/downloads?dl_cat=2