Trick with variable name transformation in CakePHP

February 26th, 2010 Michael Stepanov No comments

CakePHP is a good PHP MVC framework. You can study it easily and start developing web sites very fast. But it has some disadvantages, of course. One of them is strange rules for transformation variable name when it set in the controller. Statement

$my_var = 'Hello world!';
$this->set('my_var', $my_var);

will make the variable $my_var accessible in your view:
<?php echo $my_var; ?>
The phrase ‘Hello world!’ should appear on the web page. But if the same operation is done using function compact, the result is not predictable:
$my_var = 'Hello world!';
$this->set(compact('my_var'));

Instead of ‘Hello world!’ you’ll see the warning about undefined variable on your web page. It happens because cakePHP removes underscore and makes letter, followed by it, capital. So, instead of $my_var you should use $myVar in the view:
<?php echo $myVar; ?>

Note that this bug appears in the cakePHP version 1.2. It’s already fixed in the 1.3.

Categories: PHP Tags: , , ,

Cyprus Winter

January 22nd, 2010 Michael Stepanov No comments

Cyprus Winter

It was rainy on Cyprus this week. That’s really good for island in general because we’ll have enough water on Summer. But it’s terrible for drivers.

Categories: Cyprus Life Tags: , , ,

How to rebuild Ubuntu package from the sources

January 7th, 2010 Michael Stepanov No comments

There are two ways (at least) to rebuild Ubuntu package from the source.
Using Ubuntu diff file and dpkg-buildpackage

  • Download source from Ubuntu repository.
  • Download Ubuntu diff file and apply it:
    patch -p1 < ubuntu.diff
  • Build package:
    dpkg-buildpackage -rfakeroot

Using .dsc file and debuild

  • Download .dsc file
  • Run following command:
    dpkg-source -x file.dsc

    Note, sometimes the archive with sources should be presented in the same directory!

  • Go to source directory and start building:
    debuild

In both cases the development packages should be installed first:

sudo apt-get install build-essential devscripts

Categories: Linux Tags: , , ,

Happy New Year!

December 31st, 2009 Michael Stepanov No comments

Happy New Year!

Categories: Personal Tags:

Gift idea: Plantronics Discovery 925

December 18th, 2009 Michael Stepanov No comments

discovery925_black

Bluetooth handset Plantronics Discovery 925 can be a really good Christmas present for web workers. It’s stylish and elegant. The headset offers a hight quality voice and adaptive noise reduction. But the most interesting feature in my mind is ability to connect to the mobile and PC in the same time. So, you can make mobile or Skype call using one headset.

The handset Plantronics Discovery 925 is available in black, gold, cerise, royal blush and majectic purple colors. So, it’ll suit both men and women. Its price an expensive a bit – $149.95, but it’s good investments.

Perfect notebook for travellers

December 18th, 2009 Michael Stepanov 2 comments

ACER   Aspire 1410

If I’d travel a lot I’d buy the ACER Aspire 1410 notebook. It looks like netbook and costs the same. But instead of Atom processor it’s equiped with stronger Intel Celeron. The rest spec includes 11.6-inch LCD display with 1366 x 768 resolution, GMA 4500MHD graphics, a 6-cell battery, 250 GB hard drive, and up to 4GB of RAM. The Acer Aspire 1410 offers a bunch of communication options – 802.11b/g/Draft-N Wi-Fi, Bluetooth, Gigabit Ethernet. Additionally it sports HDMI out (can be connected to the TV in hotel), integrated webcam (video chat with family, relatives and friends), 5-in-1 card reader and Dolby-optimized surround sound system with two built-in stereo speakers (have relax after meeting). It just misses optical drive but it isn’t so big deal I think.

The wight of the the Acer Aspire 1410 is just 1.35 kg, battery life is up to 6 hours and the price is €383. All of this makes that notebook the perfect choice for web workers who should travel a lot.

IMDB::Film-0.43 is released

December 15th, 2009 Michael Stepanov No comments

I just released a fresh version of IMDB::Film module to grub movie metadata from IMDB.com. There is not any new functionality in that release. Just bug fixes:

  • fixed issue with plot retrieving;
  • fixed retrieving of movie plot keywords;
  • fixed parsing rating and top 250 or bottom 100 movie property;
  • fixed issue with parsing AKA movie property;
  • fixed bug with getting movie ID from cached paged;
  • updated tests.

Many thanks for all who sent me bug-reports and patches. Grab that version and let me know if you find some problems there.

Add Google Wave into Thunderbird 3

December 13th, 2009 Michael Stepanov No comments

Wave

Thanks to Content Tabs now it’s possible to add into Thunderbird 3 some useful for you web tools. Here is a receipt from Quetzalcoatal how to integrate Google Wave in the Thunderbird 3. It’ll help to open Wave cleanly and conveniently inside one of tabs, and even keeps it open after restarting of Thunderbird.

[via Lifehacker]

Get Adobe Flash playerPlugin by wpburn.com wordpress themes