Imran Naqvi

my personal blog

HTPC/PC Infra-red Remote Controll

November10

Its have been ages that i was searching for a infra-red RC for my home PC to watch movies on Media Player Classic – HC. I was not going to spoil too much money on some costly solutions neither on some cheap one. Then i found a software EventGhost. What it did? It did not helped me a lot but i was able to get list of compatible hardware (IR-Receivers and Remotes). PS3 DVD Remote and Xbox (Original) DVD Remote was some of them and because these are consumer products and famous world-wide so easily available. I was able to find both of them PS3 DVD Remote (from Sony, Karachi, Pakistan ), Xbox DVD Remote (from a Chinese Retailer in Faisalabad).
I was successful in setting up Xbox DVD Remote on my PC (Windows 7) which i will share in my next post.

Arduino Revolution

January11

Hi.
Have you heard about Arduino? Open-Source prototyping hardware platform.
Everyone is talking about it, and they should be because it is such a fantastic thing.
I am planing to start by making my own.
I will start by making this very basic version Serial One-Sided RS-323 version http://arduino.cc/en/Main/ArduinoBoardSerialSingleSided3 which uses Atmel ATMEGA8 or ATMEGA168. Newer versions are available with USB interface and other versions of ATMEGA micro-controller.

posted under Arduino | No Comments »

.htaccess like implementation in Zend Framework

December9

Working with Zend Framework is fun, but sometimes very small tasks like adding a custom regex route becomes annoying.

A simple solution is obvious, create a simple .htaccess like file without using .htaccess.

This is sample code to add a new regex route to Zend Framework by placing this method in bootstrap class.

protected function _initLoadUrls()

{

	//get instance of front controller
	$front = Zend_Controller_Front::getInstance();
	//get current router
	$router = $front->getRouter();
	//remove default routes if you want
	$router->removeDefaultRoutes();
	//create new regex route
	$route = new Zend_Controller_Router_Route_Regex('([0-9a-zA-z-]+)/([0-9a-zA-z-]+)\.html',array('controller' => 'product','action' => 'index'),array(1=>'category_slug',2=>'product_slug'),'%s/%s.html');
	//add to router
	$router->addRoute($key, $route);
}

Now for the solution i will create a file say url-rules.php in zend/application/config folder having an associative array which is.

$rules=array(
'home'		=>array('',array('controller' => 'index','action' => 'home'),null,''),
'product'	=>array('([0-9a-zA-z-]+)/([0-9a-zA-z-]+)\.html',array('controller' => 'product','action' => 'index'),array(1=>'category_slug',2=>'product_slug'),'%s/%s.html'),
'category'	=>array('category/([0-9a-zA-z-]+).html',array('controller' => 'category','action' => 'index'),array(1=>'category_slug'),'category/%s.html'),
'brand'		=>array('brand/([0-9a-zA-z-]+).html',array('controller' => 'brand','action' => 'index'),array(1=>'brand'),'brand/%s.html'),
'page'		=>array('([0-9a-zA-z-]+).html',array('controller' => 'page','action' => 'index'),array(1=>'page_slug'),'%s.html')
);

Now just by editing the previous method from bootstrap class.

protected function _initLoadUrls()
{
	//get instance of front controller
	$front = Zend_Controller_Front::getInstance();
	require_once(APPLICATION_PATH."/configs/url-rules.php");
	if(count($rules))
	{
		//get current router
		$router = $front->getRouter();
		//remove default routes if you want
		$router->removeDefaultRoutes();
		//pars through the assosiative urls array
		foreach($rules as $key=>$value)
		{
			//create new regex route
			$route = new Zend_Controller_Router_Route_Regex($value[0],$value[1],$value[2],$value[3]);
			//add to current router
			$router->addRoute($key, $route);
		}
	}
}

Ta-Da problem solved.

Hi fellows

August21

Hi fellows, Today i have started my own blog.

I will add my work on it so that others can gain access to it and may learn something from it.

With best wishes for you all.

Thanks.