Page 18 of All Articles

Stop Accommodating Shortcomings

I came to a very liberating conclusion the other day. I need to stop fucking around with MySQL, or any other RDBMS, and fully embrace a NoSQL server as my primary data store. I’ve been a huge fan of Redis for quite some time but the fact that everything lives […]

How to connect to MongoDB using PHP

I’ve previously discussed installing the MongoDB module but have yet to touch on how to actually do anything past the install. The first thing to do is to connect to the MongoDB server. This can simply be done like this: $client = new MongoClient(); This will connect to the default […]

Thoughts on API design

I recently had the opportunity to have a discussion about API design and RESTful services with Vasusen Patil. I’ve also been having quite a few conversations of similar nature with Justin Davis over the last few months. These types of conversations are some of my favorite because, for the most […]

How to merge two sorted PHP arrays without array_merge() or sort()

I’ve had this question come up a few times in the past on interviews, how would you merge two sorted arrays and keep their sort order intact? The easy / PHP answer is to simply use array_merge() and then sort() the resulting array. Technically this works but the whole point […]

No, I will not fix your computer

I abandoned all of my seemingly witty shirts a while ago, but I’m starting to think I need to pick this one up. At the very least, the mug perhaps. It’s not because I don’t want to help people, hell my tech career started in support. It’s because the problems […]

Visibility in PHP

Visibility of functions and properties is very important when you are attempting to lock down certain aspects of an object. In PHP there are three levels of visibility, public, private and protected. Let’s take a look at what each one means. Public Public is the easy one. It’s the default […]

The definition of “done”

For me, “done” means that something I have been working on is to the point that I no longer have to work on it, indefinitely. Depending on the nature of the task it could also mean that it’s been shipped to production and again, no longer requires my efforts. I […]

Simple PHP i18n internationalization and localization class

As sites and system grow and scale, the need for internationalization and localization (i18n and L10n respectively) of content becomes a necessary task. There’s not much to it on the surface, you need to be able to serve up the same content in different languages. This includes abstracting out words […]

Stop making it so hard for us to share your content

Hey you! Yes, you. You with that blog over there. The one without any sharing widgets whatsoever. Do you really think your content is so fucking special that people are going to go out of their way to copy and paste the link to share it? You expect us to […]

Debugging Invalid XML in PHP

SimpleXML with all of it’s faults is still a great way to interact with XML. Most of it’s shortcomings are related to debugging and how it handles invalid XML is no exception. Let’s take a look at what happens when we load an invalid XML string: $xml = " <?xml […]

Writing unit tests for legacy code

I think one of my biggest gripes with adopting that TDD life is that I feel I’m in the minority with my friends even though the concept appears to be quite mainstream these days. One of the common pushbacks I receive is that it’s hard to write unit tests for […]

Upgrade from PHP 5.3 to PHP 5.6 on Ubuntu 12.04 LTS

Last week I posted a call to action to help sway Ondřej Surý into continuing to support Ubuntu 12.04 LTS with his amazing PPA for the latest and greatest PHP versions. Ondřej was kind enough to take the time to backport the PPA and without ado, here’s how to get […]

My top 10 tips for new bloggers

I’ve been blogging every single week for over a year and a half and have been constantly egging my peers into jumping on the wagon. Within the last month both my friend Justin Davis and Francis Suarez started up blogs. I’m full of advise on the matter and have been […]

Call to Action: PHP 5.6 on Ubuntu 12.04 LTS

I’m going to take a break from posting code snippets and how-tos to draw attention to the fact that PHP 5.6 may not be coming to Ubuntu 12.04 LTS by way of Ondřej Surý’s amazing PPA. Yes, you can still compile PHP from source, but as you may already know, […]

Upgrade to PHP 5.6 on Ubuntu 14.04 LTS

PHP 5.6 is finally here and if you’re on Ubuntu 14.04 LTS you’re stuck with an older version of PHP. If you want to take advantage of the new awesomeness, you can do so very easily thanks to a PPA. If you’ve never added a PPA before, you will want […]

jQuery plugin to calculate read time

I love hosting my blog on GitHub by way of Jekyll but the Liquid templating system is far from a robust scripting language in my opinion. With the rise of Medium, I’ve been seeing the read time on more and more articles and figured it was time to add the […]

Fizz Buzz in PHP

Fizz buzz is a fairly common screening question to help sniff out non-programmers during the interview process. The task is to print out numbers 1 through 100 but for multiples of 3 print out “Fizz” instead of the number and for multiples of 5 print “Buzz” instead. If the number […]

Are GAWMiners Hashlets worth it?

I’ve only been the owner of a Hashlet from GAWMiners / ZenCloud for less than a week and I’m liking what I’m seeing thus far. My initial investment was a mere 15.99 USD for a 1MH/s Hashlet and honestly, the purchase itself was the most rocky situation. Seems with the […]

How to execute an HTTP POST using PHP cURL

I’ve been doing a lot of API integration recently and cURL ends up being exceptionally handy when you are POSTing to an endpoint. Fortunately using cURL in PHP is really easy: // Sets our destination URL $endpoint_url = ''; // Creates our data array that we want to post to […]

10 office pranks you should try at your own office

Before I start talking about office pranks, I want to give a shout-out to Noah Kagan for his post We Analyzed Nearly 1 Million Headlines. Here’s What We Learned post. The truth is, this post is just a list of some of the notable office pranks I’ve either orchestrated, witnessed […]

Why work so hard to stay at the bottom?

Not a day goes by that I see a headline about the need for a minimum wage increase. I read about staged sit-ins, protests and boycotts. I see people investing a ton of time and energy to remain the lowest paid workers in the country. I generally keep my political […]

Looping through a date range with PHP

Looping through a date range isn’t as simple as looping through an array with foreach but it doesn’t take much additional code to get the job done. To loop through a date range you will need to use a loop (I prefer a while loop) and increment the date by […]

Tabs vs. Spaces: I'm switching sides

It’s not very often that I make a drastic change to my coding style but after using tabs for my entire life, I am making the switch to spaces. My go to defense for using tabs was that they are more flexible because they allow developers to choose their own […]

Difference between break; and continue; in PHP

The topic of break and continue came up the other day and I thought it would make for a good blog post. You’re probably familiar with break moreso than continue because it is part of a switch statement’s syntax. Both break and continue can also be used inside of looping […]

Review: Sprint WeGo

A few months back when I picked up a Nexus 5 for myself, I decided to go ahead and get our 7-year-old daughter the Sprint WeGo phone. For those that are not familiar with the device, it’s a very basic telephone that comes standard with some great parental features. These […]