Tag Archives: Php

A thing or two about style guides

A style guide should be chosen when working on a solo project or with a team. This keeps the code manageable when you or your peers come back to work on it in the future. It doesn’t matter which style guideline you choose as long as you stick with it. In a sense, writing clean code will also help reduce technical debt. Below is a collection of style guides that I collected over time. Some important rules are repeated in other styles. It’s nice to keep consistency (to a degree) if you are writing in multiple programming languages but ultimately it’s best to do what’s best for each language.

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”

Martin Fowler, Refactoring: Improving the Design of Existing Code

Read More
Feb 8, 2015 2 min read

Working with Apple's iOS image orientation

Using PHP and ImageMagick

You might notice pictures taken with an iOS device (iPhone or iPad) look like they are not rotated properly when transferring them to another device or software. This happens because the device is held at a certain angle when the picture is taken and it’s up to the software at the receiving end to display it however it wants.

Apple’s camera will write orientation info into the exif headers of images taken and you can rotate it accordingly.

Here is an example of rotating an image using PHP with the ImageMagick library;

Read More
Oct 17, 2014 1 min read

Chef Gearman Cookbook v0.1.0

A little Gearman cookbook I put together for Chef. Supports installing multiple versions by source. Also has a recipe for the PHP extension.

Grab it from GitHub!

kthxbye.

Read More
Jun 12, 2014 1 min read

Type Casting String by Concatenation Performance Test in PHP

The purpose of this test is to see if casting an object to a string by concatenating it was actually slower than using normal type casting. Here is my source:

Read More
May 8, 2014 1 min read

How to install Gearman for PHP on OS X

Setup Gearman for PHP with OS X 10.9.2 Mavericks using brew. This requires libgearman and the easiest way to get it is probably to install gearman through brew, of course.

Read More
Apr 23, 2014 1 min read

How to upgrade to PHP 5.4 on Ubuntu 12.10

PHP 5.4 is not in the standard Ubuntu 12.10 repositories. We will use a backported version of PHP 5.4 by configuring a 3rd party PPA. Open a terminal and run the following commands:

Read More
Mar 31, 2014 1 min read

How to create a MongoDB ObjectID from a timestamp using PHP

This is a useful tidbit of code to have until PHP adds this feature into their MongoDB extension. I stumbled on an example on Stack Overflow illustration showing how to do this and rewrote it in what I think is a slightly more modern way that does the same thing.

Read More
Mar 31, 2014 2 min read