Swapping Out Real Emails On A Page For Screen Shots

Recently, I needed to put together some screen shots of output from a custom ads plugin I was working on. During the testing, I had several user accounts that all had various real email addresses of mine. I obviously didn’t want these in the demo shots, but I didn’t really want to go edit all the accounts or have to doctor the images to blur the details. What to do?

Thankfully this was on a WordPress site so jQuery was available. By dropping a couple of lines of JS in the console, I was able to change every instance of the real address on the page with bogus info. This let me take my screen shots without worrying about anything.

It couldn’t have been easier to do. The addresses were all in anchor tags within table cells. This made the selector easy to specify and the task took just a couple of minutes.

jQuery("td a:contains('user@real-domain.com')").text('fake.name@bogus-domain.com');

Hope this helps somebody else.

When “The Best” Isn’t Worth It

I was hanging out in the Laravel #Slack channel (as I frequently am) and saw somebody post the following about frameworks (PHP vs JS):

I was advised to master one and be better than everybody at it.

It made me think about how potentially crippling it could be to actually try to be “the best” at something….anything. Don’t get me wrong, wanting to continually learn more and be more productive, efficient, elegant, innovative, etc. are all really great aspirations that I think most developers I know share in.

However, unless you handle failure really well, “being better than everybody” will likely be a road fraught with let downs as you will always find somebody who’s better at some aspect of this business. The struggle to be “the best” will necessarily mean you would have to constantly compare everything you know and do to others. In those comparisons, it would be far too easy to feel down every time you see anyone who knows something you don’t.

Focus instead on delivering what your customer or business requires in a better, more efficient, and/or more elegant manner. If you can focus your efforts on delivering above and beyond what’s expected, under budget ($ or time), you’ll find that you’ve made yourself much more valuable.

There’s likely only a small handful of positions for “the best” developer, but thousands of openings for the developer who has built a reputation for delivering when it mattered. You become THAT developer, and you’ll never be without a job.

Addendum: I’m not trying to discourage anybody from following their dreams. There are things you certainly could be “the best” at. Every world record holder in the Olympics was the best at one time. That’s quantifiable. But this industry? How would you even begin to measure?

The Day the Bacon Attacked

For those who don’t know, I work remotely for a Japan-based company called Delfi-Net.  Every day at 9am Japan time, we have Standup — a call to discuss what’s going on and for each team member to bring others up to speed with our various projects.  This is all normal and happy for most developer types.

I’ll also let you know that my family and I live on a small farm here in north Arkansas with a myriad of livestock and critters of all sorts.

I tell you those two things so I can tell you this….

During today’s Standup, my awesome wife thought it would be fun to bring a miniature potbelly piglet into my office and put it right next to my head.  Let’s just say this went over about as well as could be hoped.  Thankfully this entire exchange was recorded, and I get to present it for you here.


      Standup with Pig Surprise - 14 July 2015 - Bill Wheeler

All That Glitters Is Not OOP

I’ll start by telling you that I’m an old developer by most visible standards.  When I started with PHP 3  after coming from Perl, register_globals was considered a good thing and articles online would tout how easy it was to deal with form vars because of it.  Fast forward a bunch of years and the concept doesn’t even exist anymore.  It’s much better for security of course; I’m just using it to point out how things change and progress.

For a time, I was finding myself without regular income, so I started looking around at the current programming world and was feeling very discouraged.  I’ve churned out tens if not hundreds of thousands of lines of code over the years and feel very confident in my abilities to solve peoples’ problems, but it seemed with so many new things (and more new things every week), that I wouldn’t ever be able to keep up.  It was depressing.

In the “modern PHP” world, everything is Frameworked, Composerified, Autoloaded, Injected, Inherited, etc.  That’s a good thing overall, but it’s not everything that is PHP.  The problem is that so much code still out there running the web sites of the world don’t use all, if any, of these things.  And not every task that needs to be done needs to use them either.

Then I started reading more and saw that some of the really big names in PHP aren’t so super gung-ho on big frameworks for everything either.  I like hearing Rasmus Lerdorf say that his favorite framework isn’t necessarily a framework at all, but whatever is the best tool to get the job done at the time.  Cal Evans said something much along the same lines in an interview with 7php.com.

Most of what I’ve been doing for the past few years revolved around PHP apps that employed some OOP principals and design patterns, but not what you see today.  I had to figure out what to do to get what I wanted with them.  And I think that goes for a huge portion of the internet still.  There are thousands of coding projects out there that need work done but there’s no budget for a ground up rewrite in Laravel or Symfony or Silex, etc.  Instead, they need some modifications or additions to solve a particular problem.

The (potentially sad) reality is that there are millions of successful web sites on servers still using PHP older than 5.2 running hundreds of millions of lines of procedural code that’s not ready to be replaced quite yet.  Somebody has to be there to support and help fix them.  That somebody may be an up and coming junior programmer, but it may be an old fogey like me too, so don’t be quick to judge without knowing what you’re dealing with.

Read the Manual!

I’ve been coding PHP for several years now.  Granted, I’ve learned a lot by taking apart other people’s scripts and applications over the years, but there is still no substitute for reading the manual!

It may seem boring or a waste of time, but if you want to be good, take some time at least once a week and read through the PHP Function Reference.  The reason this is so helpful is that the more functions you can expose your mind to and the more often you do it, the more likely you’ll know what function to use to accomplish your task at hand.  It’s been said many times that with any programming language, there are at least a half dozen ways to accomplish something — PHP is no different.  So chances are there’s a built-in function to do what you need.

If you don’t really know where to start, I’d suggest starting with Strings or Variables then move on to Arrays.  One thing you’ll start to notice as you read the examples is that most functions will reference other similar or complementary functions.  And you can click back and forth between functions as you build a grasp of how to do different things in PHP.

Also, at the bottom of nearly every function will be many user-contributed comments with code snippets, etc.  These are a great way to learn how to use the function in question or even ways to mimic that function but with more power or flexibility.

Don’t try to force yourself to learn the exact syntax for every function, the main goal is to familiarize yourself with what the various functions do so that when you need one, you’ll at least know where to look.

I hope that somebody gets some value from this first post.  And I hope that future posts will be even more useful as I find other ways to let some of the code-induced steam out of my noggin.  Thanks!