Skip to content

Instantly share code, notes, and snippets.

View jfsiii's full-sized avatar

John Schulz jfsiii

View GitHub Profile
function xports(name, api){
if (typeof exports == 'object' && exports) {
if (typeof module == 'object' && module.exports == exports) {
module.exports = api;
} else {
exports[name] = api;
}
} else if (typeof define == 'function' && typeof define.amd == 'object') {
define(function() { return api; });
@jfsiii
jfsiii / testSupport.js
Created August 23, 2011 18:36
Test something, store the result, do something on success and/or failure, (optional) retest after failure
function testSupport(options){
var noop = function(){};
if (!options.name) throw Error('test needs a name');
if (!options.root) options.root = testSupport.results = {};
if (!options.success) options.success = noop;
if (!options.failure) options.failure = noop;
var run = function(options){
var result = (typeof options.test === 'function') ? options.test(options) : options.test;
options.root[options.name] = result;
([options.failure, options.success][+result])(options);
@jfsiii
jfsiii / testSupport.js
Created August 23, 2011 18:36
Test something, store the result, do something on success and/or failure, (optional) retest after failure
function testSupport(options){
var noop = function(){};
if (!options.name) throw Error('test needs a name');
if (!options.root) options.root = testSupport.results = {};
if (!options.success) options.success = noop;
if (!options.failure) options.failure = noop;
var run = function(options){
var result = (typeof options.test === 'function') ? options.test(options) : options.test;
options.root[options.name] = result;
([options.failure, options.success][+result])(options);
@jfsiii
jfsiii / jquery.flot-on-node.js
Created November 14, 2011 15:21
Flot 0.7 updated to support node-cavas
/*! Javascript plotting library for jQuery, v. 0.7.
*
* Released under the MIT license by IOLA, December 2007.
*
*/
// first an inline dependency, jquery.colorhelpers.js, we inline it here
// for convenience
/* Plugin for jQuery for working with colors.
@jfsiii
jfsiii / node-flot-example.js
Created November 14, 2011 16:52
Flot 0.7 running on node
require('jsdom').env({
html: '<html><body></body></html>', // URL or markup required
scripts: [
// can't use jQuery 1.7+, atm, b/c of https://github.com/NV/CSSOM/issues/29
'http://code.jquery.com/jquery-1.6.4.min.js',
// Flot 0.7 patched to support node-canvas
'https://raw.github.com/gist/1364155/8d9161159d1e2bbed1a34aad90dd6d7af07a7ccf/jquery.flot-on-node.js'
],
done: function (errors, window)
@jfsiii
jfsiii / Flot_0_7.patch
Created November 14, 2011 16:56
Flot 0.7 updated to support node-canvas
42a43,44
> width: null,
> height: null,
137c139,141
< hooks: {}
---
> hooks: {},
> width: null,
> height: null
687c691,696
@jfsiii
jfsiii / JFSIII.theme.bash
Created November 22, 2011 22:30
My current BASH_IT theme
#!/bin/bash
function prompt_command()
{
scm_prompt_vars
if [[ $SCM != $SCM_NONE ]]
then
local scm_info=" $blue[$SCM_BRANCH @ ${SCM_CHANGE:0:7}] $SCM_STATE";
@jfsiii
jfsiii / supports.js
Created December 7, 2011 22:46
First cut at a simple capability testing
(function (global) {
// test: function to run OR value representing result
// root: object where results are stored
// name: key in storage object
// success: function to run on success
// failure: function to run on failure
// retest: should the test be re-run after a failure
// (eg. failure applied a polyfill)
// test must be a function to retest
function test(options)
@jfsiii
jfsiii / gimmmeauth.js
Created December 24, 2011 19:51
authorize using GimmieBar API
console.log('get REQUEST token', clientId, clientSecret);
gimmeOauth.getRequestToken(clientId, clientSecret, function(error, token){
if (error) {
console.error(error);
} else {
console.log('got REQUEST token', token);
console.log('get ACCESS token', clientId, token);
gimmeOauth.getAccessToken(clientId, token, function(error, data) {
if (error) console.error(error);
else {
@jfsiii
jfsiii / index.html
Created January 10, 2012 17:51 — forked from joubertnel/gist:870190
HTML5 Canvas - Rendering of Text on high-DPI screens
<html>
<head>
<script src='http://code.jquery.com/jquery-1.5.1.min.js'></script>
</head>
<body>
<h2>Naive canvas</h2>
<canvas id="naive" width="400" height="50"></canvas>
<h2>High-def Canvas</h2>