Posts

Showing posts from 2008

Being naïve about Python object identities, references and sizes.

I'm ashamed of how naïve and ignorant I stand regarding Python stuff. At least this time, I've learned a great lesson about object identities, references and sizes. Hopefully you won't make the same mistake as I did.

Here's what I wanted to do: write an in-memory simplistic log keeper for my application, that would be used as a poor man's brute force protection. The details don't matter much. All this meant is I'd have to keep, say, all the last 10 authentication attempts for all users, for as long as needed, in memory.

I was then a bit worried about memory usage, so I got creative. I'm probably the electrician sysadmin that Tom referred. Sometimes the wires burst in flames when I get creative.

A normal (and sane) person would write something like this:


UserLog(object):
def __init__(self, auth_result, auth_timestamp, client_ip):
self.auth_result = auth_result
self.auth_timestamp = auth_timestamp
self.client_ip = client_ip

It's a simple class …

Sharing the USB 3G serial network of a Mac OS X with a VirtualBox guest machine

When configuring networking on VirtualBox for Mac OS X, I got stuck because it didn't give me the option to use the "Host Interface" option with my ppp0 connection. The ppp0 connection is my "dial-up" Internet connection using a 3G USB modem.

The solution is so obvious, that I'm surprised I couldn't think of it before finding this post on the VirtualBox forum: just use the (amazing) Internet sharing option of the Mac.

- First, configure VirtualBox to use "Host Interface", and pick the "Ethernet" device down below.
- Then, Boot your guest OS (for example, Debian Live, or HaikuOS) and use DHCP to configure the network.
- Finally, configure Internet sharing on the Mac OS X. Just share the "connection from: " .. "To computers using: Ethernet". Wait a few seconds, then force a reload of the DHCP configuration on the guest OS, and it's done!

Now, the trick is how to make the network work on HaikuOS :-).