Tuesday, September 15, 2009

Snow Leopard and Symfony

Last week I performed the upgrade to Snow Leopard. As a Mac newbie (recent convert from Ubuntu), I'm working through the upgrade in Snow Leopard to PHP 5.3. Due to our web hosting environment at this time we can't make the jump to PHP 5.3.

After the upgrade of Snow Leopard, on the command line I started to receive the message:

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function.

This morning I needed to work through generating a couple of tasks for our application. Trying to fire up a task generated the following error:

Unable to open PDO connection [wrapped: SQLSTATE[HY000] [2002] No such file or directory]

My solution was I needed to downgrade my local install to PHP 5.2. I'm all for running the latest and greatest PHP, but now is not the time. I work on a Macbook with MAMP installed. Understanding I am approaching this from an Ubuntu perspective and there might be a better way to accomplish the following. Remember attempt at your own risk....

  • The php executable is location at /usr/bin
  • I copied the php executable to make sure I could jump back to PHP 5.3, I ran "sudo mv php php5.3", renaming php to php5.3 in the directory.
  • Then I want to create a symlink to the MAMP php version "sudo ln -s /Applications/MAMP/bin/php5/bin/php php", creating a symlink php which points to the MAMP installed version.

Now running Symfony command line commands I'm using the php executable that ships with MAMP. I hope this helps.

Monday, June 23, 2008

Audible on Ubuntu

As an avid listener to the Twit network podcasts, each show typically is sponsored by Audible. As an Ubuntu user Audible has been a no-go. Audible software is available for Windows and Apple.

In looking for solutions for Ubuntu you will typically find a couple of solutions and/or opinions (some of the comments in this post highlights the following solutions):
  • Since the files are DRM'd the most common response it the DRM is a show stopper for many Linux users. Many Linux users disregard Audible as easily as Audible diregards requests for a Linux client.
  • Use a virtual machine or dual boot in Windows and burn CD's
I can understand both solutions. Secondly without eough demand to warrant development, it's not Audible's fault for not providing a Linux client.

Still I wanted to see what I was missing with Audible. I found this post which describes using Wine with Audible and Firefox to create a workable solution.

The added comment to the post makes this a great solution. Based on the comment I created an Audible.sh file containing:

#!/bin/bash
env WINEPREFIX="/home/ja/.wine" wine "Z:\home\ja\Audible\Audible\BIN\AudibleDownloadHelper.exe" $*

Make the above file executable (right click, permissions, check the make this executable then close).

Now log into your Audible account, go through the process of selecting a book, check out, then goto your library. By clicking the download link, Firefox provides the 'Save As' dialog. Select the above shell program in the 'Open With' options. This then fires the download manager and downloads the file. When complete the player launches and your good to go.

The above solution will allow Linux users to try the Audible service.

Tuesday, June 10, 2008

New Laptop

A year ago I purchased a Dell Inspiron E1505 laptop as soon as the Ubuntu pre-installed option was available from Dell.

With all the hype over the Apple Worldwide Developers Conference, I wanted to review the current status of laptop offerings from the perspective of a developer who has flushed Windows from his arsenal of platforms (other than virtualized instances).

The second reason for the interest is I need a new battery for the Inspiron E1505, I'm down to around 30 minutes running minimal applications. A new 9 cell battery is just under $300, or roughly 10-20% the cost of a new laptop (which will come with a 9 cell battery).

I am comparing high end laptops with roughly the following characteristics:
  • 15 inch screen, glossy (personal preference)
  • ~2.5 GHz dual core, to future proof the purchase a bit
  • At least 2GB of RAM, 4GB seems to make sense, again to future proof the purchase
  • ~200GB hard disk. The reality is most of my data is in the cloud, so disk size isn't that important.
  • 9 cell battery. I've found myself becoming more mobile, working in battery required modes more often.
I am extremely interested in a new Macbook Pro. A number of fellow developers have been using the systems and/or are moving to the Macbook Pro's so there is some extreme interest personally. After configuring a system to match the above specs at the apple store, I come up with a laptop for $2,699. Personal issues with closed development aside, kind of spendy.

I went back to the Dell store to check out their Ubuntu offerings. The first issue was their laptops are built with Ubuntu 7.10. Not a deal breaker, but a little disappointing right when I get a new laptop I will need to update the distro. Using their laptop customization tool I tried to build a laptop matching the above specs. I fell a little short. 2.2 GHz processors with 128mb video card was as close as I could get. The processor difference is insignificant to me, the video card is a big issue for me. 128mb nVidia is more horsepower than I need now, but I don't feel that future proofs my purchase. The price for my configured system came in at $1,700 with a $90 discount.

I have heard good reviews reagarding System 76 laptops. They have a great powerhouse comperable to the Macbook Pro, the Serval performance line. The only difference is I am configuring with a 200 GB drive versus the 250 GB drive on the Macbook Pro. The cost comes in at $1,743.

None of the above take into account shipping, which I understand could drastically alter the costs of the systems. The other consideration is there is an Apple store 5 miles from work, so repairs and support is a 15 minute car ride away. The Ubuntu offerings are community supported, or send in the laptop via UPS.

From a price perspective, the System 76 system to me is the winner, taking into account the vastly smaller video card on the Dell system. Ease of use, coolness factor for the Macbook Pro, is it worth $1,000 more? That is a question everyone needs to answer for themselves.

Personally I've invested the last 12 months in becoming an expert developing on my Ubuntu system. I know the quirks, I know the issues. Can I afford to relearn a new os (Mac OS)? I believe I will go with the System 76 system.

Monday, June 2, 2008

PHP 4.x to 5.2.6

I have one last client that was using PHP 4.x, upgrading has been in the works for a long time. The client uses PHP and COM to automate Excel and Word document generation. The classes that performed the automation did not work in PHP 5.x. There wasn't a compelling reason to goto the new version until PHP 4.x was end of lifed.

The upgrade went surprisingly well. A couple of PHP.ini settings and getting the appropriate PEAR packages installed was the majority of work. The one issue was with Excel and COM.

I'm posting below the change that I had to make to the code. From various Google searches I doubt the other 3 PHP developers on the planet using PHP and COM to talk to Microsoft Office will find the below helpful. Regardless here is the change:

  • I initially used the below to write values to a specific spreadsheet, the solution was found here:

    foreach($data as $key => $value ){
    $excel_cell = $Worksheet->Range($key);
    $excel_cell->activate;
    $excel_cell->value = $value;
    }


  • The cell->activate call was not working and I modified the code to the below, suggested here:

    foreach($data as $key => $value ){
    $excel_cell = $Worksheet->Range($key)->Value = $value;
    }


The refactored code is much cleaner and a positive step from a code perspective.

Finally, a stern warning from Microsoft that the process I'm using is a bad idea.

Thursday, May 29, 2008

Flex 3 on Ubuntu Hardy (8.04)

Finally found a post that got Flex 3 to work on Ubuntu Hardy Heron, the post is located here.

A couple of additional points or issues that I ran into:
  • I ran without sudo and received an ominous warning to read a flash player notice in the application directory. The file highlighted the fact that the system might not utilize the debug version of Flash. Figuring I was going to have an issue I removed everything and ran the install using sudo. Running as sudo caused some other issues to crop up. I went back and re-ran as a normal user, tested and everything was fine.
  • Starting Eclipse caused an error window to display, "Could not initialize the applications security component...", the fix can be found here (in short manually create a directory ./mozilla/eclipse).
  • The Eclipse download location mentioned inthe article can be found here.

PHP Coding Standards

With an article in April 2008 issue of PHP Architects magazine, there was an article that touched on coding standards. At PHP Architects 2008 conference in Chicago one of the sessions touched on coding standards.

I typically work individually or in a group of two on development projects. There are always differences in standards followed by programmers. There are endless debates on the intertubes on this subject. This post is not to sway anyone one way or the other. I have spent some time looking into two common recommendatiosn for coding standards, the PEAR and Zend coding standards.

Why with an if is the '{' on the declaration line and with a class or method the '{' goes after the return? My goal is to follow the coding standards on future projects to create a standard.

Upon quick review I do follow 90% of the coding standards, as do most of the programmers I work with. The one that will take sometime to digest is:

if ($a != 2) {
$a = 2;
} elseif ($a == 3) {
$a = 4;
} else {
$a = 7;
}

and

class Foo
{
/**
* WRONG
*/
public function bar()
{
return($this->bar);
}

/**
* RIGHT
*/
public function bar()
{
return $this->bar;
}
}



Why with an if is the '{' on the declaration line and with a class or method the '{' goes after the return? My goal is to follow the coding standards on future projects to create a standard.

Wednesday, May 28, 2008

Ubuntu Start Up Programs

Nagging issue that I never got around to look at was auto starting applications after a delay in Ubuntu. Depending on the location, my wireless might take a few seconds to authenticate to the router. This delay in some environments would trip up GMail notify and display connection errors. A small issue. After installing firestarter I would get an error dialog box stating that the connection was unavailable.

The solution was presented in an Ubuntu thread located here. So now I have an auto_start folder in my home folder with scripts for each application that requires a delay. In my instance firestarter and gmail notify. In Ubuntu under System->Preferences->Sessions I then point to the above scripts in my auto_start folder.

Not sure if there is an easier solution but the above solution works.