Geek Stuff: Rambo Has Found a Computer

While reviewing a PHP function for a website that I am working on, I came across this codified version of Rambo (as a replacement for unset()):

function rambo() {

    // Get the victims and initiate that body count status
    $victims = func_get_args();
    $body_count = 0;  
  
    // Kill those punks
    foreach($victims as $victim) {
        if($death_and_suffering = @unset($victim)) {
            $body_count++;
        }
    }
  
    // How many kills did Rambo tally up on this mission?
    return($body_count);
}

Unfortunately I can't use it on $_SESSION, which was the reason for the research. From the session_unset() notes:

Do NOT unset the whole $_SESSION with unset($_SESSION) as this will disable the registering of session variables through the $_SESSION superglobal.

I could modify the function but it is simply easier to use session_unset().

In other news, I'm working on a web server that disables all browser caching by default. This means that every single image is downloaded for every single page. It's a great way to eat up bandwidth. My fix was to override the cache-control header by adding this to my .htaccess file:

# Check for new images every day, but only once...
<FilesMatch "\.(png|jpg|gif)$">
Header set Cache-Control "max-age=86400, public"
</FilesMatch>

garrettw's picture

funny!

That's funny.
About that no-caching thing: what do you mean by "working on"? Are you "developing" such a server, or is your site hosted on a server "running on" that configuration?
In other news, maybe one of these days I'll start working on (that is, "developing") my CMS again (which I have dubbed "Talkwork"). When I do, I'm sure I would value your help, if you're interested.
Lastly, I recently ran across a program called Namebench, which benchmarks a bunch of DNS servers to see which one is the fastest for your connection and location. I ran it on a Cablelynx connection and found that Google's new Public DNS service (which I didn't know existed until I ran this tool) was the fastest for me, followed by the default (Cablelynx) stuff, then "Sprintlink" in 3rd, and OpenDNS as the 4th fastest. Actually it only gives you a top-3 recommendation, but I added OpenDNS to my config too since it ranked fairly fast – and because I've used it in the past.
Anyway, it's a really neat tool and it generates some interesting stats for your viewing pleasure. Have fun :)

Oh – I just noticed your random quote generator on the right. That was something I did very early in my website-coding "career" (?) and I continue to use, to this day. Definitely adds some flair. If you want, you're more than welcome to rip stuff from my monster list of quotes. (You might particularly enjoy the bunch toward the end of the file.)

Chris's picture

Server Fun

Yes, one of my customer's shared hosting plans does not automatically configure session variables for us (so we have to specify the temporary path before starting a session). They also forced every file to reload regardless of the browser's cache settings. It's been grand. Nose Smile

In terms of cool things, I've been developing a small library of JS and PHP functions that I hope to polish for general use. One function takes an entire HTML form, determines the table schema, and puts the data into the database. It can even use UPDATE instead of INSERT when there is duplicate data. The calculations might be slightly wasteful (not much) when we are talking about CPU cycles but it drastically improves development time. It also sanitizes input automatically.

Google created their DNS services because they thought ISPs were too slow. I am curious about their speeds compared to mine. Might have to take a look at NameBench.

Your quotes link told me my version of Firefox was outdated. Tongue

EDIT: Scratch the last part. The quotes work now.

garrettw's picture

browser issue

Yeah, I had forgotten to update my .htaccess file to allow Fx3.6 through -- so now it will allow 3.5 and 3.6.