Skip to content

Instantly share code, notes, and snippets.

View jeffreytgilbert's full-sized avatar

Jeffrey Gilbert jeffreytgilbert

View GitHub Profile
# oh-my-zsh Zen Theme
### Git
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[green]%}%{$reset_color%}%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_no_bold[white]%}☁%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_no_bold[magenta]%}▴%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg_no_bold[magenta]%}▾%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_no_bold[green]%}✚%{$reset_color%}"
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="robbyrussell"
#ZSH_THEME="cloud"
#ZSH_THEME="wedisagree" # throws an error
@jeffreytgilbert
jeffreytgilbert / sized-async-queue.js
Created April 3, 2014 17:00
Example of sized queues, for things like, oh, i don't know, running limited numbers of selenium tests in parallel or downloading images two at a time or whatever.
var runningProcessCount = 0,
processQueuePosition = 1,
processLimit = 2,
totalProcesses = 10;
function throttleProcesses(){
if(processLimit > runningProcessCount){
fakeProcess();
return true;
} else {
@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 / 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 -->