Wednesday, February 2, 2011

Politicans, please thermalize!

Inspired by an UP rant and this photo.

Thursday, December 30, 2010

Nyelvi igénytelenség

Az NMHH nekiment a Tilosnak. Tele van vele az Internetz, a sajtó, nem is fűzök véleményt az ügyhöz.

Itt csak a Nemzeti Média- és Hírközlési Hatóság leveléből (mirror) idézek két résztletet. Az első a vitatott - stílszerűen "It's on" című - szám kezdete anglolul, a második pedig magyarul. Aki az NMHH-ban ezt a fordítást készítette, annak úgy tűnik, fogalma sem volt arról, hogy itt a kábítószer-kereskedelemről van nagyban szó. Bizonyára azt hitte, hogy minden a dalokban elhangzó trágár kifejezések körül forog.
Yo, Ice, the organization say they can't stay in business with us any longer. What you gonna do?
We always knew we were gonna come to this point sooner or later ... we have absolutely no option but to move forward. We'll have to set up our own distribution, manufacturing, run totally independent organization and operation. We still got our connections in Texas, Miami, New York, Chicago, Detroit and soldiers on the street wiling to die. I can't put any cut on the product.
NMHH magyar fordítása:
Yo, Ice, a szervezet azt mondja, hogy nem üzletelnek velünk többet. Mit tehetünk?
Mindig is tudtuk, hogy el fog jönni előbb vagy utább ez a pillanat, nincs más választásunk, megyünk előre. Létre fogjuk hozni a saját forgalmazó hálózatunkat, gyártásunkat, egy független céget. Még mindig megvannak a kapcsolataink Texasban, Miamiban, New Yorkban, Chicagoban, Detroitban. A katonáink hajlandóak meghalni értünk az utcán. Nem vághatok ki semmit a dalokból.

Monday, August 23, 2010

Convert CSV or TAB delimited text to SQL Insert with Python

Basic task: convert your coma separated or tab delimited txt file into an SQL insert script.
Done in a functional manner. Define your fields in the input file and in the destination table:  excel_fieldssql_fields 
Define your mapping: define a mapping between the two field list: mapping
Also you can assign a function to each element of this mapping. This function will be applied on the value of the input field to get the sanitized or derived db filed values in your insert SQL: map_func
The code that does the actual work is quite simple:
def print_insert(splittedline):
    print ''.join([insert_start, ','.join(map(lambda x : map_func[x](get(mapping[x],splittedline)), sql_fields)), insert_end])
f = open(sys.argv[1]'r')
map(print_insert, filter(filter_lines, map(lambda x : x.split(field_delimiter), f.readlines())))


Friday, May 21, 2010

BWV 846 Prelude No. 1 - Python

Suppose you have chords in this format: "C3E3G3C4E4" (this is just the beginning chord, the numbers are indicating transposition). Here's some python code to interpret chords in this format.

Sunday, May 16, 2010

Date range search

I've created a date range search webapp for a friend. The source is open. It was used as a data collection tool for his/her mid term essay. You can define a search term and a site and a date-range and for each day in the range you'll get the number of occurances of the search term on the given site. The whole thing is very simple. It uses Google's date range search and it always searches on a one day interval (from=to). So it iterates over the whole range given and returns the result count for each day. For example let's see the distribution of the term "rendszerváltás" on the Népszabadság online within this year.
You can use this to collect data for neat charts like this one:



Friday, February 26, 2010

Google personalized search

My blogspot blog was served as the first result of a personalized search for my friend — this is "personalized search", an opt-in feature that uses someone’s search history and location as signals to determine what kind of results they’ll find useful. Or as search quality engineer Patrick Riley puts it: every time you search on Google, you’re a lab rat.
The search terms were about a certain song and my blog post was totally irrelevant result. And it's pagerank is low. Only imaginable reason for my blog being the first is our gmail correspondence. How on earth could that be the first? Any idea?
screenshot: