Moving at the cam

The main problem w/ my webcam script, is that it always take a shot even when nothing is on the desk, by night for example or when i’m at work. Beside i can use something like monitor, it isn’t the best way since i use a huge amout of CPU. So i decide to save picture only if the previous one is not the same. But how to compare two pictures ? After a little googling I found this:

import Image

h1 = Image.open(filename1).histogram()
h2 = Image.open(filename2).histogram()

rms = math.sqrt(reduce(operator.add,map(lambda a,b: (a-b)**2, h1, h2))/len(h1))

So now i only save the picture in my snapshot folder if the RMS is greater that 100, so no more 10 times the same one.

I want SPAM now

After using the same email address since 1996, i haven’t receive a lot of spam. But since I open this weblog, every days my mailbox is full of junk mail and other f*cking spam.

So yesterday i try this: http://spambayes.sourceforge.net/

It’s took me about ~10 min to install / train it. And YES ! it works perfectly, now il just have to train it again … so please send me some spam :)

Update: A lot of people spam this blog to unsure to receive spam in return.. But don’t be stupid, email on this website are cyphered, so they won’t be used by spambot.. If you really want to receive some spam, simply put your email on a free porn website. Believe me you will receive a huge amount of spam by this way

LUFS-Python

This is one of thing, i’m waiting for a long time. You can use http://www.freenet.org.nz/python/lufs-python/ to write a custom filesystem ‘view’ in python. Take for example: You have a bunch of mp3 laying around, and all information stored in a SQL server: Using this kernel modules you can ‘emulate’ the standard Artist/Album/Track mapping on a filesystem without to much pain. I have already wrote something like this, but only by writing a fake FTP server in perl.. now i can do this in python and have a speudo FS.

Very good news :) .. I hope that LUFS will be integrated in Debian soon as my last compile of LUFS have failed.

A new blog in Webware ?

While loosing some time over python blogs, i just found this blog written in Webware.

This sound amaizing since i have already done several things like this, using ww and Modeling but i found that using a RDBDM for a little blog ( < 1000 post) isn’t a good idea. Need a lot of works for DB management, developpement and lot of trouble for migration. In this other side, using plain old fashion text file isn’t a good way too since you can’t introduce feature easily .. and writing text file need a lot of work to take care about author and date and so on..

I finally conclude the best way to have something that is usefull ( as a long time process ) it to have a ‘object oriented’ store backend. So i choose ZODB, but MetaKit can be a good challenger too.

Another thing that i found usefull in Zope, is the handly of URL. I don’t need to scratch my hairs playing w/ Apache Rewrite Rules .. and other stuff. I read recently that Webware is to be rewriten.. I hope the dev team will tray to fix this in webware too.

I really think that it should be possible to declare some kind of URL to be handled by a certain Webware Servlet. Perhaps using the same type <=> class mapping as Zope do.. This can of course done w/ Apache Rewrite but i don’t find this really nice, having to tweak apache config while i’m developping is awfull for me. ( Even using apache is a bit crudy for me ..)

Stateless vs Statefull firewalls

I’ve been hacking a part of the w-e w/ my firewall setting (mainly cause my firewall blocks my wifi network ..). Everything is fine right now, but i’m wondering what is the difference in satefull and stateless firewalls.

Here is a quote from Sun:

When talking about protocols it is possible to describe TCP as stateful and UDP and IP as stateless. As such TCP will automatically retransmit lost or garbled data independent of the application, whereas an application using UDP will have to manage retransmissions itself.

When talking about firewalls and/or firewall functions in routers stateful and stateless are not necessarily related to specific protocols but more used to describe how firewall controls forwarding/passing of packets.

A “stateless” product looks at each packet and applies rules to each packet independent of the previous packets and determines whether to forward or drop the packet independent of the specific protocol, eg a stateless product will test source and destination addresses and port and ACK bit settings to determine whether to forward or drop the packet.

A “stateful” product also looks at each packet and applies rules, but the rules or tests applied to each packet may be modified depending on packets that have already been processed or in the case of an application relay it will maintain state by definition.

Slow bridging the Wifi

In fact, i’m trying to turn my Wifi gateway (which is really a gateway 2 interfaces + masquerading ) in a transparent bridge. You know only have a single IP for the two interfaces, so going on the wired networks and back won’t be masquerade. In fact until now i can’t access to the Wifi network from the wired one.

So i give it a try to Ethernet Kernel Bridging:

# unsetting devices
ifconfig eth0 0.0.0.0
ifconfig eth1 0.0.0.0

# adding bridge / and ifaces
brctl addbr br0
brctl addif eth0
brctl addif eth1

# configure the bridge
ifconfig br0 192.168.1.20
route add default gw 192.168.1.1

Besides it’s works .. connecting to the wired from the wifi with ips in the same network. it’s slowww.. really tooo slow.

I need to look at this.