Skip to content

Instantly share code, notes, and snippets.

View jeremypele's full-sized avatar

Jeremy PELE jeremypele

View GitHub Profile
@jeremypele
jeremypele / gist:e4e4c5717875a1e2b5ea
Created October 5, 2015 13:42
[JS] Modules namespacings
// Namespace creation method
function setNamespace (ns_string, ns) {
var parts = ns_string.split('.'),
parent = ns;
if (parts[0] === "App") {
parts = parts.slice(1);
}
var pl = parts.length;
for (var i = 0; i < pl; i++) {
//create a property if it doesnt exist
@jeremypele
jeremypele / ng_scopes_size
Created August 6, 2015 13:13
[Chrome Snippets] Ng-scopes-sizes
// Finds total size of objects attached to the scopes
(function ngScopeSize() {
var i, data, scope,
count = 0,
all = document.all,
len = all.length,
test = {},
scopes = 0;
@jeremypele
jeremypele / first_paint
Created August 6, 2015 13:07
[Chrome Snippets] First Paint
// taken from https://www.youtube.com/watch?v=S9sktFzL3tQ
(function timeFirstPaint() {
/* global chrome */
var fp = chrome.loadTimes().firstPaintTime - chrome.loadTimes().startLoadTime;
console.log('first paint: ' + fp);
}());
@jeremypele
jeremypele / localstorage_stats
Created August 6, 2015 13:06
[Chrome Snippets] LocalStorage Stats
// based on answer to question
// http://stackoverflow.com/questions/4391575/how-to-find-the-size-of-localstorage
(function showLocalStorageSize() {
function stringSizeBytes(str) {
return str.length * 2;
}
function toMB(bytes) {
return bytes / 1024 / 1024;
}
@jeremypele
jeremypele / ng_stats
Created August 6, 2015 13:06
[Chrome Snippets] Ng-Stats
javascript: (function() {var a = document.createElement("script");a.src = "https://rawgithub.com/kentcdodds/ng-stats/master/dist/ng-stats.js";a.onload=function(){window.showAngularStats()};document.head.appendChild(a)})();
@jeremypele
jeremypele / ng_digest_performance
Created August 6, 2015 13:05
[Chrome Snippets] Ng-Digest-Performance
console.log("___Digest Time")
angular.element(document).injector().invoke(function($rootScope) { var a = performance.now(); $rootScope.$apply(); console.log(performance.now()-a); })
@jeremypele
jeremypele / disable_console.js
Created March 7, 2014 08:23
Disable javascript console
(function() {
try {
var $_console$$ = console;
Object.defineProperty(window, "console", {
get: function() {
if ($_console$$._commandLineAPI)
throw "Sorry, for security reasons, the script console is deactivated on this website";
return $_console$$
},
set: function($val$$) {