Packtpub is celebrating their 2000th title with a BOGO sale!

I love Packtpub books!  I just had to spread the word about their milestone sale as it is a great opportunity for packtpub books lovers everywhere to acquire a few more titles. Hurry! The sale is for a limited time!  :-)


Known for their extensive range of pragmatic IT ebooks, Packt Publishing are celebrating their 2000th book title `Learning Dart’– they want their customers to celebrate too.

To mark this milestone Packt Publishing will launch a ‘Buy One Get One Free’ offer across all eBooks on March 18th – for a limited period only.

Packt is one of the most prolific and fast-growing tech book publishers in the world. Originally focused on open source software, Packt contributes back into the community paying a royalty on relevant books directly to open source projects. These projects have received over $400,000 as part of Packt’s Open Source Royalty Scheme to date.

Their books focus on practicality, recognising that readers are ultimately concerned with getting the job done. Packt’s digitally-focused business model allows them to quickly publish up-to-date books in very specific areas across a range of key categories – web development, game development, big data, application development, and more. Their commitment to providing a comprehensive range of titles has seen Packt publish 1054% more titles in 2013 than in 2006.

Here are some of the best titles across Packt’s main categories – but Buy One, Get One Free will apply across all 2000 titles:


Accessing a Private Method for Testing

Sometimes, I come across a private method in one of the models that I really need to test. Rather than try to change the way the model is written, I’ve found a way around this limitation using ReflectionMethod.

Suppose we have a class with a private method such as this one:

class MyClass { private function myPrivateMethod( $some_value){ $new_value = $some_value + 5; return $new_value; } }

Granted, that is a very silly method, but is only meant as an easy example. In order to be able to test this method, we can do the following:

$testMethod = new ReflectionMethod('MyClass', [...]

Quick Tip: Sorting arrays with array_multisort

Sometimes you need to sort an associative array in more than one way. Let’s say you have an array such as this one, representing the toys inside a toy box. The keys are the name of the toy and the values are how many of each we have:

$items = array( "balls" => 5, "toy cars" => 1, "ropes" => 5, "dolls" => 3, "jumping jacks" => 5, "tea sets" => 2 );

And you need to sort this array in order to print a list displaying the toys of which we have the most showing up first. Those toys [...]

Quick Tip: MySQL Subqueries

This is a little tip that a co-worker shared with me some time ago and has made my life so much easier. I am often faced with a situation very similar to this: let’s say we have a table called users_rooms that includes the columns user, room, deleted, created and modified. I am required to insert new rows in this table where the values of the room column for user 123 should match all the available ones for the same column for user 128. This is something easy to do with subqueries, like this:

"insert into users_rooms (user, room, created, [...]

Moving and Deleting messages with PHP IMAP

PHP provides a great deal of functions to operate with the IMAP protocol, but implementing them isn’t always so straightforward. For example, how to best mark multiple messages as read or unread, move them to a different folder or mark them as deleted without running into a situation where some of them “return” to your inbox next time you sync to the account or worse, you end up marking as deleted other messages you did not intend to. This is actually a real-life issue we ran into at work.

Given a sequence of messages, you have a message number and [...]

Advanced Web Application Development with Express

A few days ago, I was given a copy of the book Advanced Express Web Application Development from Packtpub to review it and I’m pleased because it is a really good book. As I mentioned before, I got interested in Node.js because I learned that it could be used to do testing on the UI, which is one of the most difficult things to do for us at work right now, giving the ever changing nature of our application.

Although not completely unfamiliar, I am a newbie when it comes to Node.js, Express and related technologies. I have read my [...]

What I’m reading this month

What started as curiosity over better ways to test in the UI has become a great interest in developing web applications using Node.js and Express.js. I’ve already gone through my share of tutorials and examples, and this month I was also lucky enough to be given the opportunity to review a new Express.js book by The book is called Advanced Express Web Development. It looks good so far. I will be posting a review here very soon. In the meantime, if you are interested, you can get it from Packt here:


Interesting Little Video

One of my friends posted this little video online and I thought it was at the very least cute and funny. The animation is also very well done. Of course, any similitude with people or events of real life is pure coincidence. LOL Well, I’ve never waited in line to buy a new iphone or ipad, I don’t even own one…



Accessing the value of a private property for unit testing

I was recently given the task of writing unit tests for a function that instantiates a helper class and stores it in a private variable. It wasn’t hard to generate a mock for the helper class and stub its methods, but accessing the value of that private variable and setting it to the newly generated mock proved to be a bit tricky. Remember that you simply can’t access a private variable, if not from inside the class. Not even a child class can have access to it.

What worked for me was to use the PHP Reflection API, more particularly [...]

Testing ala Sahi

I have recently begun writing tests for the UI of our web application at work. We use a tool for automation of web application testing known as Sahi, mainly because it’s reliable, fast and easy to use. With a little guidance from an ever so patient co-worker who’s been working with Sahi for a while, I’m quickly getting the hang of it and using it effectively to produce and run my first tests. Yay!

Although Sahi allows you to record your interaction with the UI in order to facilitate scripting your tests, I’m learning that the process of crafting an [...]