Skip to content

Instantly share code, notes, and snippets.

Michael Yockey yock

Block or report user

Report or block yock

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View index.js
/**
* Makes ideal change based on the difference between the purchase price of an item,
* how much cash is tendered, and the current contents of the register
*
*/
const makeChange = (purchasePrice, cashTendered, cashRegisterContents) => {
// Exact change tendered
// Oops
throw 'Insufficient Funds';
@yock
yock / bot.js
Created Feb 22, 2018
Particle Bot
View bot.js
/*
With much credit to @BrianGenisio, this code is almost entirely his.
https://github.com/CareEvolution/nodebots-unleashed-codemash-docs/blob/master/examples/base-sumobot.js
*/
import Five from 'johnny-five';
import board from './board';
board.on("ready", function() {
console.log('ready');
View authenticator_controller.rb
class AuthenticateController < ApplicationController
DIGEST = OpenSSL::Digest::SHA256.new
def show
end
def create
nonce = Time.now.to_i
token = SecureRandom.hex
hmac = OpenSSL::HMAC.digest(DIGEST, 'soopersecret', "#{nonce}#{token}")
@yock
yock / backup.sh
Created Mar 22, 2017
Super primitive database backup script
View backup.sh
#!/bin/bash
backup_date=$(date +%s)
defaults_file=./my.cnf
destination=./backups
basename=backup
cleanup=false
cleanup_interval="+30"
dryrun=false
compress=false
View pki.yml
- hosts: all
tasks:
- name: Update public keys
authorized_key:
user: server_username
key: https://github.com/github_username.keys
View gcd.js
const iterations = 1000000;
const max = 1000000;
let count = 0;
const random = () => {
return Math.floor(Math.random() * max);
}
const euclid_gcd = (a, b) => {
View led_pulsing.c
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
Nodebots Day Code
View bot.js
var five = require("johnny-five");
var Particle = require("particle-io");
var board = new five.Board({
io: new Particle({
token: 'mytoken',
deviceName: 'changeme!'
})
});
View static-server.zsh
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 Apr 13, 2016
elevator_saga.js
View about.md

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:

You can’t perform that action at this time.