Member Avatar

Well, it bothers me to build menus for every shell application that needs one. So, I've written a module to handle that, like in the good old turbo pascal times. :) Here it is, the module comments are pretty explainatory, I think, and the sample usage if run as script should enlighten the concept. Use it, give comments, improvements, have fun... Cheers and Happy coding

Member Avatar
0
5
Member Avatar

Simple script for image transparency. Someone asked one some time ago, and i had other but for a different system, and decided to write a Python/PIL version. The value of the color used as transparent is the value of the pixel at position (0, 0). You can adjust tolerance value. Happy coding!

Member Avatar
0
6
Member Avatar

Two litle functions to help on text slice and spliting. The code comments say it all. [CODE]# Slicer takes as arguments a tuple containing the string before, # the string after and the string to truncate. It returns the string # between the two given strings Slicer = lambda((b, a, t)): t.partition(b)[2].partition(a)[0][/CODE] [CODE]# Spliter takes as arguments a tuple containing the string before, # the string after and the string to truncate. It returns a tuple # containing the string before, the string between and the string # after the given strings Spliter = lambda((b, a, t)): ((t.partition(b)[0]),) + t.partition(b)[2].partition(a)[0::2][/CODE] …

Member Avatar
1
6
Member Avatar

Aproach to the implementation of K-Nearest Neighbor (KNN) using the Euclidean algorithm. Sample Usage: [CODE]mywork = Words_Works() lit = 'literature.txt' mywork.add_category(lit, 'Literature') # adding files as category comp = 'computers.txt' mywork.add_category(comp, 'Computers') phy = 'physics.txt' mywork.add_category(phy, 'Physics') # saving categories dictionary to file mywork.save_categories() # can be loaded calling load_categories() print mywork.categories # prints categories dictionary print txts = ('sample1.txt', 'sample2.txt') # creating list of files to add for text in txts: mywork.add_text(text) # adding files print mywork.all_texts # prints files word ocurrence count print mywork.knn_calc() # perform calculation print mywork.knn_results # print overall results print mywork.knn() # print files …

Member Avatar
0
10
Member Avatar

ITunes Library Persistent ID Editor. Sample usage: [CODE]fxml = 'iTunes Music Library.xml' # path to xml file fitl = 'iTunes Library.itl' # path to itl file itk = ITunesLibKeys(fxml, fitl) print itk.file_xml # prints path to xml file print itk.file_itl # prints path to itl file print itk.xml_key # prints key on xml print itk.itl_key # prints key on itl print itk.valid_key # prints True if keys match itk.new_user_key() # ask for user input key itk.xml_key_replace(itk.itl_key) # replace key on xml file with the itl key itk.itl_key_replace(itk.new_key) # replace key on itl with user input key[/CODE] [CODE]fxml = 'iTunes Music …

0
1

The End.