Skip to content

Instantly share code, notes, and snippets.

View Fordi's full-sized avatar

Bryan Elliott Fordi

View GitHub Profile
@Fordi
Fordi / rules.js
Created January 31, 2012 14:56
Rules engine for Javascript
/**
* Simple javascript rules engine
*
* @author Bryan Elliott
* @link http://codemonkeybryan.com
*
* A RuleSet is essentially a simple list of voters. By executing the RuleSet,
* you iterate over the voters and obtain a done/fail event via jQuery's Deferred
* interface.
*
@Fordi
Fordi / workflow-demo.js
Created January 31, 2012 23:41
Javascript Workflow Processor
(function () {
var sayHi = function (token) {
if (!token.progress) token.progress = {};
token.progress.saidHi = (token.progress.saidHi||0) + 1;
//true == simply proceed; false == reject workflow
return true;
},
shakeIt = function (token, next) {
token.progress.shook = (token.progress.shook||0) + 1;
next('right');
@Fordi
Fordi / checkbox.css
Created June 12, 2012 16:44
Cross-browser checkbox styling with graceful fallback (now with less!)
/**
Usage (the label is required)
<input id="uid" type="checkbox" ... /><label for="uid">Label</label>
Produces styled checkboxes in IE9+, current Firefox and Chrome
Demo here: http://jsfiddle.net/7Fggq/
@author Bryan Elliott <ook@codemonkeybryan.com>
*/
@Fordi
Fordi / energy-policy-rant.md
Created July 31, 2012 03:55
Energy policy rant

First, a little context. I discovered that my policy views are largely compatible with those of Jill Stein. Unfortunately, this survey largely omits energy policy. Since energy policy is, in my opinion, the most important thing in the current spectrum of US policy, I consider this a massive oversight.

How we approach problems with energy scarcity is the single most important political question of our age.

Energy, simply put, is the capacity to do work. Because of this, it helps drive economy. It is what we use to convert natural resources into goods. It is what we use to convert sunlight into food. It is what we use to convert labor into leisure. Our ability to extract and use energy to perform work is one of the biggest reasons that slavery is relegated to illegal operations around the world. We've made energy our slave, so we no longer need to make slaves of each other.

Energy, additionally, is "free" - in that the human race does not synthesize th

@Fordi
Fordi / infacnt-care.md
Created October 6, 2012 15:17
How to care for an infant
  • Bottle every 2 hours (today, he started at 9:30a)
    • 3 oz, warmed to blood temperature in microwave in mug of water
      • In your Microwave, this proved to take about 30 sec
    • During feeding, Wiggle the nipple gently until you can tell he's getting suction
      • The vent will be dry
      • You'll see bubbles rising to the formula's surface inside the bottle as air enters via the vent
  • In case of crying
    1. Is his diaper dirty?
      • Simple test is if the front feels swollen; if so, he's peed at least.
  • Poop will have a distinct smell; carefully open the back and look for signs
@Fordi
Fordi / dl.js
Created October 18, 2012 05:33
dl
function dl(d,vs,vr,ts,tr) {
var c = d.createElement('div'),
s = c.style,
a = d.createElement('a'),
ve = d.querySelector(vs),
vd = ve.getAttribute('value') || ve.getAttribute('flashvars'),
u = unescape((vd.match(vr)||[])[1]||''),
t = d.querySelector(ts).innerHTML.replace(tr, '$1');
a.href=u;
a.innerHTML = "Download";
@Fordi
Fordi / example.js
Created November 25, 2012 21:27
Replace in DOM textNodes
// Early version of the Acronym Helper I'm working on.
(function (global) {
"use strict";
var $ = global.jQuery,
acronyms = {
'FAQ' : 'Frequently Asked Questions',
'TIL' : 'Today I Learned',
'ITT' : 'In This Thread',
'SRS' : 'A Load of Dingo\'s Kidneys'
};
/**
The idea here is that all changes to your new object can be observed
*/
Ember.View.extend({
model: Ember.StalkableObject.create(),
saveModel: Ember.observer(function () {
/** do some fancy stuff to save changes to your model */
}, 'model.@properties')
});
@Fordi
Fordi / Custom.css
Last active December 23, 2015 07:59
Custom stylesheet for Chrome to enable adaptive zoom for two-up and multi-up browsing To locate appropriate location, browse to about:version, go to the Profile Path in Finder/Explorer, and browse to User StyleSheets, and replace your existing Custom.css, or create it there if it doesn't exist
/**
Custom stylesheet for Chrome to enable adaptive zoom for two-up and multi-up browsing
To locate appropriate location, browse to about:version, go to the Profile Path in
Finder/Explorer, and browse to User StyleSheets, and replace your existing Custom.css,
or create it there if it doesn't exist
**/
@-webkit-keyframes fadeout {from{opacity:1; top: 0; } to {top:0; } }
html::before {
  1. Define a circle as the set of points equidistant from a center point.
  2. The Pythagorean theorem allows us to work out an equation to define the points that fit this curve, by using h as the radius
    x^2 + y^2 = h^2
  3. Setting the radius to 1 simplifies this, making our equation the unit circle
    x^2 + y^2 = 1
  4. To make this parametric (i.e., give an x, get a y), we rearrange thusly:
    y = f(x) = sqrt(1 - y^2)
  5. Since we know a circle is vertically and horizontlly symmetrical, we can simplify things by dropping the +/-, and by looking only at 0 <= x <= 1; the area under that curve will be 1/4 pi.
    ![f(0 <= x <= 1) = sqrt(1 - x^2)](http://latex.codecogs.com/png.latex?f\(0&amp;space;\\leq&amp;space;x&amp;space;\\leq&amp;space;1\)&amp;space;=&amp;space;\\