Skip to content

Instantly share code, notes, and snippets.

View Fordi's full-sized avatar

Bryan Elliott Fordi

View GitHub Profile
@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 / econ_101.h
Last active April 15, 2021 05:58
Macro versions of pinMode and digitalWrite. Tend to be faster and smaller.
/**
* This file will reduce the size of and improve the performance of certain arduino code
* 1. It strips away about 310 bytes of overhead by replacing the implicit main function with a minimal one (which will also be faster)
* 2. It replaces the library `pinMode` and `digitalWrite` code with register-based variants - saving 120
* bytes - and which which perform faster than the built-ins for single-pin changes (for multi-pin changes,
* use the registers yourself).
*/
#ifndef ECON_101
#define ECON_101
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script>
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var context = new AudioContext();
function playSound(arr) {
var buf = new Float32Array(arr.length)
@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 / git-hash
Last active December 29, 2020 18:51
Get the current hash from a Git repository without external dependencies (including Git)
#!/bin/sh
# From the Stack response:
# http://stackoverflow.com/a/33133769/353872
#
# Also acts as a low-complexity example of how to flexibly parse the argument
# list in raw sh without external programs or a lot of fuss.
# For use in usage() and in log messages
SCRIPT_NAME="$(basename $0)"
@Fordi
Fordi / vc-rev
Last active December 9, 2020 17:16
vc-rev: similar to git-hash, except it works on svn repositories as well. Minimal dependency on sqlite3 for SVN repos
#!/bin/sh
# From the Stack response:
# http://stackoverflow.com/a/33133769/353872
#
# Also acts as a low-complexity example of how to flexibly parse the argument
# list in raw sh without external programs or a lot of fuss.
# For use in usage() and in log messages
SCRIPT_NAME="$(basename $0)"
(() => {
const letters = {
a: 'ay',
b: 'bee',
c: 'see',
d: 'dee',
e: 'eee',
f: 'eff',
g: 'jee',
h: 'aitch',
@Fordi
Fordi / CatBugVenn.svg
Created August 12, 2020 21:26
CatBug Venn Diagram, designed by Vincent Caduc - https://www.threadless.com/product/5222 <- If they sell them again, buy here.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Fordi
Fordi / mmx-gen.html
Created July 30, 2020 08:35
MegaMan X Password generator
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="ISO-8859-1">
<title>Mega Man X1 Password Generator</title>
<script type="module" defer>
import { render, html, css, useState } from 'https://unpkg.com/@fordi-org/buildless';
const heart = 'Heart Tank';
const subTank = 'Sub-tank';
const levels = {
  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;\\