Skip to content

Instantly share code, notes, and snippets.

View jeremypele's full-sized avatar

Jeremy PELE jeremypele

View GitHub Profile
@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$$) {
@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 / 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 / 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 / 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 / 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 / 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 / robot.js
Created December 6, 2012 14:24
FidjyNator
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(50);
@jeremypele
jeremypele / timings
Created August 6, 2015 13:07
[Chrome Snippets] Timing
/**
* Timing.js 1.0.4
* Copyright 2015 Addy Osmani
*/
(function(window) {
'use strict';
/**
* Navigation Timing API helpers
* timing.getTimes();
@jeremypele
jeremypele / chrome_stable
Created November 7, 2016 17:00
Use latest version chrome
#!/bin/bash
function useStableChromeVersion {
curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb;
sudo dpkg -i google-chrome.deb;
sudo sed -i 's|HERE/chrome\"|HERE/chrome\" --disable-setuid-sandbox|g' /opt/google/chrome/google-chrome;
rm google-chrome.deb
}
useStableChromeVersion