Thursday, March 19, 2009

my photo contest widget

AddThis Social Bookmark Button

Wednesday, March 18, 2009

My new contest widget

Just finished work on creating a new contest widget for Votigo. Check out the widget in action here:

AddThis Social Bookmark Button

Wednesday, November 07, 2007

Mark Knopfler & Chet Atkins - Imagine

AddThis Social Bookmark Button

Sunday, November 04, 2007

How to modify your hosts file on Windows Vista

The enhanced security on Windows Vista is good, but sometimes even the simplest of tasks become a pain. For eg: I run xampp on my box and have require various virtual hosts - I also setup numerous domains and make an entry for them in my HOSTS file.

I switched to Vista very recently (I bought a new laptop :) and I simply couldn't modify the hosts file. After looking around and figuring how things work on Vista, here are the steps to change your hosts file on Windows Vista.

1) Browse to Start -> All Programs -> Accessories
2) Right click "Notepad" and select "Run as administrator"
3) Click "Continue"
4) Click File -> Open
5) Browse to "C:\Windows\System32\Drivers\etc"
6) Change the file filter drop down box from "Text Documents (*.txt)" to "All Files (*.*)"
7) Select "hosts" and click "Open"
8) Make the needed changes and close Notepad.
9) Save the file.

That's it you should now be able to add all those domains into your hosts file :)

Also, for people having problem running Eclipse, right click on the eclipse.exe and say "Run as administrator".

-Mandy.

AddThis Social Bookmark Button

Monday, September 24, 2007

Google Analytics on AIR

This one is pretty cool guys.

Nico created a custom google analytics api and used it to build a desktop version of google analytics using AIR (Adobe Integrated Runtime).

I just tried it and although it is beta, the experience is amazing - I found it to be much smoother than the online version.

Installation didn't take more than 5 minutes.

It required me to download the AIR first from here:

Then download the google analtyics air file from here:

That's it, you are all set now.

Just enter the required info and even if you have multiple websites/domains mapped with one id, it will suck all of them. You can create as many profiles as you want.

The best part is that the guys at the google camp liked it so much that I think they are now officialy supporting this project.

Enjoy!
Mandy.

AddThis Social Bookmark Button

Wednesday, May 16, 2007

Good Bye Prototype, Welcome jQuery

I have been a prototype.js user for almost 1 1/2 years now but for a new project, I was forced to use jquery (www.jquery.com). In the beginning, I was too reluctant to give it a shot because of the learning curve and laziness on my part, but I must say once I dived in, I was very impressed with the library, it's documentation, the community, the number of plugins and how easy it was to find all this - something that prototype lacked right from day one (okay now they do have a documentation site www.prototypejs.org, but it just doesn't compare to the jquery website at any level). In no way am I undermining the power of prototype.js (the library that fixed javascript programming :). Just that I am going to be experimenting with jquery now.

One more thing, people often shy away from libraries because of their size, but jquery offers an "official" compressed version of the library that is just 19KB. Prototype too has it's compressed versions but nothing that is official and I always had problems working with unofficial compressed versions.

What's the point of this post? Well, I wanted to write about all the flash work I have been doing, but was just not able to get in the mood to detail that out, so thought will post this for the time being ;)

-Mandy.

AddThis Social Bookmark Button

Tuesday, February 20, 2007

Caching with cakePHP

cakePHP has view caching built in which when used cleverly will really speed up your applications.

However, this doesn't work with requestAction.

Let's consider this example:

1. You store all your categories in a database.

2. While displaying your views, you want to pull these categories from the DB.

3. You don't want that every time you display a page, you should pull the categories from DB. Since they are not going to change (till you change them :) it's an unnecessary hit on the DB.

4. You want to load these categories at startup and then just keep pulling the data from the cache rather than the DB.

There can be many ways of doing this, but one of them could be that whenever the category data is first requested, we hit the DB and get the list of categories, then cache them (in a file) and subsequent requests would be served from reading the file (it could be stored in the session too).

So, I decided to give this a shot. cakePHP already has a cache() function that can be used for achieving something like this.

Here is what I came up with:



function __getCategories()
{
$cache_name = "views".DS."categories-list.php";
$cache_expires = '+24 hours';

$cache_data = cache($cache_name, null, $cache_expires);
if (empty($cache_data))
{
$list = array_merge(array('categories'=>'All Categories'),
$this->Contest->getEnumValues("contest_category"));
cache($cache_name, serialize($list), $cache_expires);
} else {
$list = unserialize($cache_data);
}
return $list;
}



getEnumValues is something I got as a snippet from cakeforge.
http://cakeforge.org/snippet/detail.php?type=snippet&id=112



function getEnumValues($columnName=null)
{
if ($columnName==null) { return array(); } //no field specified


//Get the name of the table
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$tableName = $db->fullTableName($this, false);


//Get the values for the specified column
$result = $this->query("SHOW COLUMNS FROM {$tableName} LIKE '{$columnName}'");

//figure out where in the result our Types are
//(this varies between mysql versions)
$types = null;
if ( isset( $result[0]['COLUMNS']['Type'] ) )
{
$types = $result[0]['COLUMNS']['Type'];
} //MySQL 5
elseif ( isset( $result[0][0]['Type'] ) )
{
$types = $result[0][0]['Type'];
} //MySQL 4
else {
return array();
} //types return not accounted for

//Get the values
$values = explode("','", preg_replace("/(enum)\('(.+?)'\)/","\\2", $types) );

//explode doesn't do assoc arrays, but cake needs an assoc to assign values
$assoc_values = array();
foreach ( $values as $value ) {
//leave the call to humanize if you want it to look pretty
$assoc_values[$value] = Inflector::humanize($value);
}

return $assoc_values;

} //end getEnumValues



So, that's it, you can now do the following in your controller:



function test()
{
$categories = $this->__getCategories();
debug($categories);
}



-Mandy.

AddThis Social Bookmark Button
 
Visit blogadda.com to discover Indian blogs