Wise Advice from a Signature

I was searching for a quick and easy way of renaming an array key without altering the order of the array elements, when I stumbled upon this thread. While it didn’t help me accomplish my goal, I did enjoy Mark Baker’s signature:

Turn on error reporting!

I’d say his estimate is low, and that it is more like 95% of PHP problems can be resolved by turning on error reporting.

I think part of the issue is that everyone recommends “for security” to turn off error reporting on production websites. That’s fine I suppose, but only if your site has some way of telling you it is broken (e.g., an emailer that sends you error logs, an error message on the screen that you can see or someone will email to you, etc..). Just having a log isn’t enough. It is unreasonable to expect someone to waste time looking at an error log that should be empty. Spend 5 minutes and write yourself a little script to email the error log to you (or search Google and find one that is already pre-built), set up a cron, and then fix your bugs when they come rolling in.

I think what drives me even crazier is when people turn error reporting off to hide “safe” errors/warnings (i.e., non-fatal), like undefined index, undefined variable, or deprecated errors. The company I work for recently hired a contractor to help get us up to speed on an open source application. We turned on error reporting, and suddenly the app was spewing warnings left and right. Our contractor’s advice? Turn off error reporting.

But the error messages are there for a reason. If PHP is telling you that you are trying to use a variable or index that isn’t there, then it doesn’t matter if it isn’t a fatal error: your code is broken. It is trying to do something that doesn’t make any sense, and the code needs fixed. 99% of the time this is as easy as setting defaults on your variables or adding a few isset()’s into your code.

So please, for the sake of the children, turn on error reporting.

Review: Three Weeks to Say Goodbye

Just finished Three Weeks to Say Goodbye by C.J. Box.

The book is narrated by a man that recently adopted a baby girl with his wife. Life is great until the adoption agency calls to tell him that the birth father wants the baby back. To make things worse, the birth father’s father is a federal judge.

While things seem rather ominous at first, the first part of the book reads almost like a TV special. The judge and his son appear “evil”, but no more so than you’d expect from people willing to tear a child from her family.

But things get worse and worse. People die, people kill, lives are changed. Despite my continual attempts to guess at the ending, I failed pretty miserably until it was pretty much spelled out for me.

Overall, a very good read. I’d definitely recommend it.

Get it here at Amazon.com.

Conduit Toolbars

Back in April of 2007, I signed up with Conduit. They offer website publishers to quickly and easily create a completely custom browser toolbar that works with both Internet Explorer and Firefox. To make it even better, they pay the publisher when people use the toolbar!

To get me started, they gave me a $100 bonus, but the minimum payout was $250 (I could cash out earlier, but wouldn’t get the $100 bonus). I put the toolbar up on the Fake Name Generator and started to get users. I expected to quickly pull in enough to meet the $250.

I didn’t. I earned mere cents per day. It would take years to hit the $250 payout. So I gave up, took it off my website, and moved on to other projects.

Fast forward 2 years. I got an email asking me how they can reinstall my toolbar because they had to format their computer. I thought to myself, “what is this guy talking about? I don’t offer a toolbar…” But then I remembered Conduit! I pulled open my control panel and see $244.09 sitting in my account, only $5.91 from the payout!

I add the toolbar back to the Fake Name Generator, quickly get over 100 users, and about a month later have a pinch over $250 sitting in my PayPal account.

So what next? Well, the next day I get an email from a Conduit employee. They congratulate me on getting a payout, and show me a new toolbar for the Fake Name Generator that they put together and ask if I want to use it. I say “sure!” They then show me some updated code I can use to advertise my toolbar on the Fake Name Generator.

Did it work? Yes! Earnings from the day before the toolbar: $0.14. Earnings the day after: $0.72.

Am I going to get rich? No. Am I going to get paid every month? No. Does it matter? No!

With absolutely no effort, I’m going to get $50 every couple months. My users get a toolbar that they apparently enjoy. I get extra traffic to the Fake Name Generator that I might not otherwise get, perhaps increasing my AdSense or CJ revenue.

Want your own toolbar? Visit Conduit.

I Am Reading: Lots of stuff!

So you may have noticed that on the right of the site I list what I’m reading. Previously, I displayed this info using the I Am Reading plugin for Wordpress. It lets you put in a single ISBN, and it will magically display the cover and link it to Amazon.

But who reads only one book at a time?

Okay, maybe lots of people do, but I don’t. I “read” a book in the car (i.e., I listen to books on CD), I read a book at work, and I read a book at home. Sometimes I’ll have a couple books going at either work or home.

So I spent a few minutes digging into the I Am Reading source code to try to make it let me specify more than one ISBN. I spent about 15 minutes doing this before I realized I’m probably not the first person to want this functionality.

So I found a better plugin: Amazon Showcase. With this plugin I can list as many books as I want, and it will display a nice big thumbnail of the cover and link it to Amazon for me, and it didn’t require any source code changes. Yay!

Review: Variable Star

Just finished Variable Star by Robert A. Heinlein and Spider Robinson. It is a sci-fi book that was outlined by Robert A. Heinlein before he died, and then fleshed out by Spider Robinson many years later.

SPOILER WARNING!

The premise is pretty good. A poor college student finds out that his supposedly equally-poor college student girlfriend is a member of one of the richest families in the solar system. To escape the life they have planned out for him, he hops on a colony ship heading dozens of light years away.

Things are going relatively well until Sol (our sun) explodes, killing everyone and everything except for a few colonies and the colony ship that the protagonist is on. To make matters worse, an engineer that keeps the ship running commits suicide, leaving the ship stranded in space.

This is where things break down. Like the last book I read, it feels a lot like the author wrote a good story, but then got himself in a hole and couldn’t figure out how to get out of it. The ending doesn’t make any sense, because it is based entirely on several highly intelligent main characters being completely ignorant of what should have been completely obvious to them.

Overall, a good read though.

Review: The Brief History of the Dead

I recently finished reading The Brief History of the Dead by Kevin Brockmeier.

The book’s premise is interesting: After death, everyone goes to “the City”, a sort of waiting room between earth-life and whatever comes after death. The catch: Once everyone that remembers you dies, you leave the City and go to… I don’t know. The author didn’t think far enough ahead to say what happens after you leave the City. You just vanish.

In the book, everyone in the world dies but a single person. This means that the only people left in the City are those that this last individual remembers (thousands of people).

So was it a good book? Eh. The author frequently started down a path that would lead to a good story about different individuals in the City, but always stopped short of actually getting anywhere interesting. Which was frustrating. To top it off, the author’s conclusion to the book was extremely weak and left me thinking: “That’s it? It’s over?”.

Overall, it was a good book except for the ending. Like I said, I wish the author would have picked a storyline he liked and stuck with it, instead of starting and prematurely stopping half a dozen other storylines throughout the course of the book. I would have preferred a more conclusive ending instead of the copout ending he chose.

Unserializer

Added a new tool to the site: Unserializer.

Lately for my job I’ve been frequently needing to unserialize PHP data from a database to see what is inside. Sometimes the data is base64 encoded, sometimes it isn’t. So I wrote a little script that will base64 decode the data if needed, and then unserialize the data and then print it into a text box for me so I can see what the heck is in it.

Click here to check it out.

AddThis Social Bookmarking

On March 11th, I signed up for and added AddThis to the Fake Name Generator. I later added it to ABA Number Lookup and iPhone Mob Codes.

So far, I’m pretty happy with it. I haven’t seen any ads (although I do have AdBlock), and they include an analytics package that includes just enough info to be useful.

So how well has it worked? Well, people have shared my content over 420 times on Facebook, Digg, MySpace, Twitter, Delicious, StumbleUpon, and more. These may not drive a pile of traffic, but they do create a lot of good backlinks that increase my rankings in the search engines.

Anyways, I’d really prefer to roll my own solution, as the JavaScript that generates the AddThis button is a bit heavier than I’d like. Or if anyone has found a free open source solution, please let me know!

Zend Certified Engineer

PHP5 Zend Certified EngineerToday I took the Zend PHP 5 certification exam, and passed! As of writing this post, I am not in the Zend Yellow Pages yet, so if you click the icon it will make me look like a liar, but trust me, I passed. I’m in the Zend Yellow Pages, and you can click the ZCE PHP 5 icon to view my entry.

The exam is similar in format to the Zend practice tests (70 questions in 90 minutes, with multiple choice and fill in the blank answers), but the topics and content appeared to be fairly different. I’m not allowed to share the test with you, but I think it is alright to make some vague references to the type of questions I was asked, as Zend themselves share this information freely on their website.

Many of the questions were crazy easy, sort of in a “if you’ve ever used PHP then you should know this” category. For example, the basics of how loops work. Some took a little more knowledge, but should still be fairly easy to someone that has been programming in PHP for a few years.

Some were ridiculous and shouldn’t (in my opinion) have been on the test. For example, one question referenced the function strspn. In the PHP world, the usefulness/popularity of a function can generally be determined by the number of comments it has in the online documentation. This function has a whopping three: two explaining what the function actually does because the official description is confusing, and one trying to help people understand why they’d even want to use this function.

One thing I thought was interesting is that the test is probably easier for people who have spent a lot of time digging in other people’s code. For example, there may be 5 common ways of getting a task done. Some ways may be faster, or easier to read, or use a single function call, or whatever. If you haven’t had to spend time in other people’s code, then you may never have seen all 5 ways of getting the task done because you always do it 1 way. The exam expects you to not only be able to understand how the other 4 ways work if you happen across them, but ideally you know what they are before you go to the testing center.

If you’re an established PHP programmer and want to take the exam, I’d recommend taking the practice tests, determine what areas you are rusty in (for me it was PDO and XML) and study up a bit.

I have this post categorized in Goals because it has been a goal of mine to get this certification, Investing because it is an investment in myself, and Web Dev because, well, PHP is web dev to me.

A Local Vacation

I was driving home the other day when my cell phone rang. I didn’t recognize the number, but I always answer my phone. It was some lady from Colonial Crossings of Williamsburg calling to let me know I won a 2 day/1 night vacation in Williamsburg. I was like, uh, lady, I live in Williamsburg.

No you don’t, you live in Suffolk, she replied. I was like, no, I’m pretty sure I know where I live. I live in Williamsburg. She was like, oh, well we’ll give you $50, too. And a 3 day/2 night vacation you can use somewhere else. I was like, oh really? What do I have to do? She said I just have to listen to a 90 minute presentation about Colonial Crossings of Williamsburg.

Ah hah! A timeshare! Becca and I are saving for a house, so I had no fear of getting talked into purchasing, so after talking it over with her, we decided to go for it.

Then the “gotchas” started showing up. They required a $10 reservation fee. And $5 hotel tax (which actually ended up being $7.50, and almost $15 if we didn’t catch the billing error). The additional vacation was just another timeshare. And although we were led to believe that we’d be staying at the resort, we actually were put up in one of the shiftiest hotels in town. The carpets had dirt clumps on them, we found a child’s toy next to the bed, and the towel rack literally fell off of the wall. Shifty.

I later discovered (thanks to Google) that this is a sales technique. Once at the presentation, the salesperson can say somehing like, “Now, wouldn’t you rather spend your vacation here instead of a hotel?” at which point you think “wow, my hotel room really did suck” and you plop down $35,000.

Oh I didn’t get to the $35,000 part yet? Well, that is how much your fancy 1-week at the resort will cost. Plus quarterly maintenance fees that can go up in price without notice. Plus a yearly fee if you want the book that lets you trade your week at different resorts. Plus a few hundred dollars if you do want to trade your week at another resort. And that is just for the place you sleep. What about food? Souveniers? Admission to attractions? Trust me, it is not cheaper to buy a resort (at least not at the retail price).

But yes, we got our $50, so we came out ahead. I had to sign for my money, and was able to see what others got. Some were being paid as much as $120 to come listen to the presentation. I guess I should have held out for more money.

    I Am Reading:

    Image of THE MESSAGE OF THE JOSEPH SMITH PAPYRI - An Egyptian Endowment - the COLLECTED WORKS of HUGH NIBLEY - VOL 16 -
    Image of The Zeezrom Syndrome: Let Your Spiritual Awakening Begin
    Image of JESUS THE CHRIST
    Image of Negotiating Your Salary: How to Make $1,000 a Minute
    Image of The Source: A Novel
    Image of The Religion: A Novel (Tannhauser Trilogy)