Skip to content

Instantly share code, notes, and snippets.

View yock's full-sized avatar

Michael Yockey yock

View GitHub Profile
@yock
yock / backup.sh
Created March 22, 2017 14:59
Super primitive database backup script
#!/bin/bash
backup_date=$(date +%s)
defaults_file=./my.cnf
destination=./backups
basename=backup
cleanup=false
cleanup_interval="+30"
dryrun=false
compress=false
@yock
yock / pki.yml
Last active March 16, 2017 14:13
- hosts: all
tasks:
- name: Update public keys
authorized_key:
user: server_username
key: https://github.com/github_username.keys
@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};
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>
{
"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);