Skip to content

Instantly share code, notes, and snippets.

View damonmcminn's full-sized avatar

Damon McMinn damonmcminn

View GitHub Profile
@damonmcminn
damonmcminn / anagrams_280.rb
Created February 26, 2017 20:05
VERY SLOW
require 'set'
# monkey path String for simplicity and readability
class String
def normalized
# replace all non-alphabet characters with nothing
downcase.gsub(/[^[:alpha:]]/, '')
end
def anagram_id
@damonmcminn
damonmcminn / anagram.rb
Created February 25, 2017 13:34
Anagram Detector
class Anagram
def initialize(str)
@str = str
end
def normalized
@str.split('?').map do |word|
# replace all non-alphabet characters with nothing
word.downcase.gsub(/[^[:alpha:]]/, '')
end
@damonmcminn
damonmcminn / Goldilocks.fsx
Last active February 22, 2017 14:32
Goldilocks
type Weight = Weight of int
type Temperature = Temperature of int
type Capacity = Capacity of Weight
type Goldilocks = {
Weight:Weight
MaxTemp:Temperature
}
type Chair = {
@damonmcminn
damonmcminn / DFA.fsx
Created February 12, 2017 15:38
Garage Door Opener
type FiniteAutomataRule<'State, 'Input> = {
State:'State
Input:'Input
NextState:'State
}
type DoorState =
| Open
| Closed
| Opening
@damonmcminn
damonmcminn / dynamic_output.md
Last active February 5, 2017 16:23
Computing Fibonacci in Crystal

DYNAMIC

AMD A10-4600M APU with Radeon(tm) HD Graphics × 4)

                    user     system      total        real
fib 1000        0.000000   0.000000   0.000000 (  0.001114)
fib 10000       0.010000   0.000000   0.010000 (  0.016190)
fib 100000      0.640000   0.090000   0.730000 (  0.564936)
fib 500000      14.650000   3.230000   17.880000 (  12.655379)
fib 1000000 56.280000 10.130000 66.410000 ( 46.374916)
@damonmcminn
damonmcminn / InfiniteFunction.fsx
Last active January 26, 2017 15:22
Infinite Function in F#
// a recursive type
type AnonResult<'T> =
| Value of 'T
| Fn of ('T-> AnonResult<'T>)
// only accepts functions that take two args
let rec create (fn : 'T -> 'T -> 'T) =
// this can probably be achieved more idiomatically with recursion
// but the mutation is localised...
let mutable accumulatedValue : 'T option = None
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
context "GET index" do
#context "POST create" do
#context "GET show" do
#context "PATCH update" do (or PUT update)
#context "DELETE destroy" do
#context "GET new" do
body {
width: 100%;
height: 100%;
}
.slideout-menu {
position: fixed;
left: 0;
top: 0;
bottom: 0;

Keybase proof

I hereby claim:

  • I am damonmcminn on github.
  • I am damonmcminn (https://keybase.io/damonmcminn) on keybase.
  • I have a public key whose fingerprint is 5952 35E5 9861 4110 D68C 3BFD 0D2B 5D7A 00B5 CFAB

To claim this, I am signing this object:

<?php
$begin = new DateTime('now');
$beginformat = $begin->format("Y-m-d");
$beginfinal = strtotime($beginformat);
$end = $begin->modify("+90 day");
$endformat = $end->format("Y-m-d");
$endfinal = strtotime($endformat);
$dates = array();