Skip to content

Instantly share code, notes, and snippets.

View jeremypele's full-sized avatar

Jeremy PELE jeremypele

View GitHub Profile
@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 / 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$$) {
@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);