Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeremy PELE jeremypele

View GitHub Profile
View robot.js
//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 / disable_console.js
Created Mar 7, 2014
Disable javascript console
View disable_console.js
(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 Aug 6, 2015
[Chrome Snippets] Ng-Digest-Performance
View 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 Aug 6, 2015
[Chrome Snippets] Ng-Stats
View 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 Aug 6, 2015
[Chrome Snippets] LocalStorage Stats
View 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 Aug 6, 2015
[Chrome Snippets] First Paint
View 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 / timings
Created Aug 6, 2015
[Chrome Snippets] Timing
View timings
/**
* Timing.js 1.0.4
* Copyright 2015 Addy Osmani
*/
(function(window) {
'use strict';
/**
* Navigation Timing API helpers
* timing.getTimes();
@jeremypele
jeremypele / ng_scopes_size
Created Aug 6, 2015
[Chrome Snippets] Ng-scopes-sizes
View ng_scopes_size
// 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;
View gist:e4e4c5717875a1e2b5ea
// 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 / chrome_stable
Created Nov 7, 2016
Use latest version chrome
View chrome_stable
#!/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