Friday, December 25, 2009

Monday, December 14, 2009

Facebook and Berlusconi

today many people are getting subscribed (with NO authorization) automatically to this group: Sosteniamo SILVIO BERLUSCONI contro i FAN di massimo tartaglia. You have NO notification that you've been subscribed to this group.

Also consider the geographic position (screenshot) of the group contact.

Also consider that the group can't be signaled to facebook, because the feature looks like out of service.

It's clearly a mafia group, beware of!

Lua for Pythoners - Dictionary

as promised this is the second post, this time for dictionaries. The most important thing to notice is that tbl[key]=nil means deleting the entry from the table, while in python dict[key]=None is still a valid entry with None value.

Here's the snippet you can launch in a lua interpreter and this is the catalog of python dictionary examples.

Sunday, December 13, 2009

Lua for Pythoners - Lists

lately I'm discovering Lua as general purpose language. Many people don't agree with lua being used as a general purpose language, many others (including a newbie like me) think Lua has such a simple syntax and powerful tables to become a full fledged language.
I use a lot of Python, so I start from here: what Python does that Lua can't do almost in the same way? Read the question as it is, don't read "what Python does that Lua can't do", it's different.

This is the first of several post series I'm writing. I'm trying to "translate" python pills in Lua + Penlight

Please consider that many things can be done really better in Lua. As I said, this is a kind of "translation". You will understand that Lua does better than Python in other things that will not be shown because the examples are made in Python.

Here's the snippet, you can run it with a stand-alone Lua interpreter.

If you know better ways of doing things like in Python please comment. Comments like 'Hey, it's inefficient! This is not the way you do things in Lua' are accepted of course but not related to the post.

I've had some important feedback thanks to #lua people in IRC:
- Variables in Lua are globally assigned, so at least in functions you must use local
- Using table.insert in loops is slow, better use tbl[#tbl+1] assignment, and even better remember the next free position tbl[next] = element; next = next + 1