Archive for the ‘information technology’ Category

A Useful Bit o' PHP Code, Set Right

Monday, 16 June 2008

I came upon someone's ancient 'blog entry in which he or she attempted to present what would be a useful PHP function. Unfortunately, the code has a few bugs.

A dynamic webpage may seek data from various sources, including data passed by GET and POST methods (which is how web forms normally), persistent data in cookies (stored on the client but provided to the server with each visit), and persistent data on the server.

Towards that end, PHP maintains five associative arrays: $_GET, $_POST, $_COOKIE, $_REQUEST, and $_SESSION. ($_REQUEST combines the contents of $_GET, $_POST, and $_COOKIE.) To access a variable named user sent by POST method, one would refer to $_POST["user"], and so forth.

The 'blog entry in question may have been written before $_REQUEST was introduced; in any event, the author had two good ideas:
  1. Avoid errors resulting from trying to access variables that don't actually exist. If no variable user was passed by POST, then $_POST["user"] throws an error. To avoid that sort of thing, the author checks for the presence of the variable before attempting to access it.
  2. Combine the variables in $_SESSION, as well as those in $_GET, $_POST, and $_COOKIE. Indeed, session data is more analogous to cookie data than is cookie data to data transmitted by $_GET or by $_POST.
The problems with the actual code are these:
  • If the server is not maintaining session data, then the attempt to use $_SESSION will itself cause an error.
  • There is an attempt to get cookie data from the array $_SESSION.
  • In the aforementioned attempt, the array is treated as a function.
Here's a version of the code that fixes those problems:
function getvar($var_name)
{
  if (array_key_exists($var_name, $_GET) == TRUE) $ret_value = $_GET[$var_name];
  else if (array_key_exists($var_name, $_POST) == TRUE) $ret_value = $_POST[$var_name];
  else if (session_id() != "")
  {
    if (array_key_exists($var_name, $_SESSION) == TRUE) $ret_value = $_SESSION[$var_name];
  }
  else if (array_key_exists($var_name, $_COOKIE) == TRUE) $ret_value = $_COOKIE[$var_name];
  else $ret_value = ""; 
  return $ret_value;
}
PHP also provides analogous associative arrays for other global variables, but what unites the variable types of the five here is that they are commonly used in session-tracking — keeping data associated with a specific visitor as she moves through one's site. Possibly, getvar would be better named something else, if not distinguished by being made a member of some class of objects.

Bad Intentions Confirmed

Friday, 6 June 2008

I can confirm that the Robertson Bad Intentions is the song from WTTS that I wanted to identify. To-day, I received a copy of his Bad Intentions CD that was distributed to radio stations to promote Jimmy Hollywood; I listened to it a few minutes ago.

Matte Display

Friday, 6 June 2008

Speaking — well, writing, actually — of my note-book computer and its display:

Instead of replacing the original glossy display with another, I chose to replace it with a non-glossy matte display. Of course, I did this hoping for some improvement, but the improvement is substantially better than I had anticipated. For example, unlike before, the screen is now comfortably readable when (to conserve power) dimmed to the preset level for running on battery.

GeekEntrailAllFull

Thursday, 5 June 2008

Yester-day, the Better Business Bureau sent to me a copy of a fax in which Rod Pereira (Geek Available AKA GeekAvailable) asserted

Answering the issue under ID [here omitted], I would like to state that the computer was returned to him as soon as he showed up to pick it up on Tuesday, the 27th
As seen on the documents provided attached to this, I already sent him an email explaining that we actually dropped the ball on his particular case and saying how sorry I was for that
I absolutely refuse the reimbursement of any computer rental fees he could have had as it wasn't agreed under any circumstances
I informed the BBB that I'd received no such communication from him, that his communications to me since I'd contacted them had consisted largely of various misrepresentations, that vague admission to dropp[ing] the ball was not sufficient, that he'd not returned my computer before extracting an evaluation fee (the diagnosis of which evaluation was incorrect), and that the delay from Saturday until Tuesday didn't result from mere ineptitude and that I was plainly entitled to reïbursement for that.

Pereira can agree to repay me in the process, or we can go to court, in which case he will have to repay me and bear the court costs. I'd say that he should cut his losses.

Nothin' but Bad Intentions

Tuesday, 3 June 2008

Years ago, when I was pursuing a master's degree at IUPUI, I routinely listened to WTTS, which transmitted out of Bloomington but usually came-in quite clear, and which had one of the best play-lists of the many radio stations to which I've listened in my life.

They occasionally played a grim song, with lyrics such as

You've got nothin' but bad intentions
You've got somethin' to prove
You've got nothin' but bad intentions
Baby, it's your move
(or something very close to those) and made repeated use of a sample from Body and Soul (1947) where Charlie Davis (John Garfield) says What are you gonna do, kill me? Everybody dies.

But I couldn't remember who performed it; and, over the last several years, my googling of the lyrics or of the sampling have not identified the song.

Yester-day, I telephoned WTTS for help. I was told that the man to ask was Todd Berryman, but that he was on vacation until to-day. This morning, I called again and was promptly connected to Mr Berryman. He didn't have the answer at his finger-tips, but he ran various checks against references to which he had access, and gave me a short-list of candidates, one of which was Bad Intentions by Robbie Robertson.

To-night, I found that Robertson's Bad Intentions was part of the sound-track for Jimmy Hollywood (1994), and was released to radio stations to promote the film; and IMDb says that Jimmy Hollywood referenced Body and Soul.

There's still a tiny chance that this song isn't the one that I've tried to identify, but I'm really quite sure that, thanks to Mr Berryman and to WTTS, my question has been answered. (I've ordered a copy of the promotional CD, so you'll read about it if I'm mistaken.)

Rough Approximation

Tuesday, 3 June 2008

Quoth Google:

Results 1 - 17 of about 5 for "robby robertson" discography. (0.23 seconds)

A Less than Manic Monday

Monday, 2 June 2008

While I was visiting the Woman of Interest during the second week of May, I had a hold placed on my mail. During that time, a CD arrived dall'Italia. Unfortunately, some time between then and when the carrier attempted to deliver it, it went missing within the local postal facility. Finally, on Friday or on Saturday, I found a note in my mailbox declaring that they'd made a final attempt at delivery — the package requiring my signature (rather than that of the apartment complex manager) for some reason — and would hold the thing until 22 June. I wasn't thrilled, but I had two other reasons to go to the post office to-day anyway. I had a package to send to the Woman of Interest (which package holds two devilish rubber ducks and a fair quantity of jelly beans), and needed a small money order to pay for a purchase made by way of eBay.

Also in my box on Friday or on Saturday was a note that the complex office had a package for me, which package contained A Drawing Manual by Thomas Eakins, a volume of lectures by Ludwig Heinrich Edler von Mises that had been absent from my collection, and a DVD of In the Heat of the Night (1967).

At Bronx Pizza this evening, someone spotted a dollar left on the floor; I knew who had probably dropped it, and gave it to her. Not exactly the scenario of one of my polls, but quite close.

Later, at David's Coffee Place, I noticed a group of four people whom I've seen there on prior occasion, again discussing a business venture built around a social networking site. I won't name their site here, because I really don't wish them ill, but to me, they seemed foredoomed to failure. First, centralized social networking already has some heavy hitters, and if this new site has useful innovations then they are going to have a hard time avoiding imitation by those established players. Second, the group of four only have one actual programmer, and the others don't seem to have a prior background in the business side of any similar venture; further, the programmer doesn't seem to have the personal connections to the other three that they have to each other. Third, I over-heard mention of a failed attempt to secure funding, which would have stuck them with a 35% APR — such debt doubles in less than 2 years and four months.

Deleted from Kudzu

Monday, 2 June 2008

My latest review of Geek Available (AKA GeekAvailable) has been deleted from Kudzu and when I tried to repost it now, instead of absurd messages about failed searches I got this message:

We're sorry

Your previous review of this business location has been deleted by the Kudzu.com team.
You won't be able to write another review for this location.

For more on our rules regarding reviews, please see our Visitor Agreement and Guidelines for Writing Reviews.
So, plainly, Kudzu is an advertising site masquerading as a review site. No big deal. The more significant result of the exercise was earlier catching Geek Available lying about not using parts got from eBay; I'll be using that later.

ThiefAvailable (Yet Another Installment)

Saturday, 31 May 2008

On 27 May, after Geek Available (AKA GeekAvailable) moved their page on Kudzu, I posted a new review:

Beware!

Instead of buying repair parts through reputable channels, Rodrigo Pereira (owner of GeekAvailable) uses eBay account "rodrafael" (which, as you can check, used to be named "geekavailable"), to buy questionable parts from unreliable dealers, without telling his customers that he is doing so. When things go wrong, Rod doesn't take responsibility; he lies and stalls and misses appointments. My computer was supposed to be repaired in about 72 hours; thanks to Rod Pereira I lost two weeks.
To-day, Rod Pereira posted a new response with a new version of events:
Dear Daniel McKiərnan, this kind of part can be found with the same 6 months warranty for $30 on ebay or way more through Dell (not even counting on the waiting time). We didn't lie when we told you that we would be on shop on Saturday, but as you can see on our business hours, we don't open on saturdays and unfortunately you got to our shop too late without any calls in advance. We could never realize you would still come and couldn't wait for the whole day as we were only organizing the shop. We told you to come as we wanted you to have your laptop back ASAP. And actually, you didn't lose 2 weeks. You dropped your computer on May 15th and instead of having the parts here on 72business hours (on May/20th) it got here on May/23rd,[1] the same day you called yelling at the lady that you wouldn't wait anymore. Following my instructions, she just told you that would return the computer back to you as you demanded since you were extremely rude and unpolite. Regards, Rod
So I've tacked-on an addendum to my review:
Geek available lied to me about when the part was ordered; at one time (and this can be documented) they lied about not using eBay; at another time (and this too can be documented) they lied about having been open until 2:30 on that Saturday. I was there at 2:10 because I was told that they'd be open until 3:00 that day. (Had they instead said that they'd not be open, then I'd have gone on later Friday afternoon.) They lie now when they claimed that I yelled. And on the 23, the day that they claim that the part arrived, I called after mail delivery, was told that the part was not there. So either they were lying then (which would have been weird even for a dishonest business) or they're lying now.


[1]Mind you that Rafael Schneider Pereira told me on Tuesday (27 May) that he thought that the part had come-in on 24 May. (I rather doubt that it was even mailed by originalpartsglobal before 27 May, as he'd promised them tracking, but on 23 May they said that he'd not provided a tracking number.)

Laws, Sausages, and Wikipedia

Saturday, 31 May 2008

If you want a sense of the dynamic behind Wikipedia administration, then read

(If you're only going to read one of these pages, then I would suggest that it be the evidence page.) FWIW, I recognize some of the disputants as villains, and some of the others as either villains or rather great fools; I don't know, one way or the other, about the rest. It's quite possible that some are fine people, or that all are jerks.