Sunday, November 1, 2009

Cakephp slow on Windows Vista

I use Vista for development. I find that cakephp development on Vista is painfully slow. Some of my coworkers use mac. I, being a (relatively) poor entrepreneur cannot afford a mac (yet), so I have no option but to keep waiting for page to load for sometimes upto 60 seconds.

I tried various ways to handle the problem - apc and xcache both didn't work with my version of php and apache on windows. Then one day it occurred to me - apc is just an elaborate in-memory cache, so why dont I put my cakephp cache files in memory?
So started search for a (free) RAM Disk. After trying few, I found Dataram RAM Disk was the only one that didn't crash on Vista. Those folks have done a good job with their product. I just need a 10M disk, so their free option works well for my dev server.

Next updated the core.php with:

      Cache::config('_cake_core_', array(
'engine' => 'File',
'path'=> 'E:/',
First few times were still painfully slow, but as cache filled up, the website now loads blazing fast. I can now again develop on Vista!

Monday, September 28, 2009

Android - detect device on Vista 64 bit

I spent few hours trying to get it to work. Here are the instructions that helped:

I got these from the following link:

First set up environment variable:
  1. In VISTA hit WindowKey + Pause\Break to bring up the system properties
  2. Click Advanced System Settings
  3. Under The Advanced Tab click Environment Variables
  4. Click the New button below the System Variables panel.
  5. In the New System Variable dialog box, type devmgr_show_nonpresent_devices in the Variable Name text box and 1 in the Variable Value box.
  6. Click OK, then OK again to close that Window
Now device manager:
  1. Now go to the device manager and go to View > Show Hidden Devices
  2. Look under Hard Drives and delete the HTC Android Phone USB Device
    ** This may show up as Generic Mass Storage **
    Note: When trying to delete the USB controller for the phone, have the phone plugged in first and see how many usb devices are actually conected. Once you disconnect the phone, you will obviously have 1 less connected device. Plug the phone in 1 more time and see which one is now connected and delete just that one. This will help avoid having to reinstall a bunch of usb devices.
  3. Look Under Portable Devices and delete the Android Phone
  4. Look Under Universal Serial Bus Controllers and Delete ANY USB Mass Storage Devices with a greyed out icon ... one if these is for your phone....
  5. Now with the device manager still open ... unplug and plug your phone in. When the window pops up, choose the android 1.6r1 usb driver directory for the device driver dialog.

Friday, May 29, 2009

vi - global search and replace?

I use vi heavily. Every time I have to do global search and replace, I have to do google search first. So documenting it here:


Saturday, May 2, 2009

Subversion - query what files will be updated

Another subversion entry!
Before I push changes out to the production website, I wanted to see what files will get pushed out. So I wanted to see if I run svn update, which files will be updated. I was hoping to find something like 'svn update 'dry run'" or 'svn update -query'.

So I looked hard at 'svn update' documentation but still didn't find anything. After a few searches on the manual, the command turned out to be on the least expected svn command. So, the summary is - if you want to see what svn update will do, run this command:
svn status -u

Thursday, April 23, 2009

subversion checksum mismatch problem

I got hit with the subversion checksum mismatch error again today. I had faced this problem couple of weeks ago, but just checked out a new copy to avoid fixing the problem at that time. Today I thought I would dig deeper.

I saw two variations:
svn: Checksum mismatch for 'aaa'; expected: 'xxxxx', actual: 'yyy'
Checksum mismatch while updating

I did few searches, and found that people had fairly complex set of steps to fix this. A simpler solution suggested was to check out a clean copy of your files, and then copy over all your changed files from the problem copy to your new copy. This was also painful for me because I had changes all over my working copy, and not just in the problem directory.

After looking at the svn files I found that the easy solution that worked for me (still involved checkout) was to
1. checkout a clean copy
2. for new and your problem checkouts, go to the folder where your svn mismatch error is thrown
3. in that folder, go to .svn folder
4. copy the entries file over from the clean copy.
5. svn cleanup on the problem folder
6. svn update

Sunday, March 29, 2009

phpUnderControl, CruiseControl and Jetty - No context on this server matched handled this request

I am tryin to get phpUnderControl set up, and for that I needed to get Cruisecontrol working.
I installed Cruisecontrol, set up phpUnderControl (there are enough instructions out there), but let me know if you want me to do a writeup)
After putting all pieces together in a VirtualHost, I go to and I get:
Error 404 - Not Found.
No context on this server matched or handled this request.

I looked around quite a bit, but didn't find the answer. Going to Jetty forums, finally, I pieced together that Jetty doesn’t get configured with a default context automatically. So here is what I did:
go to /opt/cruisecontrol (where I have cruisecontrol installed)
cd webapps
ln -s cruisecontrol root

Restart cruisecontrol and now loads the cruisecontrol nicely.

Wednesday, January 14, 2009

Ignoring svn entries in Cakephp

If you are trying to protect the svn related files so that they dont get shown in a browser, here is what worked for me after trying various things:

RewriteRule ^(.*/)*\.svn/(.*) - [F,L]

Making Cakephp and Shindig work together

So we decided to use Shindig for our web console widgets. There is lot of documentation on how to make shindig work as a virtualhost.

However, I didnt find complete documentation on how to make it work as a Alias (say
Where your Cakephp app runs at

So basically, we have cakephp running as virtual host and our gadgets/widgets will be provided by shindig using the url

Just few days ago, I read an interesting point in a performance article on Android code site - (paraphrasing) there are two phases of learning to developing on a new platform - first step is to make it work, second step is to make it work the right way.

So here is what I did and made it work - now you readers tell me how to make it work the right way.

I did svn co of Shindig in my downloads directory.
From there, I exported the following directories into vendors/shindig directory of my cake app.
- config
- features
- javascript
- php

So far so good.

In shindig/php/.htaccess file have the following line uncommented:
RewriteRule (.*) /shindig/index.php [L]

In shindig/php/config/container.php update as follows:
'web_prefix' => '/shindig',
'default_js_prefix' => '/shindig/gadgets/js/',
'default_iframe_prefix' => '/shindig/gadgets/ifr?',

In shidig/config/container.js, change all occurences of %host% with %host%/shindig. When I did it, there were 5 instances.

Now the shindig side is updated.

Next we need to tell Cakephp to ignore shindig urls. So, in your root .htaccess file
RewriteRule ^shindig/.*$ - [L]
Getting this to work took me a good part of the day. But hey, I now know how mod rewrite works, which I never bothered to learn till now.

Last part, we need to update the apache virtual host, so I added the following block:

Alias /shindig /dev/coolproduct/vendors/shindig/php
<Directory /dev/coolproduct/vendors/shindig/php>

Now, I put in a sample container and a widget, which I can load using:

Thursday, January 1, 2009

IPhone development - Global variables in Objective C

This one took me few hours, so I hope this post saves someone time.

So while developing our app for iphone, I decided to use static variable (probably a bad design choice, but I wanted to get the concept working and fix the code later). Anyhow. I found that using global static variables in Objective-C is obvious, but only if you know what you are doing.

For a newbie like me, who skimmed the Objective-C manual, and did read that there is something called retain, forgot about it when I actually needed it.

The problem was that I was setting the value in one View, but it was showing up empty on the other side. To add insult to injury, the iphone simulator showed all kind of weird exceptions, which I could not find any explanation yet. For example, it was crashing without any clear explanation. In few times, I saw NSCRArray length selector being invalid as reason for crash.

So, to have a global variable, this is what I did that worked:

In Globals.h:
extern NSString *gProp;

In Globals.m:
NSString *gProp;

In ViewThatHasABigWidgetThatSetsThisGlobalViewController.m:
{ gProp = [textFieldvalue retain]; }

In ViewThatUsesThisGlobalViewController.m:
{ NSString *textFieldValue = gProp; }