rss

Featured Posts

Rupee on the Web Two young Indian techies have developed a code for the new rupee symbol for the internet. WebRupee is a web Application Programming Interface(API) for the new Indian rupee symbol. This makes the Rupee symbol available to everyone on the web. The API provides a cross browser support for the Rupee symbol. Here...

Read more

Animation: Ólafur Arnalds – Ljósið http://www.ndesign-studio.com/blog/animation-olafur-arnalds-ljosi%C3%B0 Ólafur Arnalds - Ljósið (Official Music Video) from Erased Tapes on Vimeo.

Read more

CakePHP Paginate Count with group by I am working on a CakePHP project these days, today i ran into a different problem with CakePHP. Sometimes i feel that there are small-small things that are sometimes missed by the Cake developers, but thank God that there are some workarounds available to them.  Here is the problem statement that i...

Read more

A new look for Gmail Today when i logged in to my Gmail account i saw that Gmail has a new look. The new look has an easy access to the contacts and tasks. There was an update to the contacts too, now one can sort by last name and add custom labels for phone numbers and other fields. [caption id="attachment_581" align="alignleft"...

Read more

HTML5 localStorage() As you all know that its been exciting to see lots of new and good features of  HTML5 and CSS3. I have been looking for things that would be very good for the future of HTML5 and CSS3, one such thing that might be very useful in the future is the HTML5 localStorage(), which is a client-side database....

Read more

Rupee on the Web

Category : Information, Internet News

Two young Indian techies have developed a code for the new rupee symbol for the internet.
WebRupee is a web Application Programming Interface(API) for the new Indian rupee symbol. This makes the Rupee symbol available to everyone on the web. The API provides a cross browser support for the Rupee symbol.

Here is the code through which you can get this symbol on the web.

1
2
3
4
5
6
7
	Rupee
	<!--
	<link rel="stylesheet" href="http://cdn.webrupee.com/font" mce_href="http://cdn.webrupee.com/font" type="text/css" media="screen" title="no title" charset="utf-8">-->
	<!-- 	       @font-face{font-family: 'WebRupee';                src: url('http://cdn.webrupee.com/WebRupee.V2.0.eot');                src: local('WebRupee'), url('http://cdn.webrupee.com/WebRupee.V2.0.ttf') format('truetype'),  url('http://cdn.webrupee.com/WebRupee.V2.0.woff') format('woff'), url('http://cdn.webrupee.com/WebRupee.V2.0.svg') format('svg');font-weight: normal;font-style: normal;} .WebRupee{font-family: 'WebRupee';} -->
	<script src="http://cdn.webrupee.com/js" type="text/javascript"><!--mce:0--></script>
 
	<span class="WebRupee">Rs</span> 200


Rs 200

  • Share/Bookmark

Animation: Ólafur Arnalds – Ljósið

Category : Information

http://www.ndesign-studio.com/blog/animation-olafur-arnalds-ljosi%C3%B0

Ólafur Arnalds – Ljósið (Official Music Video) from Erased Tapes on Vimeo.

  • Share/Bookmark

CakePHP Paginate Count with group by

1

Category : General, PHP

I am working on a CakePHP project these days, today i ran into a different problem with CakePHP. Sometimes i feel that there are small-small things that are sometimes missed by the Cake developers, but thank God that there are some workarounds available to them.  Here is the problem statement that i encountered, i had a table in which i was having duplicate records and i wanted to show only distinct records in the data grid which was using the CakePHP paginator class to create a paginated data grid.

Now to show only the distinct rows i used the group by clause to eliminate the duplicate records, the records were coming fine but when i saw the paging it was not working right at all. The problem was that the paginator’s “paginateCount” function was also considering the “Group By” clause while doing the counting of the total records. This was crazy.

I searched through Google to get a solution to that and found this link, where people have already reported a his error to the cake developers. The solution that worked for me was that i needed to override the “paginateCount” function and use a different function in my model to get the correct number of total records. I added this function to my model and whola it worked for me. Here is the function that needs to be added model to get things right.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public function paginateCount($conditions = null, $recursive = 0, $extra = array()) {
		$parameters = compact('conditions', 'recursive');
 
		if (isset($extra['group'])) {
			$parameters['fields'] = $extra['group'];
 
			if (is_string($parameters['fields'])) {
				// pagination with single GROUP BY field
				if (substr($parameters['fields'], 0, 9) != 'DISTINCT ') {
					$parameters['fields'] = 'DISTINCT ' . $parameters['fields'];
				}
				unset($extra['group']);
				$count = $this-&gt;find('count', array_merge($parameters, $extra));
			} else {
				// resort to inefficient method for multiple GROUP BY fields
				$count = $this-&gt;find('count', array_merge($parameters, $extra));
				$count = $this-&gt;getAffectedRows();
			}
		} else {
			// regular pagination
			$count = $this-&gt;find('count', array_merge($parameters, $extra));
		}
		return $count;
	}
  • Share/Bookmark

A new look for Gmail

Category : General

Today when i logged in to my Gmail account i saw that Gmail has a new look. The new look has an easy access to the contacts and tasks. There was an update to the contacts too, now one can sort by last name and add custom labels for phone numbers and other fields.

Gmail_update

Gmail new update

  • Share/Bookmark

HTML5 localStorage()

Category : HTML5 & CSS3

As you all know that its been exciting to see lots of new and good features of  HTML5 and CSS3. I have been looking for things that would be very good for the future of HTML5 and CSS3, one such thing that might be very useful in the future is the HTML5 localStorage(), which is a client-side database. The values in this database is stored as a key value pair. This database resides on the users browsers and not on the server. You need not write SQL insert/update/delete for manipulating this database. There are functions provided to this which helps in storing, updating and deleting the data stored in localStorage(). This database is available per browser so if some data is stored in the Firefox browser and you switch to Safari you won’t be able to use the localStorage data in firefox. This is a browser dependent feature, currently its supported by most modern browsers including Safari 4+, Mobile Safari (iPhone/iPad), Firefox 3.5+, Internet Explorer 8+ and Chrome 4+.

Let me show you how to code to use the localstorage() of your browser:

?View Code SCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
if (typeof(localStorage) == 'undefined' ) {
	alert('Browser support unavailable, try upgrading your browser');
} else {
	try {
		localStorage.setItem("date", "9th July 2010"); //INSERT, "key", "value"
	} catch (e) {
	 	 if (e == QUOTA_EXCEEDED_ERR) {
	 	 	 alert('Quota exceeded!'); //data wasn't successfully saved due to quota exceed so throw an error
		}
	}
	document.write(localStorage.getItem("date"));
	localStorage.removeItem("date"); //DELET
}

You can use this localStorage() in various ways, you can use it to track the time spent by a user on your site, you can store the date the user logged in the last time etc. In the first impression it may not sound very good to you but its a very nice feature to have for the future.

  • Share/Bookmark

jQuery Custom Alertbox Plugin

Category : Javascript

I was working on an app using Adobe AIR platform. At one stage i was at a point where i needed an alert system that i can customize according to my needs. I searched for some of the plugins that were very good but accidently i bumped into a link where it talks about how to create a jQuery plugin, so i thought of creating my own which i can customize according to my needs.
I am providing the code here so that you can use this code and customize it according to your need.

?View Code SCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//PLUGIN FOR THE NEW ALERT BOX
 (function($){  
	 $.fn.extend({   
		 customAlert: function(options) {
			var htmlStr = '<div id="amitOverlay"></div><div id="alertMsgDiv"><div id="aClose">[X]</div><div id="aMessage"></div></div>';
			var defaults = {   
				 bgColor: '#000',  
				 opacity: '0.6',  
				 message: 'This is a test message from the plugin',  
			 };  
 
			var options = $.extend(defaults, options);  
			$("body").append(htmlStr);
			$("#alertMsgDiv").css({'display': 'block', 'width': '100px'});
			$("#amitOverlay").css({'display': 'block', 'top': '0px', 'left': '0px', 'width': $(this).width() + "px", 'height': $(this).height() + "px", 'background-color': options.bgColor, 'opacity': options.opacity});	
 
			$("#aMessage").html(options.message);
			$("#alertMsgDiv").animate({width: 300}, 300);
 
			$("#amitOverlay, #aClose").click(function(){	
				$("#alertMsgDiv").remove();
				$("#amitOverlay").remove();									
			});
		 }  
	 });  
 })(jQuery);
 
 
/*
 USAGE
 $(document).ready(function(){
	$(document).customAlert({opacity:0.4, bgColor: "#aaa",  message: 'This is a test message' });
 });
 */
Download the code here
  • Share/Bookmark

Lots of improvements for Firefox 4

Category : General, Product Releases

Some of the cool new stuff coming in Firefox 4.
* New Add-Ons Builder based on Bespin
* HTML5 Video display
* Painting with Canvas
* Image manipulation with Canvas – pixel testing, face detection with opencivitas
* Green screen technologies in images and video by detecting pixel colours.
* HTML5 embedded inside SVG (yes!)
* SVG as an IMG
* SVG as a CSS background
* SVG filter/mask/clip
* SVG animations
* Inline SVG inside HTML5
* CSS3 (selectors, @font-face, 2D Transforms, Transitions, Shadow, Gradients ,calculations – calc(2em-10px) )
* APIs: Geolocation, Offline (IndexDB, localStorage, AppCache, FileAPI – binary content of a file input, file drag and drop, web workers, websockets)
* Websockets controller running the presentation from the mobile.
* WebGL

  • Share/Bookmark

Microsoft Rolls Out Office Web Apps

Category : General, Information

Microsoft rolled out Microsoft Office Web Apps on Skydrive to users in the U.S., U.K., Canada and Ireland June 7th

Microsoft_office_live
  • Share/Bookmark

CSS3 – Multi Column Layout Demonstration

Category : CSS

CSS3 – Multi Column Layout Demonstration

http://www.csscripting.com/css-multi-column/

  • Share/Bookmark

CakePHP Sharing sessions between apps on the same domain

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/Bookmark

Amit Yadav is Digg proof thanks to caching by WP Super Cache