rss

The Zen of Python

Category : Information

 

 

    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren't special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one– and preferably only one –obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    Namespaces are one honking great idea — let's do more of those!
 

 

Share

Namazu with PHP5 on Linux

1

Category : Featured, PHP

Namazu is a full-text search engine intended for easy use is what the namazu site tells its users. I have already worked on namazu and it worked amazingly fast. Recently i started working on a project having tens & thousands of records and it was cumbersome for MySQL to work efficiently under that much load. I decided to use namazu for that but unfortunately i was working on a windows based platform and its very difficult to configure PHP5 with namazu on windows. I was able to install namazu easily on windows. One can use the CGI mode to use namazu on windows but installing namazu as a PHP extension is difficult at least for me at this time.

But i was able to install namazu on LINUX and was also able to install namazu as a PHP extension on LINUX. While stumbling though site searching for installing namazu with PHP5 i got this link which describes how one can install namazu on LINUX and its PHP extension also.

I will keep on searching how to get namazu as a PHP extension, meanwhile you can use this link to get namazu working on LINUX.

Share

Software Engineering In PHP

Category : Information, PHP

I was wondering if the PHP developers can work exactly like a JAVA developer in the sense the PHP developer has all the tools required for building, deploying & managing the application like a JAVA developer. Here i found a slide from Ralph & Josh who have given a very good details of all the things that you can use while developing a PHP app.

Share

PHP ORM: Doctrine 2

Category : PHP

At the start of my career as a developer, there were almost no ORM for PHP, there existed some classes that enabled you to easily access DB but not ORM.

ORM(Object Relational Mapping) in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. In other words it maps the relational database to the objects in your application. So each table becomes and object.

Doctrine is one of the powerful ORM present for PHP and with Doctrine 2 its has provided more features and ease of accessing database.

Share

CakePHP Sharing sessions between apps on the same domain

1

Category : General, PHP

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.

Cake-logo
Cake-logo
Image via Wikipedia

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.

Share

QUnit:JavaScript Testing Framework

Category : Javascript

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).

Share

Javascript: visual event

2

Category : Javascript

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.

Share

Zend Framework 1.8 Released!

Category : PHP

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

Share

openid.sreg

Category : General

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.

  1. 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']))
  2. 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)
  3. The relying party uses SRegResponse.fromSuccessResponse to extract the data from the OpenID response:
    sreg_resp = SRegResponse.fromSuccessResponse(success_response)
Share

Javascript: Ways to iterate over an array

Category : General

for each in:

JAVASCRIPT:

  1. for each (var item in [1, 2, 3]) alert(item);

JavaScript 1.6 added the Array.forEach method:

JAVASCRIPT:

  1. [1, 2, 3].forEach(function(item) { alert(item) });

JavaScript 1.7 added array comprehensions for array initialization:

JAVASCRIPT:

  1. 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:

  1. [alert(item) for each (item in [1, 2, 3])];

I can iterate object properties the same way:

JAVASCRIPT:

  1. var obj = { foo: 1, bar: 2, baz: 3 };
  2. [alert(name + "=" + obj[name]) for (name in obj)];

Edward Lee points out how to use Iterators:

JAVASCRIPT:

  1. [alert(key + "=" + val) for ([key, val] in Iterator({a:1,b:2,c:3}))]
Share

Amit Yadav is Stephen Fry proof thanks to caching by WP Super Cache