Posted on 09-06-2010 | By: Amit
Category : General, PHP
Tags: CakePHP, Frameworks, PHP, Programming
Few days back i was working on two separate CakePHP applications, suddenly there was a need to maintain session between these two separate apps working on the same domain. Let me explain a bit more.
I was having two apps (i)wishlist (ii) lighthouse
These are two separate apps under the root folder having the directory structure as:
/htdocs
/wishlist
/app
/config
….
/lighthouse
/app
/config ….
By default the sessions are created relative to the apps directory, and this was the problem i was dealing with, not a big thing but i spent a lot of time figuring this, but for you its will work like a charm.
Steps that i follow to make the two apps share sessions between them.
1. Edit “core.php” for wishlist and the lighthouse and add the line
ini_set(‘session.cookie_path’, “/”);
This is to direct the CakePHP app to create the session on the root
2. The Session.cookie name should be same for the two apps
3. The Session.salt should be same for the two apps
4. Security.level should be low in both the apps
This is it what is required. Let me know if you are still stuck with the things, happy coding.
Posted on 16-02-2010 | By: Amit
Category : Javascript
Tags: Javascript, JQuery, Programming, QUnit, Unit testing
QUnit is a powerful JavaScript unit testing framework that helps you to debug code. It’s written by members of the jQuery team, and is the official test suite for jQuery. But QUnit is general enough to test any regular JavaScript code, and it’s even able to test server-side JavaScript via some JavaScript engine like Rhino or V8.
If you’re unfamiliar with the idea of “unit testing”, don’t worry. It’s not too difficult to understand:
In computer programming, unit testing is a software verification and validation method in which a programmer tests if individual units of source code are fit for use. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual function or procedure.
This is quoted from Wikipedia. Simply put, you write tests for each functionality of your code, and if all of these tests are passed, you can be sure that the code will be bug-free (mostly, depends on how thorough your tests are).
Posted on 19-05-2009 | By: Amit
Category : Javascript
Tags: Bookmarklet, Firebug, Javascript, Programming
When working with events in Javascript, it is often easy to loose track of what events are subscribed where. This is particularly true if you are using a large number of events, which is typical in a modern interface employing progressive enhancement. Javascript libraries also add another degree of complexity to listeners from a technical point of view, while from a developers point of view they of course can make life much easier! But when things go wrong it can be difficult to trace down why this might be.

It is due to this allan jardine put together a Javascript bookmarklet called Visual Event which visually shows the elements on a page that have events subscribed to them, what those events are and the function that the event would run when triggered. This is primarily intended to assist debugging, but it can also be very interesting and informative to see the subscribed events on other pages.
I just received Zend’s newsletter regarding the release of Zend Framework 1.8.
New features are
- rapid application development (RAD) using the new code generation classes, allowing developers to bootstrap their applications quickly
– also available are new cloud classes – abstracting and simplifying access to Amazon‘s S3 and EC2 services, exposing users to scalable deployment infrastructure.
Download Zend Framework 1.8
Posted on 13-05-2009 | By: Amit
Category : General
Tags: Databases, Facebook, google, Openid, Programming
Simple registration request and response parsing and object representation
This module contains objects representing simple registration requests and responses that can be used with both OpenID relying parties and OpenID providers.
- The relying party creates a request object and adds it to the
AuthRequest object before making the checkid_ request to the OpenID provider:
auth_request.addExtension(SRegRequest(required=['email']))
- The OpenID provider extracts the simple registration request from the OpenID request using
SRegRequest.fromOpenIDRequest, gets the user’s approval and data, creates a SRegResponse object and adds it to the id_res response:
sreg_req = SRegRequest.fromOpenIDRequest(checkid_request.message)
# [ get the user's approval and data, informing the user that
# the fields in sreg_response were requested ]
sreg_resp = SRegResponse.extractResponse(sreg_req, user_data)
sreg_resp.toMessage(openid_response.fields)
- The relying party uses
SRegResponse.fromSuccessResponse to extract the data from the OpenID response:
sreg_resp = SRegResponse.fromSuccessResponse(success_response)
for each in:
JAVASCRIPT:
-
for each (var item in [1, 2, 3]) alert(item);
JavaScript 1.6 added the Array.forEach method:
JAVASCRIPT:
-
[1, 2, 3].forEach(function(item) { alert(item) });
JavaScript 1.7 added array comprehensions for array initialization:
JAVASCRIPT:
-
var squares = [item * item for each (item in [1, 2, 3])];
I just realized I can (ab)use comprehensions to iterate arrays with Perl-like syntax by throwing away the result:
JAVASCRIPT:
-
[alert(item) for each (item in [1, 2, 3])];
I can iterate object properties the same way:
JAVASCRIPT:
-
var obj =
{ foo:
1, bar:
2, baz:
3 };
-
[alert(name + "=" + obj[name]) for (name in obj)];
Edward Lee points out how to use Iterators:
JAVASCRIPT:
-
[alert(key + "=" + val) for ([key, val] in Iterator({a:1,b:2,c:3}))]