Skip to content

Instantly share code, notes, and snippets.

View manigandanta's full-sized avatar

Manigandan Arjunan manigandanta

View GitHub Profile
@manigandanta
manigandanta / datediff.php
Created May 18, 2012 04:38
difference b/w two dates
<?php
$date1 = $date;
$date2 = date("Y-m-d");
$diff = abs(strtotime($date2) - strtotime($date1));
//$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
//$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
@manigandanta
manigandanta / windowonload.js
Created April 25, 2012 12:24
window.onload for firefox
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", init, false);
}
@manigandanta
manigandanta / disableccp.js
Created April 25, 2012 05:34
disable cut copy paste in a text box using jquery
$('#email').live("cut copy paste",function(e) {
e.preventDefault();
});
@manigandanta
manigandanta / validatedomainname.php
Created April 24, 2012 09:57
javascript domain name validation script
var domain=$("#domain").val();
function checkDomain(nname)
{
var arr = new Array('.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
/*
* vertical news ticker
* Tadas Juozapaitis ( kasp3rito@gmail.com )
* http://plugins.jquery.com/project/vTicker
*/
(function(a){a.fn.vTicker=function(b){var c={speed:700,pause:4000,showItems:3,animation:"",mousePause:true,isPaused:false,direction:"up",height:0};var b=a.extend(c,b);moveUp=function(g,d,e){if(e.isPaused){return}var f=g.children("ul");var h=f.children("li:first").clone(true);if(e.height>0){d=f.children("li:first").height()}f.animate({top:"-="+d+"px"},e.speed,function(){a(this).children("li:first").remove();a(this).css("top","0px")});if(e.animation=="fade"){f.children("li:first").fadeOut(e.speed);if(e.height==0){f.children("li:eq("+e.showItems+")").hide().fadeIn(e.speed)}}h.appendTo(f)};moveDown=function(g,d,e){if(e.isPaused){return}var f=g.children("ul");var h=f.children("li:last").clone(true);if(e.height>0){d=f.children("li:first").height()}f.css("top","-"+d+"px").prepend(h);f.animate({top:0},e.speed,function(){a(this).children("li:last").remove()});if(e.animation=="fade"){if(e.height==0){f.ch
@manigandanta
manigandanta / greaterdate.php
Created April 16, 2012 11:01
Find Greater date
<?php
function greaterDate($start_date,$end_date)
{
$start = strtotime($start_date);
$end = strtotime($end_date);
if ($start-$end > 0)
return 1;
else
return 0;
}
@manigandanta
manigandanta / matchStrIntSpace.js
Created April 11, 2012 12:38
match only strings and numbers with spaces
var userRegex = /^\d*[a-zA-Z][a-zA-Z\d\s]*$/;
@manigandanta
manigandanta / scandirectory.php
Created April 11, 2012 05:59
Scan directory
<?php
$directory = "../scripts/";
$images = scandir($directory);
$ignore = Array(".", "..");
foreach($images as $dispimage)
{
if(!in_array($dispimage, $ignore))
{
$files=$directory.$dispimage;
?>
@manigandanta
manigandanta / php-password-generator.php
Created April 11, 2012 05:58
PHP password generator
<?php
function generatePassword($length, $strength)
{
$vowels = 'aeuy';
$consonants = 'bdghjmnpqrstvz';
if ($strength & 1)
{
$consonants .= 'BDGHJLMNPQRSTVWXZ';
}
if ($strength & 2)
@manigandanta
manigandanta / calendar-script.php
Created April 11, 2012 05:56
Calendar script
<?php
$home1="sunrise-sunset-day_".$sun_value."_";
//$bgcolor="#898989";
//$tablecolor = "#675645";
//$fontcolor = "#EE49DD";
//$tableborder = "458866";
//Edit the below three lines to change the colors (Look and Feel of the calander).
//The default values are shown in the above lines
$bgcolor="#4B9E03";