Skip to content

Instantly share code, notes, and snippets.

def optimal_move state
return state if Math.sqrt(state) % 1 == 0 # its a perfect square
(1..Math.sqrt(state)).each { |n| return n*n if optimal_move(state - (n*n)) == -1 }
return -1
end
require 'io/console'
class TicTacToe
attr_reader :state
def initialize *players
@players = players
@state = players.map { Array.new(9) }
@marks = ['X','O']
@dustMason
dustMason / keybase.md
Created August 4, 2017 22:09
keybase.md

Keybase proof

I hereby claim:

  • I am dustmason on github.
  • I am dustmason (https://keybase.io/dustmason) on keybase.
  • I have a public key ASCHhKGcG3EAzzZ3-nz6OEC2IxecrY77ntKiusv920L8lwo

To claim this, I am signing this object:

def find_median_sorted arr1, arr2
joined = (arr1 + arr2).sort
if joined.size % 2 == 0
return joined[(joined.size/2)-1..(joined.size/2)].reduce(&:+) / 2.0
else
return joined[joined.size/2]
end
end
<table>
<tr>
<th>
Column 1
</th>
<th>
Column 2
</th>
<th>
class Solution
# @param a : array of integers
# @return an integer
def solve(a)
found = -1
sorted = a.select { |n| n >= 0 }.sort
s = sorted.size
sorted.each_with_index do |n, i|
if n >= 0 && n == s - 1 - i && sorted[i+1] != n
@dustMason
dustMason / deps.sh
Last active January 11, 2022 15:51 — forked from prashantmaurice/install-ffmpeg-amazon-linux.sh
How to compile ffmpeg on Amazon Linux (EC2) for use on AWS Lambda
#!/bin/bash
# Author : Hemanth.HM
# Email : hemanth[dot]hm[at]gmail[dot]com
# License : GNU GPLv3
#
function useage()
{
cat << EOU
Useage: bash $0 <path to the binary> <path to copy the dependencies>
@dustMason
dustMason / midi.js
Created June 1, 2017 20:50
Simple web midi implementation
var OP1MidiInterface = function(midi) {
var data, cmd, channel, type, note, velocity;
midi.inputs.forEach(function(input) {
if (input.name.indexOf('OP-1') > -1) {
document.dispatchEvent(new Event('midi-connected'));
input.onmidimessage = onMIDIMessage;
}
});
midi.onstatechange = onStateChange;
@dustMason
dustMason / op-1-keys.js
Created June 1, 2017 20:46
Interactive OP-1 keys
(function(document, window) {
var fullWidth = 1111.0;
var img = document.querySelector("#op1-keys:not([data-ready])");
if (img) {
var keys = [
[[210, 58], [270, 173]], // F
[[211, 0], [298, 57]], // F#
[[269, 58], [327, 174]],

Arbotunity Report Apr 21, 5:45:07 PM

Commissions:

  • gdax: 0.00%
  • polo: 0.25%
  • kraken: 0.10%
  • btrx: 0.25%

Arbo | Asset | Buy On | Buy @ | Qty | Sell On | Sell @ | Fee | Profit