Category: Software Development
-
How to error when setting undefined class properties in PHP
Perhaps you have a class and you absolutely don’t want anyone tacking new properties onto it once it’s been instantiated. To do so, you can use PHP’s overloading to catch the setting of a variable and raise an error accordingly. Here is the default behavior where an object can have…
-
That time I got ripped off on Flippa
In my defense, I’m a grown ass man and I knew exactly what I was doing. I was really intrigued by all of the “automated websites” that Flippa is overrun with and figured I’d set myself a very modest budget of 250$ and see what trouble I could get myself…
-
Ground up rewrites should be a last resort not the status quo
And even then, everything has to be so fucking abysmal that there’s no way to avoid it. The only time I’d ever condone a full rewrite is when you are completely abandoning an existing user base else you’re probably going to disappoint at least a good chunk of your users…
-
How to calculate Thanksgiving’s date with PHP
The topic of this post ended up turning into quite the programming exercise for me. In true PHP fashion, I was able to come up with 3 distinct methods to determine what date Thanksgiving falls on (and have another in mind but it’s just a crappier version of what I’m…
-
How to convert a negative number to a positive number with PHP
Converting a number from negative to positive is a pretty simple process using the absolute function abs(): $positive = abs(-123); // = 123 $positive = abs(123); // also = 123 Absolute returns a positive integer or float based on what you feed it. Because it only ever returns a positive…
-
My Experience with Wizpert
For those that aren’t familiar, Wizpert is a platform for chatting with people (Skype, Gtalk and their site) that are experts (referred to as “wizperts”) of specific topics. Earlier in the year I was sent a beta invite to become a wizpert in the category of PHP. I’m not a…
-
PHP’s HereDoc versus NowDoc
We’ve previously discussed how to assign variables and add in variables and all of that good stuff, but what about if you are dealing with a large block of text? There’s many approaches, most that require you to be mindful of escaping characters like simply using quotes to wrap a…
-
How to handle daylight savings time in PHP
If you’ve ever dealt with time in PHP you’ve probably been burnt by daylight savings time before (quite possibly yesterday ;). I’ve been there, waking up on the Sunday of the time change with an email about timestamps being an hour off or some other anomaly that ends up being…
-
Split an array into chunks with PHP
Array chunking is a great way to paginate large arrays and as I found out recently, makes it very easy to map a large array from Redis (by way of mget and/or pipelining) back to the original data. Chunking an array is the process of taking an array and splitting…
-
Temporary ufw rules or How I learned to stop scripting and love the shell
This post was originally planned to be a social commentary on the potential for riots this coming Novemeber (a/k/a The 2013 Food Stamp Riots a/k/a The Backlash of the Entitlement Society) but that seemed like such a fucking downer. Then the post was supposed to be about a Python script…