Skip to content

Instantly share code, notes, and snippets.

View jeffreytgilbert's full-sized avatar

Jeffrey Gilbert jeffreytgilbert

View GitHub Profile
@jeffreytgilbert
jeffreytgilbert / show-me-your-plugins.js
Created April 3, 2014 17:01
Scan over all the plugins available in a browser. Does not work under mozilla browsers who have disabled this ability.
var $$$i = 0,
$$mt = [];
while(navigator.mimeTypes[$$$i]){
$$mt.push(navigator.mimeTypes[$$$i]);
$$$i++;
}
console.table($$mt.map(function(i,v,a){
return {
'name':i.description||i.enabledPlugin.description,
var
express = require( 'express' ),
connect = require('connect'),
app = express();
count = 0;
app.configure( function() {
app.use(connect.urlencoded());
app.use(connect.json());
});
@jeffreytgilbert
jeffreytgilbert / solution-timer.js
Last active August 29, 2015 14:00
CommonJS module for managing a timeline of timers with an optional execution time limit. The timers can all be paused and resumed independent of the execution timer. This was tested to within 1/100th of a second accuracy in Chrome, but uses Date.now() which is not compatible with some older browsers (IE 9 for instance). Easy to replace with new …
'use strict';
// ****** BEGIN SOLUTION TIMER ******* //
module.exports = (function () {
// all times will be measured in seconds by default
return function (_arrayOfTimes, _scriptTimeLimit, _timerCallback, _timeLimitCallback, _useMilliseconds) { // _useSeconds - add this later to add the ability to measure in milliseconds
var _startTime = 0, // the time this script started
_initialPlayTime = 0, // the time the playhead initially started
@jeffreytgilbert
jeffreytgilbert / FPSUtils
Last active August 29, 2015 14:01
Measure FPS at a sub second sampling level. Check can be throttled by time passed, based as a guesstimate of (frames x frame time) given stage FPS as a limit. When Flash throttles playback, timers are limited to 2 per second and up to 2 frames per second, so you can't improve that by using timers vs frames.
package FPSUtils {
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.external.ExternalInterface;
import flash.utils.clearInterval;
import flash.utils.getTimer;
@jeffreytgilbert
jeffreytgilbert / posers.js
Last active August 29, 2015 14:02
Sometimes android browsers get iphone envy and try to pretend they're mobile safari... So I broke it down by os by feature detection, because i needed to for this.
// see if this is a mobile browser
var w = window, d = document;
var regex = /mobi|android|webos|blackberry|ipad|ipod|iphone|tablet|phone|kindle/i;
r.mobile = regex.test(ua) || regex.test(w.navigator.platform);
if (r.mobile) {
if (w.chrome || w.performance) { // this is an android device posing as an iPhone
if (w.Worker) { // android 4.4+
var open = require('open');
var url = require('url');
var http = require('http');
var twitterAPI = require('node-twitter-api');
var Q = require('q');
var authObject = (function () {
var deferred = Q.defer();
var twitter = {};
var token = {};
@jeffreytgilbert
jeffreytgilbert / notes.md
Created September 8, 2014 20:17
Research notes into browser throttling behaviors

Research

Throttling and Browser Optimization

Flash Support

It is known that certain VMs can reduce the amount of FPS allowed by Flash in order to provide a more performant experience for their users. One known software is VMWare. Because we do extensive testing using SauceLabs browser grid service through selenium webdriver, we wanted to test the compatibility with real world results on specific browsers we were seeing odd results in. Below are some of the findings from this research, which resulted in our adoption of IE11 on Windows 8 and our drop of IE optimization detection on all other Windows releases.

FPS throttle detection unsupported
@jeffreytgilbert
jeffreytgilbert / js-perf-struct-frame.html
Created September 8, 2014 20:22
A container to frame content so positioning it outside of the viewport is easier.
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<link href="test-styles.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFF99" bottommargin="0" rightmargin="0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div style="position:relative; border:10px solid #228b22; width:820px; height:250px;">
<!-- first frame is positioned where it will be in view by the container iframe in the parent document -->
@jeffreytgilbert
jeffreytgilbert / js-test-frame.html
Created September 8, 2014 20:27
Framed documents which try and force redraws in the browser and then measure the rates at which they redraw to discover discrepancies in browser behavior.
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<link href="test-styles.css" rel="stylesheet" type="text/css">
<style>
body {
margin:0;
padding:0;
background-color:#ff99ff;
}
@jeffreytgilbert
jeffreytgilbert / index.html
Created September 8, 2014 20:30
Main document for loading throttling tests in various browsers. This document loads the other test frames in various ways where they are outside and inside the viewport, then moves them all back into the viewport once tests have completed.
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<link href="test-styles.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#eeeeff" bottommargin="0" rightmargin="0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div style="float:left;position:relative; border:10px solid royalblue; width:820px; height:1100px;">
<!-- show 1 iframe and box out the other -->