Skip to content

Instantly share code, notes, and snippets.

View Fordi's full-sized avatar

Bryan Elliott Fordi

View GitHub Profile
@Fordi
Fordi / Object.watch.js
Last active August 29, 2015 14:17
Object.watch and Object.getMetadata for all browsers
/***
* Object.watch / Object.unwatch for all browsers
* Plus bonus: Object.assign / Object.getMetadata / Object.getGUID
* @author Bryan Elliott
* @copyright 2015 GPLv2
**/
(function () {
"use strict";
var meta = {},
guid = 1,
@Fordi
Fordi / lzw.js
Last active March 3, 2019 04:05 — forked from anonymous/lzw.js
export const lzw = {
decode: str => {
var i, code, phrase,
dict = {},
chr = str[0],
last = chr,
out = [chr],
next = 256;
for (i = 1; i < str.length; i++) {
code = str[i].charCodeAt(0);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Fordi
Fordi / Finn the Humanist.md
Last active December 25, 2015 19:39
Finn the Humanist

Download the SVG file and open it in Inkscape or Illustrator, and export at the resolution you need.

  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;\\
@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 {
/**
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 / 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'
};
@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 / 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