|
|
Wednesday, July 2. 2008
Windows Vista demand is so strong that Dell is offering a Windows Vista Bonus to its customers.
What is it?
It's the option to have Windows XP pre-installed, of course!
Friday, June 20. 2008
If you're using LogMiner to analyse your Apache/IIS logs, here's an easy recipe to be notified of sites that send visitors your way.
First, let's define a Pg/PLSQL function to extract the new referrers:
CREATE TYPE new_referrer AS ( site_id int8, site_name text, referrer text, hits int );
CREATE OR REPLACE FUNCTION get_new_referrers() RETURNS SETOF new_referrer AS $body$ DECLARE rec new_referrer; lastRef int8; BEGIN
SELECT INTO lastRef CAST( value AS int8 ) FROM catalog WHERE name = 'LastReferrer';
IF lastRef IS NULL THEN INSERT INTO catalog ( name, value ) VALUES ( 'LastReferrer', 0 ); lastRef := 0; END IF;
FOR rec IN EXECUTE 'SELECT s.id AS site_id, s.name AS site_name, r.referrer, tmp.hits ' || 'FROM ( ' || ' SELECT site, referrer, COUNT(*) AS hits ' || ' FROM accesses ' || ' WHERE referrer > ' || lastRef || ' GROUP BY site, referrer ' || ') tmp ' || 'JOIN sites s ON s.id = tmp.site ' || 'JOIN referrers r ON tmp.referrer = r.id ' || 'WHERE r.extern = true ' || 'ORDER BY s.name, tmp.hits DESC, r.referrer' LOOP
RETURN NEXT rec;
END LOOP;
UPDATE catalog SET value = ( SELECT MAX( id ) FROM referrers ) WHERE name = 'LastReferrer';
RETURN; END; $body$ LANGUAGE plpgsql;
Then, a little PHP script to run the query and format the results:
#!/usr/local/bin/php<?php $lines = array(); $lastSite = ''; // quickest and dirtiest way to execute a query in PHP ;-) exec ( "echo 'SELECT r.* " . "FROM get_new_referrers() r " . "LEFT JOIN search_engines se ON ( r.referrer ~* se.pattern AND r.referrer ~* se.query_pattern )" . "WHERE se.id IS NULL' | /usr/local/pgsql/bin/psql -U logminer -At logminer", $lines ); foreach( $lines as $line ) { $parts = explode( '|', $line, 4 ); if( $lastSite != $parts[ 0 ] ) { printf( "\n\n\n\n" . "-------------------------------------------------------\n" . "Referrers for %s\n" . "-------------------------------------------------------\n\n", $parts[ 1 ] ); $lastSite = $parts[ 0 ]; } printf( "[%d] %s\n\n", $parts[ 3 ], $parts[ 2 ] ); }?>
The query above grabs the referrers for every site available in the DB, filtering requests coming from known search engines to reduce the level of "noise".
This script is finally invoked by the cron job that processes the logs:
referrers_report.php | mail -s 'New referrers report' email@example.com
Saturday, June 7. 2008
Intelligence is the ability to avoid doing work, yet getting the work done.
-- Linus Torvalds
Wednesday, June 4. 2008
Suppose you want to create an application which you want to limit to a single running instance, like some image viewers do for example. Also, you need different users on a Terminal Server not to conflict with each other. Oh, and you're coding in C#.
A possible solution to the problem is the one described in this Flawless Code post.
What I didn't like is, it requires the 3.5 version of the framework, while I preferred to be able to run on machines with only 2.0 installed. So I've replaced the NamedPipeClientStream/NamedPipeServerStream with a P/Invoke-based implementation based on this example.
Also, I create a different pipe per user session, since I haven't found a way to create a "local" pipe. An article at Dr Dobb's suggests that it's possible, while MSDN doesn't mention this possibility...
I've zipped up my test solution in case someone else has the same needs.
Monday, June 2. 2008
I've just added LogMiner to Ohloh, a site that offers an interesting feature: it can analyse a project source code and estimate how much it would cost to hire a development team to recreate the project from scratch.
I think that it's a simple way to estimate the effort you put over the time in open source projects.
Here's the resulting figure for LogMiner:
Thursday, May 29. 2008
I'm starting to suspect that spammers try to collect and verify email addresses from PAD files using bogus sites as honeypots.
In fact, lately I've received several mails which are all based on the same template:
Hello, my name is John, and I am an associate of
SITEURL
Briefly, here is what we do. We specialize in
software reviews and downloads. While browsing the
web we came across your software and I must say
that we were stunned. We were so amazed by its
outstanding features that we decided to give you
our prestigious 5 stars award and put your
software on our editors choice list. We would be
delighted if you would consider posting it in your
awards section. To find the award please go to
http://SITEURL/adownloadIDOFSOMEKIND.html
If you have time please leave a comment, so that
others can view your remarks.
I would like to take a moment to thank you for
all your devoted work in the software field and
wish you success in your business.
The suspicious points are:
- all the sites have the same structure
- they don't even pretend not to be fake: the search function never works, the content appears only in some pages and never point to valid files, etc...
- IDOFSOMEKIND could be used just to verify that the mail reached an user that actually reads the mail and clicks on URL's
Am I paranoid?
Monday, May 19. 2008
Here's another interesting piece of code I've just digged up in a C# application I'm reviewing.
If you can come up with a bright idea about what those try/catch blocks are supposed to do, you've got more imagination than me...
class Foo { private int bar;
// ...snip...
public int GetNewBar() { int ret = 0;
lock (this) { try { bar++; ret = bar; } catch { try { bar++; ret = bar; } catch {} } }
return ret; }
// ...snip... }
Wednesday, May 14. 2008
Sometimes when you're reviewing someone else's code, you find interesting pieces of " art". Like the following loop construct in a C# application:
int i = anArray.Length - 1;
while (true) { if (i < 0) break; else { ... i--; } }
Doh.
You might be tempted to rewrite it as:
for( int i = anArray.Length - 1; i >= 0; i-- ) { ... }
but it would be too simple, too boring, wouldn't it?
Sunday, May 11. 2008
It's been more or less forever since I've decided to setup a Flickr account. Finally, I did.
There are just a handful of photos there at the moment, but it's a start.
Wednesday, May 7. 2008
I shot this picture a couple of days ago, while returning home from Budapest. It's now my desktop wallpaper.
Friday, April 18. 2008
I always assumed the designers of the Objective-C language and Cocoa frameworks trust me to know what I'm doing while I find very elegant ways to shoot myself in the foot.
-- from a mail sent to Cocoa-dev
Tuesday, March 25. 2008
Several months ago, I've added a captcha check to the contact page to stop spammers from flooding my mailbox.
Today, with much surprise, I've received a comment to that post from a guy trying to sell his services:
We the leading Data processing company in Bangladesh. Presently we are processing 300000+ captcha per day by our 55 operators. We have a well set up and We can give the law rate for the captcha solving.
Our rate $2 per 1000 captcha.
We just wanna make the relationship for long terms. can we go forward?
What?! No, we can NOT go forward.
Unbelievable.
I didn't even imagine that someone would employ people just to break captcha barriers and push spam through.
Saturday, March 8. 2008
I've just installed the latest Mandriva 2008.1 RC on this fine Asus barebone.
Everything went fine, except that the output of sensors showed too many ALARM messages for my taste... so, here's how I've modified the pre-installed sensors.conf to set some min/max values closer to reality and to hide useless lines:
# Winbond W83627EHF configuration originally contributed by Leon Moonen # This is for an Asus P5P800, voltages for A8V-E SE. chip "w83627ehf-*" "w83627dhg-*"
label in0 "VCore" label in2 "AVCC" label in3 "3VCC" label in7 "VSB" label in8 "VBAT"
# +12V is in1 and +5V is in6 as recommended by datasheet compute in1 @*(1+(56/10)), @/(1+(56/10)) compute in6 @*(1+(22/10)), @/(1+(22/10)) set in1_min 12.0*0.9 set in1_max 12.0*1.1 set in6_min 5.0*0.95 set in6_max 5.0*1.05
set in4_min 1.6*0.9 set in4_max 1.6*1.05 set in9_min 1.6*0.9 set in9_max 1.6*1.05
# Set the 3.3V set in2_min 3.3*0.95 set in2_max 3.3*1.05 set in3_min 3.3*0.95 set in3_max 3.3*1.05 set in7_min 3.3*0.95 set in7_max 3.3*1.05 set in8_min 3.3*0.95 set in8_max 3.3*1.05
# Fans label fan2 "CPU Fan"
ignore fan1 ignore fan3 ignore fan4 ignore fan5
# Temperatures label temp1 "Sys Temp" label temp2 "CPU Temp" label temp3 "AUX Temp"
set temp1_over 45 set temp1_hyst 40
Corrections are welcome.
|
|