21 November 2011

Some useful resources and snippet for web developer and designers

Today we like to share some useful resource and snippet for web developers and web designers. I hope often i like to share some valuable resource from this post.


Already we have started to some good valuable resource via our facebook fan page.

1. Input box with voice recognition.

speechtotext


One of my client need his input box to be voice recognized just like Google search.Where if you speak some thing that will be converted to text.Today i like to share a simple code snippet to creating a voice recognized input box.

<input type='text' x-webkit-speech/>

x-webkit-speech is supported by only by chrome.

2.CSS3 Graph Animation.



A Simple mind blowing graph animation with css3.



3.Sharpen Images with PHP GD.


php image sharpen
<?php
function imagesharpen( $image) {

$matrix = array(
array(-1, -1, -1),
array(-1, 16, -1),
array(-1, -1, -1),
);

$divisor = array_sum(array_map('array_sum', $matrix));
$offset = 0;
imageconvolution($image, $matrix, $divisor, $offset);

return $image;
}
?>



4.Javascript Pointers

Pointers are a powerful part of C, and they're so simple that it's not too hard to replicate them in other (powerful) languages. I made a pointer system not unlike C's in just a few lines of javascript.


var uid;
(function() {
var lastId = 0;
uid = function() {
return lastId++;
};
}());

global.$ = function(val) {
var id = uid();
global.$[id] = val;
Object.defineProperty(global.$, id, {
get: function() {
return val;
},
set: function(newVal) {
val = newVal;
return newVal;
},
enumerable: false
})
return id;
};

global.$.free = function(ptr) {
delete global.$[ptr];
};


5.Automatic updating timestamp,facebook style.


( function($){
$.fn.updateTime = function(){
this.each( function(){
var $this = $(this);

if( $this.parent().hasClass('stopUpdateTime') === false )
{
$.update( $this );
setInterval( function(){
$.update( $this );
}, 60000 );
}
});
}

var $lang = {
0: 'less than a minute ago',
1: '1 minute ago',
59: '%distance minutes ago',
118: 'an hour ago',
1439: '%r hours ago',
2879: 'Yesterday at %h:%i',
14567: '%l at %h:%i',
},
$default = '%d %f%y at %h:%i',
$days = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],
$months = ['January','February','March','April','May','June','July','August','September','October','November','December'];

$.update = function( $this )
{
if( $this.attr('title') != 'undefined' )
{
var $date = new Date( $this.attr('title') );
var $timestamp = $this.attr('title');
if( $date == 'Invalid Date' )
{
$date = new Date( $this.attr('title') * 1000 );
$timestamp = ( $this.attr('title') * 1000 );
}

var $time = new Date();

var $distance = Math.round( Math.abs( $time - $timestamp ) / 60000 );

var $return = '';
for( i in $lang )
{
if( $return == '' && $distance <= i )
{
var $r = Math.round( $distance / 60 ),
$h = ( ( $date.getHours() < 10 ) ? '0' : '' ) + $date.getHours(),
$i = ( ( $date.getMinutes() < 10 ) ? '0' : '' ) + $date.getMinutes(),
$l = $days[ $date.getDay() ];

$return = $lang[i]
.replace(/%distance/i, $distance)
.replace(/%r/i, $r)
.replace(/%h/i, $h)
.replace(/%i/i, $i)
.replace(/%l/i, $l);
}
}

if( $return == '' )
{
var $d = ( ( $date.getDate() < 10 ) ? '0' : '' ) + $date.getDate(),
$f = $months[ $date.getMonth() ],
$y = ( $time.getFullYear() == $date.getFullYear() ) ? '' : ' ' + $date.getFullYear(),
$h = ( ( $date.getHours() < 10 ) ? '0' : '' ) + $date.getHours(),
$i = ( ( $date.getMinutes() < 10 ) ? '0' : '' ) + $date.getMinutes();

$this.html(
$default
.replace(/%d/i, $d)
.replace(/%f/i, $f)
.replace(/%y/i, $y)
.replace(/%h/i, $h)
.replace(/%i/i, $i)
);
}
else
$this.html( $return );
}
}
} )(jQuery);

$(document).ready(function(){
$('abbr.time').updateTime();
});



About Editorial Staff
Nathan Shri is a Web Developer ,Opensource lover,and the editor of the codingwoo based in India ,who loves to learn new stuffs and and share.You can be his friend on Facebook.

Post a Comment