eclipse plugin for python

=====================================
Installing eclipse plugin for python:
=====================================

eclipse version: eclipse-jee-galileo-win32
update manager url: http://pydev.org/updates

Help -> Install New Software

    Add ...

Name: pydev
Location: http://pydev.org/updates

Work With: pydev

Check 

    PyDev
        PyDev for Eclipse

install plugin

restart eclipse

Window -> Preference -> PyDev -> Interpreter - Python -> New..

Add python.exe (of python26 installed on my desktop)

Click OK (it will do some validations)

Open PyDev prespective

Configuring auto-refresh
--------------------------------------------------------------------
Eclipse by default (at least on 3.1) does not refresh
things automatically, so, if you make changes outside of the workspace, you will
not see the changes until you refresh it (F5 on the navigator). However, you can
change the default setting and ask Eclipse to refresh automatically.

To set auto-refresh, go to window > preferences > general > workspace
and check the refresh automatically check-box.

NOTE: not doing so may have some specially strange results with .pyc files not
being deleted, as pydev will only acknowledge that the .pyc file exists on a refresh.
Categories: Uncategorized

where is “share this” button on filckr

from flickr home page
http://www.flickr.com/photos//

Organize -> Your Sets

double click one of your set

are you looking for “Share This” button well you wont find it here !!
Click on “Open set page” then you’ll see “Share This” button
===========

Categories: Uncategorized Tags:

Netflix Prize Winner- Recommendation System

http://www.netflixprize.com/assets/GrandPrize2009_BPC_PragmaticTheory.pdf
http://www.netflixprize.com/assets/ProgressPrize2008_BigChaos.pdf
http://www-cse.ucsd.edu/users/elkan/KddNetflixWorkshop.pdf

http://www.netflixprize.com/assets/GrandPrize2009_BPC_BellKor.pdf
http://www.netflixprize.com/assets/GrandPrize2009_BPC_BigChaos.pdf
http://www.netflixprize.com/assets/GrandPrize2009_BPC_PragmaticTheory.pdf

Websphere class loaders

09/09/2009 mynotes Comments off
  1. Bootstrap
    • jre/lib
    • jre/lib/ext
    • CLASSPATH environment variable
  2. Extension
    • ws.ext.dirs system property to determine the path that is used to load classes.
  3. Application module classloaders
    • shared libraries
  4. Web module classloaders
    • WEB-INF/classes
    • WEB-INF/lib

Distributed Systems & Transaction Processing books

08/24/2009 mynotes Comments off

Reliable Distributed Systems: Technologies, Web Services, and Applications (Hardcover)
# Hardcover: 668 pages
# Publisher: Springer; 1 edition (March 25, 2005)
# Language: English
# ISBN-10: 0387215093
# ISBN-13: 978-0387215099
# Product Dimensions: 9.3 x 7.2 x 1.5 inches

Transaction Processing: Concepts and Techniques (The Morgan Kaufmann Series in Data Management Systems) (Hardcover)
# Hardcover: 1070 pages
# Publisher: Morgan Kaufmann; 1st edition (September 15, 1992)
# Language: English
# ISBN-10: 1558601902
# ISBN-13: 978-1558601901
# Product Dimensions: 9.4 x 7.6 x 2 inches

Distributed Algorithms (The Morgan Kaufmann Series in Data Management Systems) (Hardcover)
# Hardcover: 904 pages
# Publisher: Morgan Kaufmann; 1st edition (March 15, 1996)
# Language: English
# ISBN-10: 1558603484
# ISBN-13: 978-1558603486
# Product Dimensions: 9.3 x 7.6 x 1.7 inches

standard output and error to same file

08/21/2009 mynotes Comments off

question:

I want both standard output and standard error of my command cmd to go to the same file log.txt

answer:

cmd >log.txt 2>&1

http post using curl

curl -i -k https://my.host.com/a/b/c -d @c:/temp/1.xml
Categories: Uncategorized Tags: , ,

wordnet 2.1 lexnames missing

download PyWordNet

>>> from wordnet import *

Traceback (most recent call last):
  File "<pyshell #8>", line 1, in <module>
    from wordnet import *
  File "C:\tools\python\2.6.2\lib\site-packages\wordnet.py", line 767, in </module><module>
    setupLexnames()
  File "C:\tools\python\2.6.2\lib\site-packages\wordnet.py", line 763, in setupLexnames
    for l in open(WNSEARCHDIR+'/lexnames').readlines():
IOError: [Errno 2] No such file or directory: 'C:\\tools\\wordnet\\2.1\\dict/lexnames'

download WordNet-2.0.tar.gz

C:\tools\python>gzip -d WordNet-2.0.tar.gz
C:\tools\python>mkdir x
C:\tools\python>cd x
C:\tools\python\x>mv ..\WordNet-2.0.tar .
C:\tools\python\x>tar xf WordNet-2.0.tar
C:\tools\python\x\WordNet-2.0\dict>cp lexnames C:\tools\wordnet\2.1\dict

now it works

>>> from wordnet import *
>>> N['dog']
dog(n.)
>>> V['dog']
dog(v.)
>>> ADJ['clear']
clear(adj.)
>>> ADV['clearly']
clearly(adv.)

Why lexnames is missing from wordnet 2.1 ?

python dict sort by value

many ways

http://blog.client9.com/2007/11/sorting-python-dict-by-value.html

alist = sorted(adict.iteritems(), key=lambda (k,v): (v,k))

http://coreygoldberg.blogspot.com/2008/06/python-sort-dictionary-by-values.html

sorted(foo.items(), key=lambda(k,v):(v,k))

http://writeonly.wordpress.com/2008/08/30/sorting-dictionaries-by-value-in-python-improved/

def sbv0(adict,reverse=False):
    ''' proposed at Digital Sanitation Engineering
    http://blog.modp.com/2007/11/sorting-python-dict-by-value.html '''
    return sorted(adict.iteritems(), key=lambda (k,v): (v,k), reverse=reverse)

def sbv1(d,reverse=False):
    '''  explicit list expansion '''
    L = [(k,v) for (k,v) in d.iteritems()]
    return sorted(L, key=lambda x: x[1] , reverse=reverse)

def sbv2(d,reverse=False):
    '''  generator '''
    L = ((k,v) for (k,v) in d.iteritems())
    return sorted(L, key=lambda x: x[1] , reverse=reverse)

def sbv3(d,reverse=False):
    ''' using a lambda to get the key, rather than "double-assignment" '''

    return sorted(d.iteritems(), key=lambda x: x[1] , reverse=reverse)

def sbv4(d,reverse=False):
    ''' using a formal function to get the sorting key, rather than a lambda'''
    def sk(x):  return x[1]
    return sorted(d.iteritems(), key=sk , reverse=reverse)

def sk(x):  return x[1]

def sbv5(d,reverse=False):
    ''' using a formal function, defined in outer scope
    to get the sorting key, rather than a lambda
    '''
    return sorted(d.iteritems(), key=sk , reverse=reverse)

from operator import itemgetter
def sbv6(d,reverse=False):
    ''' proposed in PEP 265, using  the itemgetter '''
    return sorted(d.iteritems(), key=itemgetter(1), reverse=True)

D = dict(zip(range(100),range(100)))

from profile import run

run("for ii in xrange(10000):  sbv0(D, reverse=True)")
run("for ii in xrange(10000):  sbv1(D, reverse=True)")
run("for ii in xrange(10000):  sbv2(D, reverse=True)")
run("for ii in xrange(10000):  sbv3(D, reverse=True)")
run("for ii in xrange(10000):  sbv4(D, reverse=True)")
run("for ii in xrange(10000):  sbv5(D, reverse=True)")
run("for ii in xrange(10000):  sbv6(D, reverse=True)")
Categories: Uncategorized Tags: , , ,

python reading table into list of dicts

Task:
create a list of dict from a table. First row of the table is header and rest is data. Each row should be converted to a dict where keys are header value and values are data.

Example:

header1 header2 header3
x1 x2 x3
y1 y2 y3
z1 z2 z3

Code:

table=[
['header1','header2','header3'],
['x1','x2','x3'],
['y1','y2','y3'],
['z1','z2','z3'],
]

header=table[0]
print [dict(zip(header,table[rowx])) for rowx in range(1,len(table))]

Output:

[{'header2': 'x2', 'header3': 'x3', 'header1': 'x1'}, {'header2': 'y2', 'header3': 'y3', 'header1': 'y1'}, {'header2': 'z2', 'header3': 'z3', 'header1': 'z1'}]
Categories: Uncategorized Tags: , ,