This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.customFadeIn = function(fn) { | |
//set opacity to 0 and visibility to visibile | |
$(this).css({"opacity" : 0, "visibility" : "visible" }); | |
$(this).animate({opacity: 1}, 1000, "swing", function(){ | |
if(typeof fn == 'function') | |
fn.call(this); | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function trim(stringToTrim) { | |
return stringToTrim.replace(/^\s+|\s+$/g,""); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function func(a,b){ | |
if(typeof(a)==='undefined') a = 10; | |
if(typeof(b)==='undefined') b = 20; | |
//js code here | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var RegEx = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; | |
$("#p").filter(function() { | |
return $(this).html().match(RegEx); | |
}).each(function() { | |
$(this).html($(this).html().replace(RegEx, "<a href=\"$1\">$1</a>")); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getExcelColumnName($num) { | |
$numeric = ($num - 1) % 26; | |
$letter = chr(65 + $numeric); | |
$num2 = intval(($num - 1) / 26); | |
if ($num2 > 0) { | |
return getExcelColumnName($num2) . $letter; | |
} else { | |
return $letter; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$x = microtime(true); | |
/* ... Your script goes here ... */ | |
$temp = microtime(true) - $x; | |
echo "<p> execution time: ".$temp." seconds"; | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Modifies a string to remove all non ASCII characters and spaces. | |
* Try slugify("é&asd_æô") for example | |
*/ | |
function slugify($text) | |
{ | |
// replace non letter or digits by - | |
$text = preg_replace('~[^\\pL\d]+~u', '-', $text); | |
// trim | |
$text = trim($text, '-'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* validate email | |
*/ | |
function is_valid_email($email) | |
{ | |
if(preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) | |
return true; | |
else | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* PARTIAL_DIR is a constant that defines the path of the partial file to include */ | |
function get_partial($partialName, $vars = array()){ | |
// start the output buffer | |
ob_start(); | |
ob_implicit_flush(0); | |
// extract the variables in the scope of this function | |
extract($vars); | |
// include the file | |
include PARTIAL_DIR.$partialName.'.php'; | |
// clear the output buffer, and return the content |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine on | |
RewriteCond $1 !^(index\.php|images|robots\.txt) | |
RewriteRule ^(.*)$ /index.php/$1 [L] | |
//For local server (localhost on wamp) | |
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule .* index.php/$0 [PT,L] |