Je me suis désabonné de l'annuaire Pages Jaunes (un petit geste pour l'environnement)

Aujourd'hui, j'ai demander de ne plus recevoir d'annuaire de pages jaunes. J'utilise internet et l'application Pages Jaunes sur mon iPhone de toutes façon.

Faite-le vous aussi!

http://distribution.ypg.com/fr/FR/Home/Index

Removing extra whitespaces on bunch of PHP files using Ack-grep and Emacs

As a follow up to my own post on Indentations: Tabs vs. Spaces, I wanted to cleanup a number of files that contained a lot of extra and useless whitespaces that were getting on my nerves.

I did not want to spend too much time on this so, here is what I did.

First, here is what I have in my .emacs files that is needed for this to work:

(require 'whitespace)
(setq-default global-whitespace-mode t)
(setq-default whitespace-modes (quote (php-mode c-mode)))

Command cache-clear needs a higher bootstrap level to run

I created a new VMWare appliance for the project that I am working on. I deployed the project and created the DB and all that and when I was trying to access the site, it told me the site was offline. I decided to install DRUSH and clear the cache and see if I can find more information about this problem.

Once I installed drush, I got this error:

[roychri@p1695vm drupal]$ drush cc
Command cache-clear needs a higher bootstrap level to run - you will need invoke drush from a more functional[error]
Drupal environment to run this command.

... how the internet works

This is a great post about how the internet works. MUST READ :)

Because it is capable of describing the location of something anywhere in the world from anywhere in the world. It’s the foundation of the web. You can think of it like GPS coordinates for knowledge and information.

http://tomayko.com/writings/rest-to-my-wife

Install pear without network (no internet access/offline)

I was faced with a problem. I wanted to use drush on a server that had no internet access. Well, I could connect to it but it could not (for security reasons) connect to the outside world.

Drush requires PEAR's Console_Table and that in turns requires PEAR, obviously.

First I downloaded all the PEAR packages that I needed from my desktop and then I uploaded them to the server using SFTP. I could also have used a USB key if I had physical access to the server but that as not my case.

The files that I downloaded were the .tgz files that I found here:

Using Drush without json_decode/json_encode enabled.

Did you know that drush requires json support to be enabled in php?

Well, I did not until today.

Fatal error: Call to undefined function json_encode() in /home/drush/includes/output.inc on line 380
Drush command terminated abnormally due to an unrecoverable error.
Error: Call to undefined function json_encode() in /home/drush/includes/output.inc, line 380

If you have root or if your in good terms with your sysadmin, the good solution would be to enable json to your php. Either recompile php or install json using pecl or using your distribution's package manager (yum, rpm, apt, whatever).

Well, I did not have root on that machine so here is what I did.
First I installed pear's Services_JSON package.
Second, I created a file called json.php with the following content found here:

<?php
if ( !function_exists('json_decode') ){
    function json_decode($content, $assoc=false){
                require_once 'Services/JSON.php';
                if ( $assoc ){
                    $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
        } else {
                    $json = new Services_JSON;
                }
        return $json->decode($content);
    }
}

if ( !function_exists('json_encode') ){
    function json_encode($content){
                require_once 'Services/JSON.php';
                $json = new Services_JSON;
               
        return $json->encode($content);
    }
}

Then I created a /.drush/ folder in my home directory and I created a file called php.ini inside that folder.

mkdir ~/.drush
emacs ~/.drush/php.ini

You can use vi if your one of those :)

I put the following inside the file:

auto_prepend_file="/path/to/json.php"

where /path/to/ is the real path of where I put the json.php file above.

That was all and now I could use drush!

Help! Something is broken...

When you have access to a unix server and someone asks for help and you do not know about all the possible log files that exists, here is a command that will show you ALL opened file for append or write.

ulimit -n 9999 # In case there is more than 1024 files!
tail -vF $(/usr/bin/lsof -n | egrep -i '[[:digit:]]+(u|w).*reg' | awk '{print $9}')

Thanks Marius! :)

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.

Syndicate content