I am busy with…

1. A linkedIn Profile parser – last couple of days I did some research on the structure of linkedin url and profile structure and I developed this small class which can parse any linked in public profile in a valid set of xml nodes.

2. LinkedIn Address book importer – thats right, all you need to provide is your linkedin username and password and this PHP class will return all your connections in CSV format.

3. A social Networking site – I am currently working on a localized social networking site which will be released pretty soon.

4. My Book – currently I am writing the fifth chapter of my book

5. Amazon ECS – yes, for last couple of days I did some study on amazon ECS web service APIs (REST) to develop some cool apps with that.

6. Software prototyping – this thing attracts my interest recently, as a result I am studying it.

7. Last but not the least, I am working on OpenId to do something with it, actually small RnD.

I am…


Your Five Factor Personality Profile


Extroversion:

You have medium extroversion.
You’re not the life of the party, but you do show up for the party.
Sometimes you are full of energy and open to new social experiences.
But you also need to hibernate and enjoy your “down time.”

Conscientiousness:

You have high conscientiousness.
Intelligent and reliable, you tend to succeed in life.
Most things in your life are organized and planned well.
But you borderline on being a total perfectionist.

Agreeableness:

You have medium agreeableness.
You’re generally a friendly and trusting person.
But you also have a healthy dose of cynicism.
You get along well with others, as long as they play fair.

Neuroticism:

You have medium neuroticism.
You’re generally cool and collected, but sometimes you do panic.
Little worries or problems can consume you, draining your energy.
Your life is pretty smooth, but there’s a few emotional bumps you’d like to get rid of.

Openness to experience:

Your openness to new experiences is high.
In life, you tend to be an early adopter of all new things and ideas.
You’ll try almost anything interesting, and you’re constantly pushing your own limits.
A great connoisseir of art and beauty, you can find the positive side of almost anything.

Thanks to Samiha Esha for this nice Link

Igniting Code with Code Igniter

Day by day I am loving codeigniter more and more. Its so awesome, rick ellis, you are da man. But unfortunately codeigniter was not properly tested with PostgreSQL. Yesterday I fixed active records insert_id() function to work properly with PostgreSQL. I am running it’s version 8.1

Here comes my modified system/database/driver/postgre/postgre_driver.php

function insert_id()
{
$v = pg_version($this->conn_id);
if (isset($v['server'])) $v = $v['server'];

$table = func_num_args() > 0 ? func_get_arg(0) : null;
$column = func_num_args() > 1 ? func_get_arg(1) : null;

if ($table == null && $v >= '8.1')
{
$sql='SELECT LASTVAL() as ins_id';
}
elseif ($table != null && $column != null && $v >= '8.0')
{
$sql = sprintf("SELECT pg_get_serial_sequence('%s','%s') as seq", $table, $column);
$query = $this->query($sql);
$row = $query->row();
$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $row->seq);

}
elseif ($table != null)
{
// seq_name passed in table parameter
$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table);
}
/**
* another insert id Hack for PostgreSQL
* @author : Hasin Hayder
* @since : March 09, 2007
*/
elseif(is_null($v))
{
$sql='SELECT (LASTVAL()) as ins_id';
}
/**
* End Hack
*/
else
{
return pg_last_oid($this->result_id);
}
$query = $this->query($sql);
$row = $query->row();
return $row->ins_id;
}

Fixing ActiveRecord Class for CodeIgniter to use with PostgreSQL

Hi,

If you are using PostgreSQL and execute the following statement, it will defnitely generate error because of some internal properties in the model.

Controller Code


<?
$model
= $this->load->model("MyModel");
$this->mymodel->insert();
?>

where the model code is


<?
Class MyModel extends Model{
  public $username
;
  
public $password;

  public function insert()
  
{
    $this
->db->insert("table",$this);
  
}
}
?>

So guys – Here I fix the Active Record class in CodeIGniter. Here goes the solution. Just replace the existing insert() function in system\database\DB_active_rec.php

Dont worry, it wont hamper the functionality for other DB providers


/**
     * Insert
     *
     * Compiles an insert string and runs the query
     *
     * @access    public
     * @param    string    the table to retrieve the results from
     * @param    array    an associative array of insert values
     * @return    object
     */
    function insert($table = '', $set = NULL)
    
{
        
if ( ! is_null($set))
        
{
            $this
->set($set);
        
}

        if (count($this->ar_set) == 0)
        
{
            
if ($this->db_debug)
            
{
                
return $this->display_error('db_must_use_set');
            
}
            
return FALSE;
        
}

        if ($table == '')
        
{
            
if ( ! isset($this->ar_from[0]))
            
{
                
if ($this->db_debug)
                
{
                    
return $this->display_error('db_must_set_table');
                
}
                
return FALSE;
            
}

            $table = $this->ar_from[0];
        
}

        /**
         * A small hack for PostgreSQL
         * @author : Hasin Hayder [[email protected]]
         * @since : March 09, 2007
         */
        
if ($this->dbdriver=="postgre"){
            $clone
= $this->ar_set;
            foreach(
$this->ar_set as $key=>$val)
                if (
substr($key,0,1)=="_") unset($clone[$key]);
            
$sql = $this->_insert($this->dbprefix.$table, array_keys($clone), array_values($clone));
        
}
        
else
        
$sql = $this->_insert($this->dbprefix.$table, array_keys($this->ar_set), array_values($this->ar_set));
        
/**
         * End Hack
         */
        
        
$this->_reset_write();
        return
$this->query($sql);
    
}

going for a complete redesign of zephyr

zephyr2.jpg

I am planning for a complete redesign of zephyr, a tiny AJAXed MVC framework for PHP5 developers. So far zephyr has been downloaded 3,975 times from sourceforge and I got several impressive mails from users of zephyr which inspired me a lot. Now it’s time to a complete redesign. Zephyr has been a framework for many of you, but really we can make it more dynamic. Lets make it so easy, so amazing so that a guy who does not know even PHP will be able to use it.

I am planning to make it more “Human” – ha ha ha.

A new look to CodeIgniter, Finally!

CodeIgniter recently gained a lot of attraction from different level of PHP developers because of it’s simplicity and creative flavour. I started learning CakePHP but its so much automated and took time to learn all these stuffs, I moved to CodeIgniter and fall into love with it. Amazing framework.

Recently CodeIgniter website got a new look an feel, a very impressing design indeed. But the sad part of the story is that they also changed the logo which I didn’t like at all. The old logo was much more creative.

Love for CodeIgniter and it’s developers.

Some interesting PHP Apps

While surfing out there, I just find some cool PHP Apps which may come handy for you.

1. Tasks Jr by AlexKing
A task management tool similar to ActiveCollab, BaseCamp and TickSpot

2. MythTv
MythTV is a GPL licensed suite of programs that allow you to build the mythical home media convergence box on your own using Open Source software and operating systems. MythTV is known to work on Linux and Mac OS X (PowerPC and Intel). It does not run on Windows.

3. PHP-Java Bridge
The php/Java bridge is an optimized, XML-based network protocol, which can be used to connect a native script engine, PHP, with a Java or ECMA 335 virtual machine. It is more than 50 times faster than local RPC via SOAP, requires less resources on the web-server side, and it is faster and more reliable than communication via the Java Native Interface.

4. Relay Ajax Directory Manager
An excellent PHP+Ajax directory manager script

5. Vanila
A nice and Simple bulletin board script

Adding Layout support like RubyOnRails into CodeIgniter :: By Hooking

Recently I came across an interesting feature in RoR which is known as layout yielding. To understand what it is just imagine that you have a particular template file (layout) specific to your controller, and in that layout file you have a special block called yield. After that whenever there is some output from any method in your controller will be yielded exactly to that block in that layout. Which means all output from your controller will be first replaced into that “yield” block inside that layout, and then whole data will be displayed right away.

So what is the benefit of using that. Simple, it will help to design your website more flexibly. You have a layout, and inside that layout at a particular position you can output all data. This will just minimize the need of splitting a single template into smaller pieces like “header”, “body”, “footer” and so forth, and finally turning them into a single piece manually before rendering the final output.

Let’s have a look at the following image to understand the fact more clearly.

layout.gif

This is a typical website payout where some of its sections are marked. In this layout which sections you think changes most frequently? Definitely the section marked as p3. Now what usually happens when you design a site.

1. Either you write the whole file as template and change the parts you need
2. Or you split them into smaller components and merge those parts while delivering the final output.

Now, with this yield feature all we do is we create a single html file exactly as the design keeping the div of P3 blank. But inside that P3 container div, we will just write some text “{yield}”. Now because of this yield feature, whenever our controller generate some output using any view, CodeIgniter will automatically load that layout file first, then take the output from the view and merge them together.

To enable this excellent yield feature into CodeIgniter we need to write some hook. First, open the file named application/config/hooks.php and add the following line in it.

$hook['display_override'][] = array(
'class' => 'Yielder',
'function' => 'yield',
'filename' => 'Yielder.php',
'filepath' => 'hooks'
);

After that, inside application/hooks folder create a file named “Yielder.php” and inside that file, write the following code.

<? if (!defined('BASEPATH')) exit('No direct script access allowed');
class Yielder
{
function yield()
{
$ci= & get_instance();
$current_output = $ci->output->get_output();
$controller = $ci->uri->segment(1);
$layout = "system/application/layouts/{$controller}.php";
if (file_exists($layout)){
$output = $ci->load->file($layout,true);
$output = str_replace("{yield}",$current_output,$output);
}
else
$output = $current_output;
echo $output;
}
}
?>

And that’s it!! You are done.

Now all you have to do is create a folder inside your application folder named “layouts” and place the layout file named same as controller. For example if your controller name is “abcd” then your layout should be “abcd.php” – But remember to keep a section named {yield} inside that layout. Lets take a look at the complete example below

Controller: controllers/abcd.php

<?
class abcd extends Controller
{
function help()
{
$title = "";
for($i=0; $i";
}
$this->load->view("myviews",array("title"=>$title));
}

}
?>

View : views/myview.php

<?
echo $title;
?>

Layout : layouts/abcd.php

<h1>
Hi there
</h1>

{yield}

<h1>
Happy Ending
</h1>

And the final Output is

/****************************

Hi there

0
1
2
3
4
5
6
7
8
9

Happy Ending

****************************/

back after a long time

after almost a month, I started blogging again. these days I was extremely busy with developing a localized blog and some internal deliveries with pageflakes. yesterday i found one cool service which tells you what happened any day in history. i developed a flakes yesterday by clipping those information.

day by day I am falling into love with code igniter.

yesterday i started learning ruby on rails again.