Today I needed a list of 2-digit country codes wrapped in a Python dictionary. Since there’s nothing in Python’s standard library, I went to ISO‘s official list of English country names and code elements (a.k.a ISO 3166-1-alpha-2), grabbed the data, filtered it with sed and wrote a module, which you can download here.
I guess the usage is pretty straightforward. Just make sure you specify the dictionary keys in capitals.
>>> from IsoCountryCodes import COUNTRY
>>> COUNTRY["GR"]
'GREECE'
I’m sure there are millions of such implementations over the Internet -but hey! You came here!
When I go to sleep at night, I always leave my computer playing some music -it helps me relax. It’s always quite nice for a while, but after some timeΒ it starts to piss the fuck out of me. The most annoying thing though, is getting out of my warm covers and walking to my box and manually closing whatever application I use for music playback -especially if it’s in the middle of winter and it’s cold as hell.
I guess you’d say something like “dude! Use shorter playlists!”. But you see, the thing is that I don’t know when actually I’ll start drifting into sleep -it might be 20′ or it might be two hours. So yesterday, as I was struggling to sleep while listening to some pagan metal, I decided to build a remote control for my music!
Today I started working on a web-application which requires geographical data, so it can allow (or restrict) access only from certain countries.
While doing my research on geolocation databases, I stumbled upon WIPmania.com -a site which provides IP geolocation tools and services. WIPmania provides real-world geographical information and not just information on geographic locations of the network owners. Also, the database is well-maintained and regularly updated.
Finally, they provide a handy API, so you can easily use it in your applications. A query looks something like that…
[2/12/2010: It seems that Facebook developers changed the structure of chat messages, so the data filtering/extraction methods are pretty much useless now. Will update the code some time soon.]
Not long ago, I demonstrated at my university’s IEEE branch’s event a live man-in-the-middle attack and eavesdropped on Facebook chat conversations and gained access to a student’s Facebook account by stealing cookies over the network. Since I didn’t have much time to prepare for that presentation, the code I wrote was pretty sloppy and missed some of the messages exchanged.
Tonight, I took some time to rewrite it and fixed few bugs. Now it doesn’t miss anything, even if someone is flooding the conversation with a burst of messages.
A couple of weeks ago, I was looking for a handy packet crafting library so I could play a bit at the lower layers of OSI. There are lots of choices available out there and I didn’t have the time to try them all. One of the best pieces of code I stumbled upon was Scapy. It’s written in Python and can be used from its own interactive shell or can be imported and used directly from your Python scripts.
There are lots of tasks you can accomplish with the help of Scapy: from writing network discovery scripts and security tools, to building your own low-level protocols. I won’t go in depth of describingΒ Scapy’s features -you can go to the documentation page for that. Keep in mind that you’ll have to refer to Scapy’s source code for most of your documentation needs, since Scapy’s official documentation scratches only the surface of its features and capabilities.
So! Let’s have a really quick tour of Scapy…
Tonight I needed few actual (as in “non-virtual”!) boxes to mess with some networking stuff. After a long time, I fired up my Asus EEE 900, booted into Debian and started Wicd Network Manager, only to find out that my access point wasn’t listed among available wireless networks. I tried running iwlist from command line, but still, my wireless network’s SSID wasn’t there. That was kinda weird: my SSID wasn’t configured as hidden and my access point was up and running properly, since my other laptop was connected to it and had no connection problems.
WordPress: Fighting spam comments without annoying your readers
Lately I started receivingΒ spam comments from some Russian and Chinese spambots -and it’s annoying as hell! Actually the messages are not that bad -it’s mostly things like “nice post!” and “helpful article!”, but the links which come with them point to spam sites, totally unrelated the the content of my posts. The most annoying thing though, is that when you open the moderation panel and find comments awaiting moderation, you expect them to be from human beings. It’s disappointing when you realize that it’s shit from yet-another-spambot.
Sure, there are many anti-spam methods available, like CAPTCHA, allowing only registered users to comment or using some other anti-spam plugin. They all work great, but they can be an annoyance for actual reader. You see, readers are lazy creatures: they rarely comment on what they read (unless it annoyed them somehow), so if they decide to do it and find out that they’ll have to register first, they will most probably avoid it. CATCHAs tend to get annoying too -lately I find myself wasting lots of brain cycles to understand what the fuck is written there! Finally, there are some WordPress plugins which check the comments against blacklists to identify if they’re spam or not, but spamming networks are changing and growing all the time, so you’ll have to keep updating these plugins often.