Wednesday, October 10. 2007
After my server was close to wasting all its CPU time for checking email messages for potential spam using Spamassassin I decided that it was time to investigate. My friend Arne, who helped me a lot with Qmail problems earlier, recommended to install spamdyk, an SMTP spam filter that is placed in front of Qmail and does not require specially patches for the MTA itself. Spamdyk can filter mail by blacklisting, whitelisting, greylisting and using several other options.
Thanks to Arne for this great tip! Spamdyk is up and running now on my maschine and my load is now constantly below 0.40, while spam receival seems to be reduced drastically. Since I did not find much information about Spamdyk on Gentoo, I wrote down my experiences as a little howto in the Gentoo wiki. Maybe someone finds it helpfull. Any feedback welcome!
Sunday, September 30. 2007
The fact that type save comparisons (ala ===) are faster in PHP than the normal comparison operator (ala ==). The reason for this is simply, that PHPs loosly-typed-ness-auto-cast-code is not even touched with ===, AFAIK. So, if you did not know, yet:
$foo = 0; $bar = "0";
if ( $foo == $bar )
// ...
is slower than
$foo = 0; $bar = 0;
if ( $foo == $bar )
// ...
wich is again slower than
$foo = 0; $bar = 0;
if ( $foo === $bar )
// ...
But, this should not be the topic of this article, it's just an interessting pre-condition to know and the reason why I started to code strictly type save in PHP a longer time ago. Code like
$foo = array();
if ( count( $foo ) === 0 )
// ...
was the goal of this behavioural change. But, as Kore pointed out while we were coding together, it also led to funny code construct like:
if ( isset( $foo ) === true )
This looks kinda funny, doesn't it? But as I noticed recently, I more and more tend to code this way. So, the valid question was, does this have any effect on speed here? Positive or negative? And my little benchmark (code) revealed: There is a slide speed improvement here, too. So I basically don't care that I started it by accident. ;)
P.S. I love PHP 5.3! ;) Many congratulations and a lot of luck to Johannes as well as a huge ton of thanks to Illia!
Wednesday, September 26. 2007
After 2 years of really satisfied use of the IBM/Lenovo T43p I decided that time has come to upgrade. When the T61p was released by Lenovo some weeks ago I felt that this would be the right for me and so far I did not regret it until now. While I read/heart a lot about Lenovo quality constantly dropping I cannot confirm this.
My version T61p comes with a 15.4" LCD with a maximum resolution of 1920x1200 (after 1600x1200 I did not want anything smaller anymore). While it is about 4 cm wider than my previous T43p its size is still ok for me, since I don't use a desktop PC beside it. The integrated Core 2 Duo (T7700 @ 2.40GHz) compiled my whole Gentoo system (about 800 packages, including nice stuff like OpenOffice.org, Firefox, Thunderbird and Xorg) in about 16 hours (impressive!), supported by 4 GB of RAM.
Although brand new hardware is usually a synonyme for "does not work under Linux" I was impressed, how flawlessly most things worked out of the box. As you can imagine, not everything went out of the box, what is because I'm writing this little blog. Maybe I can assist some people shipping around some pitfalls.
The integrated audio chip 82801H did not work with the latest alsa-driver package, when I first installed the box. I tried compiling the drivers from kernel with no success and only unmasking the CVS version helped. However, the latest media-sound/alsa-driver-1.0.15_rc2 works fine with the snd_hda_intel driver. Tormented by ATI driver politics for Linux, I'm quite happy with the NVIDIA Quadro FX 570M, which is supported by the recent binary drivers. A bit weird but quite ok for me is, that the NVIDIA X Server Settings tool tells me I have 512 MB graphics memory, while the NVIDIA website states that this chip is only available with max. 256 MB. ;)
The brand-new 4965 wireless chip by Intel ran out of the box with the driver (net-wireless/iwlwifi-1.0.0_p1 currently) and firmware (net-wireless/iwl4965-ucode) packages in portage. While connection and association works quite fine in most cases I noticed some weird speed problems and only got about 200-300 kb/s download rates in my local network. As it looks, this was a problem of having CONFIG_MAC80211=y instead of CONFIG_MAC80211=m. Since I re-compiled gentoo-sources-2.6.22-r7 with the new wifi stack build as a module it works perfectly fine and I get 2-3 mb/s. Hope that was the solution for this problem now.
The ACPI support is not perfect so far. While CPU frequency scaling works fine, I'm not able to adjust the LCD brightness through /sys or to switch of bluetooth via hotkey. Suspend to RAM using the Gnome NetworkManager works out of the box. I also tried roughly to get the fingerprint reader to work. Compiling thinkfinger and enrolling my fingerprint worked fine, but pam_thinkfinger does not accept fingerprints currently. Since enrolling worked, this seems to be a setup specific problem. The internal clock of the T61p needs the setting CLOCK_OPTS="--directisa" in /etc/conf.d/clock to work correctly.
I uploaded my Kernel config, dmesg output, the infos of lspci and my xorg.conf as examples for configurations. If anyone has solutions for any problems or tips about how to get stuff working, please post a comment here!
Tuesday, June 26. 2007
I really like OpenOffice.org. Until now, it satisfied any of my needs quite fine. But since I am writing a book using OpenOffice.org, I found some really annoying stuff. Most annoying by now, is the problem of cross references. It happens almost in every text section, that I need to add a reference to another section of the book. For example, while writing about securing user data I want to point to the section of a database chapter, where prevention of SQL injection is explained. I basically want to add a reference like 'See section X.Y.Z, "SQL injection"'.
Just adding a simple reference, which points to another headline of the same document and automatically gets updated if the headline text or number changes, is already a pain in OpenOffice.org. Headlines are not referenceable by default, which means, that you manually need to add a reference target to each of the headlines you want to reference. If you did so, you can make openoffice insert a reference to this target.
At this point the next issue comes into place: OpenOffice.org only allows to use a very limited set of formatings for the reference to be displayed. While you can use the chapter number as a reference, it seems not to be possible to use the headline text in addition or to create your own format, like I need it. Therefore, the basic reference handling of OpenOffice.org is kinda useless for me.
Searching the web left me with 2 solutions: a) Wait for OpenOffice.org 3.0, where enhanced reference handling planned as part of the bibliographic enhancements. Sure, I just need to postpone my project for some years... b) Make use of a custom macro. The latter solution sounds much more practical to me. While I first thought this problem must be very common for authors, Google tought me the opposite. So far I only found 1 macro (see OutlineCrossRef3.sxw), which was written in 2003 and last updated in 2004. The macro at least solves parts of my problems: It provides a list of all headings in a document and, on demand, creates a reference target to one of them and inserts a reference at the current cursor position. Still remaining here: The formatting functionality does not satisfy my needs. You can specify some characters to be placed between different parts of the reference (like between the headline number and text), but still no real custom format.
I'm quite shocked that this feature, for me absolutly essentiell for writing larger documents, is almost not realized in OpenOffice.org. Or did I miss something? Is there anyone out there, who solved the issues? Or do I really have to dig into a macro language of OpenOffice.org and implement the feature on my own? Any hint welcome! Thanks in advance!
Tuesday, May 1. 2007
If you live in the north half of Germany or in a country that also has "Aldi Nord" discounters, you can now get a professional Chorizo cheaper than from Mayflower. ;)
Monday, April 2. 2007
I don't know which is the most common way to calculate Pi in computer programs, but from the stochastics book a read for my recent stochastics exam, I have a randomized variation, which is quite cool I think. To show it, I implemented it in PHP:
$precision = pow( 10, (int ) ini_get( "precision" ) - 5 ); $hits = 0; for ( $i = 0; $i < ITERATIONS; $i++ ) { $x = mt_rand( 0, 2 * $precision ) / $precision - 1; $y = mt_rand( 0, 2 * $precision ) / $precision - 1; if ( ( $x * $x ) + ( $y * $y ) < 1 ) { $hits++; } } echo "Pi is about " . ( ( 4 * $hits ) / ITERATIONS );
The basic assumption in this algorith is, that the generated coordinates are rectangular distributed in the rect (-1/-1) - (1,1). For the numbers I generate using mt_rand() this should be almost correct (note that the generation is not part of the algorith itself, it only says, that you need rectengular distributed points). For each of this generated points, a check is performed, if the point is located inside the unit circle. If it is, a hit is recorded. The relative frequence for this event is exactly the ratio between the unit circle and the whole square, which means it is Pi/4.
The algorith is not really fast, but gives usable results for a large number of iterations:
| Iterations |
Pi estimation |
Time (sec.) |
| 100 |
3.2 |
0.000174045562744 |
| 1000 |
3.128 |
0.00145411491394 |
| 10000 |
3.1436 |
0.0180418491364 |
| 100000 |
3.13876 |
0.16107583046 |
| 1000000 |
3.143652 |
1.64533686638 |
| 10000000 |
3.1423896 |
18.0556662083 |
Update, 2007-04-02: Note, that you should never use this algorithm to calculate Pi in PHP! There is the predefined constant M_PI, as well as the function pi() to retrieve a value with the precision specified in your php.ini! This is just a cool algorith and it's really slow (in comparison of using the constant)!
Friday, March 23. 2007
The Mozilla Development Center has a new mascot called "developer kit":
Really sweet and a nice slogan! :)
Friday, February 16. 2007
Yesterday (and today) I had an experience, which showed me once again, why I pay so much for a high quality notebook. During our (currently daily) learning sessions, the keyboard of my 1.5 years old IBM Thinkpad T43p lost it's backspace key. Somewhat annoyed I opened a support call on the IBM website (luckily, IBM has 3 years of guarantee) about it and (while having the chance) I added anothe issue with the notebook I now had for about 2-3 months. This one was, that I had a bunch of weird light-gray dots on my display, which actually looked like tiny liquid splashes. I was not able to kill them with a towel and therefore added the phenomenon to the support call, too. Anyway, I did not expect IBM to react on that issue, because it simply did not look like a guarantee issue to me.
After entering the support ticket, I went for a coffee, leaving my cellphone in another room. When I returned back (about half an hour later), IBM had already tried to call me back. A look at the trouble ticket showed me, that they already had taken 3 steps: 1. "Customer called". 2. "Problem strategy defined". And 3. "Mechanican will come out". The 3rd step actually wondered me most, because I don't have the extended on-site guarantee and expected to get a request to send the notebook. Whatever, 2 hours later, IBM tried calling me again and finally reached me. The question was, if I would be at home today between 11 and 1, which I agreed on, and they promised to send me a technican for repair.
Around 12 today the mechanican turned up, took a look at my keyboard and (which wondered me a bit) at the display. Around 45 minutes later I had a brand new keyboard and 'a brand new display in my thinkpad and he was gone again.
I am really amazed by this support! Not really 20 hours after my support call arrived, they finished repair, sent someone on-site and also exchanged the display. Fantastic! Now I really know, why I pay such a price for a piece of hardware!
|