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'
And:
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 cc.myserver.com 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 cc.myserver.com 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 www.domain.com/shindig/xxxx)
Where your Cakephp app runs at www.domain.com/

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

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
add
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>
</Directory>



Now, I put in a sample container and a widget, which I can load using:
http://local.domain.com/shindig/gadgets/files/coolappsamplecontainer/coolappsamplecontainer.html

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:
-(void)someMethod
{ gProp = [textFieldvalue retain]; }

In ViewThatUsesThisGlobalViewController.m:
-(void)someMethod
{ NSString *textFieldValue = gProp; }

Saturday, December 13, 2008

Change MySQL Timezone

If your server is in a different timezone, a quick fix is to update the timezone of the server. I did that previously, but that turned out is not enough. I had to change the timezone of mysql daemon too. Here is how I did it:

SET GLOBAL time_zone = 'America/Los_Angeles';

SET SESSION time_zone = 'America/Los_Angeles';

Check it using:
SELECT @@global.time_zone, @@session.time_zone;

Friday, December 12, 2008

shindig and ssl

For our website, we are looking at some gadget/widget frameworks. First thing I tried was shindig from apache.

I had some trouble getting it to work, so I thought I will document the workaround, in case someone else has the same problem.
Note that in the end, the problem turned out to be different versions of openssl in apache and php, but here is how to work around it.

What caused the problem?
I like portable apps. So that whenever I change/upgrade my machine, I just copy my 'dev' directory to new machine, and my whole development environment is avaialble out of box.
I had set up apache and php about 2 years ago. Over time, as I played with various apps, lot of fat was added, not all of which jive together (notably openssl in this context).


So, to try out shindig, I downloaded the package and followed instructions from this site:
http://incubator.apache.org/shindig/#php

I turned on curl and openssl in php.ini, by uncommenting extensions for curl and openssl.

I configured virtal domain shindig.com and then I hit this url in a browser:
http://shindig.com/shindig/php/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml

I got this error message:
Shindig requires the openssl extention, see http://www.php.net/openssl for more info

Without SSL, I got the above message, but with SSL, apache showed alert with this message whenever I tried to start apache.
"The ordinal 3879 could not be located in the dynamic link library LIBEAY32.dll"


I tried various things, but then I didn't really need ssl at this point, so here is what I did. I went into the shindig code, and found that I could work around the problem. Here is how:

In shindig/php/index.php
look for openssl, and change it like this:

//$modules = array('json', 'SimpleXML', 'libxml', 'curl', 'openssl');
$modules = array('json', 'SimpleXML', 'libxml', 'curl');

That's it. When I will need ssl, I will handle that, but for now, I can keep playing with shindig.