Skip to content

Instantly share code, notes, and snippets.

View yock's full-sized avatar

Michael Yockey yock

View GitHub Profile
@yock
yock / gcd.js
Created March 14, 2017 02:47
Pi Day!
const iterations = 1000000;
const max = 1000000;
let count = 0;
const random = () => {
return Math.floor(Math.random() * max);
}
const euclid_gcd = (a, b) => {
typedef struct Color {
int red, green, blue;
};
const Color red = {255, 0, 0};
const Color green = {0, 255, 0};
const Color white = {255, 255, 255};
const Color yellow = {255, 255, 0};
const Color orange = {255, 100, 0};
const Color off = {0, 0, 0};
@yock
yock / bot.js
Last active May 15, 2019 15:22
Nodebots Day Code
var five = require("johnny-five");
var Particle = require("particle-io");
var board = new five.Board({
io: new Particle({
token: 'mytoken',
deviceName: 'changeme!'
})
});
function static_server() {
PORT=8080
lsof -i :$PORT > /dev/null
while (( $? == 0 )) {
PORT=$((PORT+1))
lsof -i :$PORT
}
nohup python -m SimpleHTTPServer $PORT &
@yock
yock / about.md
Last active April 13, 2016 19:50
elevator_saga.js

Elevator Saga

A programming challenge for dispatching elevators. If you've ever waited for an elevator and thought about how much sorter the wait would be if you were the programmer, give this a try.

http://play.elevatorsaga.com/

About the Algorithm

This very simplistic implementation attempts to do just two things:

Keybase proof

I hereby claim:

  • I am yock on github.
  • I am yock (https://keybase.io/yock) on keybase.
  • I have a public key whose fingerprint is 328E 81DC 076B 6643 CA15 373E ED0B 6007 1F19 F833

To claim this, I am signing this object:

@yock
yock / dev.forwarding.apache
Last active March 30, 2016 03:24 — forked from scottslowe/pf-launchd-item
This is a launchd item that you could use to automatically start pf on OS X Mountain Lion at boot.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple Computer/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>dev.forwarding.apache</string>
<key>Program</key>
<string>/sbin/pfctl</string>
<key>ProgramArguments</key>
<array>
@yock
yock / uri.sh
Last active December 28, 2018 23:42
URL Parsing function for Bash
#
# URI parsing function
#
# The function creates global variables with the parsed results.
# It returns 0 if parsing was successful or non-zero otherwise.
#
# [schema://][user[:password]@]host[:port][/path][?[arg1=val1]...][#fragment]
#
function uri_parser() {
# uri capture
{
"env": {
"DATABASE_URL": {
"description": "Location of, and credentials to, the database instance for this app.",
"required": true
}
}
}
import Ember from 'ember';
import JSONStorable from 'forte-electron/mixins/json-storable';
export default Ember.Service.extend(JSONStorable, {
localStorageKey: 'publicKey',
add(publicKey) {
let allKeys = this.retrieve(this.get('localStorageKey')) || [];
if(publicKey != null) {
if(publicKey instanceof Array) {
allKeys.concat(publicKey);