This file contains 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
/** | |
* Formats numbers (or string numbers) | |
* @param number int or int-parsable string | |
* @param prec decimal precision | |
* @returns formatted number as string | |
*/ | |
numberFormat : function (number, prec) { | |
var ext, name, numS, rgx = /(\d+)(\d{3})/; | |
number = number || '0'; | |
prec = prec || 0; |
This file contains 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
/** | |
* LESS mix-in library | |
* vendor prefixes verified with prefixr.com and caniuse.com [2012-09-28] | |
* https://gist.github.com/3798764 | |
*/ | |
@img-base: "../img"; | |
@icon-base: "../img/icons"; | |
.b(@v) when (@v = 0) { font-weight: normal; } |
This file contains 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
/** | |
* https://gist.github.com/tborychowski/3799025 | |
*/ | |
var UTILS = { | |
/*jshint maxlen: 500, onevar: false */ | |
isTouch : (/iPhone|iPod|iPad/ig).test(navigator.userAgent), | |
/** | |
* Modified & lintified version of https://gist.github.com/527683 |
This file contains 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
// Array Remove - By John Resig (MIT Licensed) | |
Array.prototype.remove = function(from, to) { | |
var rest = this.slice((to || from) + 1 || this.length); | |
this.length = from < 0 ? this.length + from : from; | |
return this.push.apply(this, rest); | |
}; |
This file contains 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
// import sql file | |
$file_content = file('updates.sql'); | |
$query = ""; | |
foreach($file_content as $sql_line){ | |
if(trim($sql_line) != "" && strpos($sql_line, "--") === false){ | |
$query .= $sql_line; | |
if (substr(rtrim($query), -1) == ';'){ | |
$result = $dbo->dbEdit($query); | |
echo $query.'<br>Result: '.($result==1?'OK':$result).'<br><br><br>'; | |
$query = ""; |
This file contains 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
//Returns ISO 8601 week number and year | |
Date.prototype.getFullWeek = function(){ | |
var jan1, w, d = new Date(this); | |
d.setDate(d.getDate()+4-(d.getDay()||7)); // Set to nearest Thursday: current date + 4 - current day number, make Sunday's day number 7 | |
jan1 = new Date(d.getFullYear(),0,1); // Get first day of year | |
w = Math.ceil((((d-jan1)/86400000)+1)/7); // Calculate full weeks to nearest Thursday | |
return {y: d.getFullYear(), w: w }; | |
}; | |
//Returns ISO 8601 week number | |
Date.prototype.getWeek = function(){ |
This file contains 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 validate(f,v,a,x){ | |
for(a=0;x=f[a++];) | |
if((v=window[x.getAttribute('valid')])&&!v(x.value)){ | |
alert(x.getAttribute('alert')); | |
return !x.focus(); | |
} | |
} | |
function notempty(x){return x>''} | |
function ismail(e){return /^[\w\.-]{2,}@[\w\.-]+\.[a-z]{2,5}$/i.test(e)} |
This file contains 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
new Array(20).join('.') |
This file contains 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 getCaretPosition (ctrl) { | |
var caretPos = 0; | |
// IE | |
if (document.selection) { | |
ctrl.focus (); | |
var sel = document.selection.createRange(); | |
sel.moveStart ('character', -ctrl.value.length); | |
caretPos = sel.text.length; | |
} | |
// Firefox |
This file contains 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
// the quickest way - by the bug :-) | |
var IE = !+"\v1" |
OlderNewer