" /> kasia in a nutshell: April 2004 Archives

« March 2004 | Main | May 2004 »

April 28, 2004

Comment spam and mod_rewrite

In my never-ending quest to fight comment spam in my weblog I have been closing off older entries to comments. This works remarkably well, comment spam has come down significantly. Unfortunately, the attempts have not. A simple sampling of my log shows over 200 POST requests today to entries with turned off comments. Obviously, a spam bot. This begs for a new rewrite rule. Granted, the comments were not posted, but it annoys me regardless.. so from now on, if you wish to make a POST request to my server there is a new condition.. you need to be referred from my domain.. Turned off the referer in your browser? Bummer.. you can't post comments.



RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} !.mt-tb\.cgi*
RewriteCond %{HTTP_REFERER} !.*unix-girl\.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^-$
RewriteRule (.*) /post_error.html [R,L]

The above Rule will send anyone who tries to post to my server without a referer from my domain to an error page. Of course, many spam bots use the actual url they're posting to as a referer.. for those just need to depend on either the user agent (one I saw was just "-") or some idea I'll come up with later.

Side benefit: also stops all those stupid scripts looking for formmail and friends.

Edit: Added a line which will except trackbacks.

April 26, 2004

Amusing

Someone, somewhere has my email address on their computer and also a lovely selection of a windows virus du-jour. That same person also has the subscription address to this particular Google-related blog. You put those three things together and what do you get?

A virus sent to that subscription address with my e-mail address as a return.. and in return a 'subscription confirmation' email in my inbox.

Amusing.

Fedex is clueless

They failed to deliver a package to me since it was misaddressed -- instead sent me a postcard (credit to my mailman for delivering it to me despite the wrong street address on it).

"You can pick up your package at the local terminal"

Great! I'll do that.. except the address they provided is a P.O. Box..

uhm, yah. Thanks.

April 22, 2004

Hey, a sane coding style

I whole-heartedly concur with all that is good an geeky.

In my own code, I tend to also add an additional line under a comment for readability.. like so..

// This is a comment
//

Hungarian notation? Hate it, despise it, don't like it. It makes for long, clunky variable names that become cryptic instead of helpful half the time.

[via jeremy]

So maybe I'm just slow.. but..

Apparently the entire world is under the impression that if they continuously bother me while I'm really busy it will somehow make me work faster.

Well, it won't.

It will make me more irritated, more annoyed, more frustrated and more prone to obscenity. But! It cannot possibly make me work faster.

It's a very simple concept. If something has gone horribly wrong and it needs to be fixed *right now* and I am aware of it and already working on the issue, what do you think I'm doing? That's right, working as fast as I can. Now it is entirely possible that 'my fast as I can' is not quite fast enough but still, does not change the fact that it's simply not humanly possible for me to work faster than my maximum physically-allowable work speed. My brain will explode otherwise. Perhaps my fingers too. My wrists are sure to complain as well.

But you can bet your sweet code blocks that I will not insert multiple return statements anyway. Hah, take that, oh argumentative ones.

April 21, 2004

Panoramas around the world

Some of these are really beautiful.

April 14, 2004

Named code blocks in Java

I didn't realize I was starting a religious discussion with my post about multiple return points from the same method. I suppose I could have been clearer (one sentence is pithy even for me, but it was posted in a state of relative upset) and specified that I meant Java. Maybe an example of why this upset me so would have been nice as well, but little late now. Let's just say it involved, reflection, setting a debug level and execution ending before debug code was reached.

In my mind (but go ahead, disagree, keeps things interesting, I'd hate for everyone to agree with me), there's really no excuse for using multiple return points in a language like Java. Number one argument to my proposition appears to be "code readability".. this provides me with an impression that not enough programmers realize Java supports this wonderful thing called code blocks. That you can name! If you wish to avoid convoluted code, they're your best friend.

It's really quite simple, and even more so with my easy to follow example:

private boolean testSomething(Object this)
{
    boolean rval = false;

    DONE:
    {
        this = doSomething();
        if(this.isThat())
        {
            rval = false;
            // Exits the code block completely
            //
            break DONE;
        }

        // more code..
        //
        
        // some more code that will only execute if you didn't
        // call 'break' or 'continue' above'
        //
        rval = true;

    } // end of code block.

    return rval;
}

This is incredibly handy in keeping code clean and easy to read. In a gist, each code block has to have one label and one entry point, may have multiple exits.

April 13, 2004

Writing readable code that's easy to debug 101

Multiple return statements in one method are bad, m'kay?

April 11, 2004

One dusty lens

My brother has an older Canon SLR camera that he probably used last when Swedes invaded Poland.. or well, it feels that way. His interest in photography never quite sustained as mine did. Today, I paid a visit to his dusty apartment and spotted his 70-300 Sigma lens collecting dust in the same general neighborhood as a couple of ashtrays and distinctly lacking in a lens cap. It tugged at my heart, sitting there all by its lonesome, unused for years.. dusty.

With his enthusiastic permission I took the poor little thing home, cleaned it off best as I could and mounted it on my Rebel. It's dusty, still.. auto focus took some toggling of the switch to work, but it did. Much to my delight, it has quite a decent macro mode! That's something I have yet to play with as, while it's a very interesting technique, it never quite seemed a priority. I like landscapes, see. I'm boring and amateurish that way.

Since my cats were not cooperating, I took it out to the woods to look for signs of spring, Very unsuccessfully, but I did get a shot of pussy willows I liked..

April 07, 2004

Programming - it's an adventure!

I'm often asked "what is it like to be a programmer". It's a good question! After all, programming, being the glamorous and exciting profession it is generates much curiosity in the less-typing inclined portion of the population. Oh, alright, I got the question once and it was from a six year old, but who's really counting? The question still deserves to be answered and who better than I? A typical (in my limited view of the universe - from my living room couch where I am located presently) programmer. Please keep in mind that my view of the programming universe may not apply to other typical (not me) programmers.

An average day in an average life of an average programmer.


A good start to any programming day is to drink coffee (lots of coffee) and make realistic and plausible goals for the days accomplishments. Say, fixing the few outstanding issues in the current project and feeling good about yourself and your productivity at the end of the day.

Around midday, as you get through your second pot of coffee, answer all your email and deal with the usual morning interruptions of questions, phone calls, general chit-chat it's time to start the initial debugging work on the first (and usually the hardest) of the list of bugs to fix for the day. Ah, productivity! Fuzzy, warm, green feelings.

Lunch time!

As afternoon rolls in, the day usually starts to look much more organized and flows in a pattern. Much like a flowchart. Created by a disorganized manic depressive. Who likes to smoke pot. The pattern is very usual and typical.. start up debugger, get through one statement, get interrupted, answer questions, discover application core dumped while waiting for your input (weblogic likes to make our lives exciting that way), go get coffee while weblogic restarts. Rinse, repeat until around 5pm.

The evening shift.

Watch all your co-workers leave the office as you fumble some data, debug some QA problems and discover it's now dark outside. Turn up your iPod to tune out any possible interruptions, code madly, try not to insert too many offensive comments in between removing the hacks you said would only be there for a couple days (three years ago) and finally watch everything fall into place and code operate properly. Success! Bug fixed! One.

Kick the chair as you leave the office.

April 04, 2004

gmail privacy policy

There has been much noise recently about Google's new mail service and its privacy policy. Specifically, the biggest concern appears to be the storage of the email itself. What should have been the service's main selling point (who has 1GB worth of email sitting around anyway?) is now the biggest point of contention. "What will they do with all that information".

I have to admit, the privacy policy is worded pretty ambiguously and leaves many open doors for all kinds of nefarious schemes.

We will never rent, sell or share information that personally identifies you for marketing purposes without your express permission.

"But we will happily sell all other information". I suppose that in itself isn't quite as bad as it sounds. What company doesn't sell their customer information these days? We sell ourselves and our info for a discount at a grocery store, why not for a mail service. Note, it specifies "for marketing purposes".. so does this mean they will for other purposes?

Residual copies of email may remain on our systems, even after you have deleted them from your mailbox or after the termination of your account.

What exactly is "residual copies" of email? What conceivable reason would Google have for storing more than one copy of an email (other than backups, obviously) on their system? Considering Google is using the content of the email to target ads, this is probably something as simple as using a sampling of email to test and improve their targeting algorithm.. but if that's all it is, I wish they would say as much in the privacy policy.


Google employees do not access the content of any mailboxes unless you specifically request them to do so (for example, if you are having technical difficulties accessing your account) or if required by law, to maintain our system, or to protect Google or the public.

This is the biggest open door. "Protect Google" -- who defines what is needed to protect Google? Of course.. Google, in other words, as long as they can justify "it's good for the company" they can do what they please.

The policy is pretty badly written, leaves too many questions and doesn't explain Google's intentions as clearly as it should, but I would think they're too big of a company to get away with anything too nefarious for too long. I have a feeling that thanks to all the noise this is causing, we'll see an amended policy within days.

iPod too hard to use

I think this just proves we are doomed as a species:

...the iPod digital music player has confused so many thousands of new owners that the gadget has spawned its own service industry - to help technophobes download their own songs.

The article: news.independent.co.uk

Cary Cooper, professor of organisational psychology at Lancaster University, said the problem was that the iPod had become a fashion must-have, but that fashionistas tended to be technologically illiterate. "The irony is the people who can use it - the tecchies - are not in themselves very fashionable. But they buy it because they find the technology fascinating."

I would think the reason 'tecchies' buy iPods is because it's an incredibly useful device if you like listening to music? Maybe it's just me..

April 02, 2004

Memory

I upgraded the memory in my powerbook today, it is now a scrumptious 768MB, up from the standard and boring 512MB (came with a side of a leftover 256MB RAM chip).

I was hoping this might help with Safari performance. I should have known better.. I'm a programmer I know how these things work, yet somehow, against all logic and reasoning, I still hoped.

It helped -- now Safari takes up 648MB of RAM instead of the previous 400-something.

Great.


Is anyone even looking at this memory leak? It shows up when browsing sites that heavily rely on tables for layout use background-images assigned via css.