Skip to content

Instantly share code, notes, and snippets.

View Illizion's full-sized avatar
🤒
Out sick

Illizion Illizion

🤒
Out sick
View GitHub Profile
@timhobbs
timhobbs / camelCase.js
Created June 6, 2018 04:05 — forked from johnsmith17th/camelCase.js
To convert string to camel case in javascript.
function toCamelCase(string) {
string = string.toLowerCase().replace(/(?:(^.)|([-_\s]+.))/g, function(match) {
return match.charAt(match.length-1).toUpperCase();
});
return string.charAt(0).toLowerCase() + string.substring(1);
}
We couldn’t find that file to show.
@timhobbs
timhobbs / gist:bb8a304a8d008d74fd29
Last active November 30, 2018 02:37
C# style String.Format for JS
/* Examples:
* var test = "test {0} {1}, {2} - {0} {1} {2}".format('a', 'b', 'c');
* var test2 = "the {0} ate the {1}".format("cat", "canary");
*/
String.prototype.format = function () {
var self = this;
var re = /\{\d+\}/g;
var m = self.match(re);
var indexes = [];
(function(AP, isF) {
'use strict';
// isArray : https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
Array.isArray || (Array.isArray = function (a) {
return Object.prototype.toString.call(a) == "[object Array]";
});
// toSource(Non-standard)
AP.toSource || (AP.toSource = function() {