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
// http://stackoverflow.com/questions/1219860/javascript-jquery-html-encoding?answertab=votes#tab-top | |
function htmlEncode(value){ | |
"use strict"; | |
//create a in-memory div, set it's inner text(which jQuery automatically encodes) | |
//then grab the encoded contents back out. The div never exists on the page. | |
return $('<div/>').text(value).html(); | |
} | |
function htmlDecode(value){ | |
"use strict"; |
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
// isOneOf() : see https://gist.github.com/davask/4571536 | |
function length(obj) { | |
"use strict"; | |
var count = 0; | |
if (isOneOf(obj, 'Object')) { | |
for (var k in obj) { | |
if (obj.hasOwnProperty(k)) { | |
++count; | |
} | |
} |
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
// http://stackoverflow.com/questions/8525206/javascript-the-most-efficient-way-to-check-if-a-variable-is-a-function-an-arra?answertab=votes#tab-top | |
function isOneOf(obj, types) { | |
"use strict"; | |
var type; | |
type = Object.prototype.toString.call(obj); | |
return types.split(' ').some(function (t) { | |
return type.indexOf(t) > -1; | |
}); | |
} |
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
http://stackoverflow.com/questions/11259140/sass-not-recognised-using-windows-command-shell | |
find folder like | |
C:\Program Files (x86)\custom\web\Ruby193\bin | |
where "gem" and "gem.bat" file exists |
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 is_empty(obj) { | |
"use strict"; | |
// assign object type | |
var objType = Object.prototype.toString.call(obj); | |
// is type === object | |
if (objType === '[object Object]') { | |
// Assume if it has a length property with a non-zero value | |
// that that property is correct. | |
if (obj.length && obj.length > 0) { 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
// concat multiple json in one | |
function jsonConcat(arrayjson) { | |
"use strict"; | |
var o = {}; | |
for(var i=0; i<arrayjson.length; i++) { | |
o = concat2json(o, arrayjson[i]); | |
} | |
return o; | |
} |
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
// get browser language in this format US, FR, ... | |
var getBrowserLanguage = function (){ | |
"use strict"; | |
// navigator.userLanguage for IE, navigator.language for others | |
var lang = navigator.language || navigator.userLanguage; | |
lang = lang.split('-'); | |
return lang[1]; | |
}; // END FUNC | |
// example |
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
// see : http://www.quirksmode.org/js/detect.html | |
var BrowserDetect = { | |
init: function() { | |
"use strict"; | |
this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; | |
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; | |
this.OS = this.searchString(this.dataOS) || "an unknown OS"; | |
}, | |
searchString: function(data) { | |
"use strict"; |
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
// see : http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml | |
// Load a js or a css file | |
var filesadded = "", //list of files already added | |
fileref = ""; | |
function checkloadjscssfile (filename, filetype) { | |
"use strict"; | |
if (filesadded.indexOf("[" + filename + "]") === -1) { | |
if (loadjscssfile(filename, filetype)) { | |
filesadded += "[" + filename + "]"; //List of files added in the form "[filename1],[filename2],etc" |
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
/* Filter table from a database */ | |
/* see : http://stackoverflow.com/questions/6528531/mysql-show-tables-sort-by-table-name?answertab=votes#tab-top */ | |
/* string $filter = filter */ | |
/* string $dbn = database name */ | |
SELECT table_name | |
FROM information_schema.tables | |
WHERE table_type = 'BASE TABLE' AND table_schema='$dbn' AND table_name LIKE '$filter' | |
ORDER BY table_name ASC; |
OlderNewer