array_unique returns NULL

I am dealing with legacy code written by another team and someone asked me why his images were not showing up...

Took me an hour to dig that one out.

Simply because the optional second parameter to array_unique() was only added in php 5.2.9 and we were using 5.2.4 ... Therefore it was generating an error that was hidden (because of error_reporting) and returning null.

I removed the second parameter and VOILA!

Too bad the sysadmin does not allow us to upgrade PHP. :)

How to test bash scripts

I was coding a bash script that was giving me an error but the message was not very helpful.

After googling a bit I found out that I could ask bash to help me find where the problem was being generated.

bash -x yourscript.sh

Lenovo "Stand By" Stuck (solved)

When I put my levono T500 in stand by mode, I sometime do it quickly and unplug my usb keyboard and mouse and my external monitor while it is still going in stand by. It took me some time but I made a co-relation between that action and the fact that the whole system just hangs forever while going in stand by mode, forcing me to hard reboot.

Since I changed my habit by waiting that the lenovo is in stand by mode before unpluging my USB devices or unpluging my external monitor, I no longer get that problem.

Indentation: Tabs vs. Spaces

This is one of these archaic question.

Short answer: Spaces, and only spaces.

Long answer:

Origins
The tab key on the keyboard seem to have first been introduced with typewriters and then with computers. The original idea was not about indenting complex code structure. A long time ago, some people started to use tabs for indentation because of the disk space it was saving.

Concept

Disable cache on Chrome

As a developer, I often need to clear the cache to see my changes.

The best is when the cache can be disabled completly.

There are many options but here are 3 options that I consider like the best of the options.

Google is gaining ground over firefox (for me)

I am using less and less Firefox because

  • It's slow to start/load
  • It's bloated
  • It's a memory pig

I just found a GREAT chrome application for developpers.

https://chrome.google.com/webstore/detail/hgmloofddffdnphfgcellkdfbfbjel...

This chrome app allow you to test REST calls and it's similar to the firefox POSTER extension.

Easy to use and shows your parsed JSON/XML content.

The only thing missing is the ability to see the REQUEST headers. Right now it only shows the response headers.

Doctrine considers empty string as null (I mean Oracle)

We are on the last stretch of our project and we need to deliver soon.

Sometimes, we have to make concessions and compromises in order to make sure to deliver in time.
This means coding something that is not necessarly clean.

We wanted to use a column that could have 3 different significations.
The column was already a varchar2 and we needed to keep it that way for legacy reasons.

Reading book: Zend Framework 1.8 Web Application Development

I am currently working on a PHP project which involves creating web services with Zend Framework.
I started reading the book "Zend Framework 1.8 Web Application Development" and I plan on doing a review soon.

Drupal in Africa

I recently had the pleasure and honour to help rebuild the BDA foundation’s website using Drupal.
I would like to thank Julie Hinse from Comptabilité Carrier who recommended me for this contract.

Extracting SVN info from cli (command line)

For one of my project, I needed to have the SVN Repo URL for one of the file.

When doing svn info, this returns the URL in a readable format. I wanted a format that less likely to change over time (when I upgrade svn for example).

Without being set in stone, I think that an XML version of this information will less likely change! (Maybe I am wrong).

HURRAY, svn supports this!

$ svn info --xml

<?xml version="1.0"?>
<info>
<entry
  kind="dir"
  path="."
  revision="3097">
<url>https://svn.example.com/svn/projects/fubar/trunk</url>
<repository>
<root>https://svn.example.com/svn/projects/fubar</root>
<uuid>1a819d2a-f4ff-46bb-9fd0-7749d8846de9</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
  revision="3097">
<author>some.user</author>
<date>2009-12-04T08:24:04.996830Z</date>
</commit>
</entry>
</info>

I was building a shell script, so I added to be able to parse XML from the command line.

I found : XMLStarlet
http://xmlstar.sourceforge.net/

Ubuntu installation:

$ sudo apt-get install xmlstarlet

CentOS Installation:

  1. http://sourceforge.net/projects/xmlstar/files/
  2. http://www.dil.univ-mrs.fr/linux/dil/centos/5/

Here is an example on how to use it:

$ svn info path/to/file --xml | xmlstarlet sel -t -v 'info/entry/url'

Syndicate content