Skip to content

Instantly share code, notes, and snippets.

View davidkellis's full-sized avatar

David Ellis davidkellis

View GitHub Profile
> open Archer.Collections;;
> let c = new LruCache<int,string>(3);;
val c : LruCache<int,string>
> c.Add(5, "a");;
val it : unit = ()
> c.Add(6, "b");;
val it : unit = ()
> c.Add(7, "c");;
val it : unit = ()

Keybase proof

I hereby claim:

  • I am davidkellis on github.
  • I am davidkellis (https://keybase.io/davidkellis) on keybase.
  • I have a public key whose fingerprint is 72B1 CBAA 4D75 C002 7400 3477 9262 2B71 FB8A D192

To claim this, I am signing this object:

@davidkellis
davidkellis / vms_analysis.fsx
Last active August 29, 2015 14:07
VMS Analysis
open System
module Decimal =
let Zero = 0M
let One = 1M
let ceil (d: decimal): decimal = System.Math.Ceiling(d)
let floor (d: decimal): decimal = System.Math.Floor(d)
@davidkellis
davidkellis / vms_analysis.rb
Created October 14, 2014 14:07
VMS Analysis
require 'time'
require 'pp'
require 'bigdecimal'
# This implementation is based on http://en.wikipedia.org/wiki/Quantiles#Estimating_the_quantiles_of_a_population
# For additional information, see:
# http://www.stanford.edu/class/archive/anthsci/anthsci192/anthsci192.1064/handouts/calculating%20percentiles.pdf
# http://en.wikipedia.org/wiki/Percentile
# http://www.mathworks.com/help/stats/quantiles-and-percentiles.html
#
@davidkellis
davidkellis / gist:b58535a0f230e1a550c8
Last active August 29, 2015 14:14
sequence expression headache
open System
let fromIEnumerator (xs: System.Collections.Generic.IEnumerator<'x>): seq<'x> =
seq {
while xs.MoveNext() do
yield xs.Current
}
let fromIEnumerable (xs: System.Collections.Generic.IEnumerable<'x>): seq<'x> = fromIEnumerator (xs.GetEnumerator())
1. type Foo = struct { X | Int, Float, Array[X]}
2. type Foo = struct {X ; Int, Float, Array[X]}
3. type Foo = Struct[X; Int, Float, Array[X]]
4. type Foo = struct [X; Int, Float, Array[X]]
1. type Foo = struct {
X |
Int,
Float,
Array[X]
@davidkellis
davidkellis / gist:909449e13905d8bfbd49c30d20f7fbca
Last active September 7, 2017 13:35 — forked from silviorelli/gist:ad8e1d80bdc0245eb7e7
Install Ruby 1.8.7 on macOS Sierra (10.12) with rbenv
brew install apple-gcc42 openssl libyaml libffi
xcode-select --install
export CC=/usr/local/bin/gcc-4.2
export CFLAGS='-g -O2'
export RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl`
export CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl`
# I had to edit the svn repo URL in /usr/local/Cellar/ruby-build/20160913/share/ruby-build/1.8.7-p375 and change the URL from http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7 to https://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7
rbenv install 1.8.7-p375
// I found the following implementation (verbatim) of Fibers in Go at https://play.golang.org/p/NSIlZ327sC
// I'm capturing it here for future reference.
package main
import (
"errors"
"fmt"
)
package hashids
MinAlphabetLength = 16
SepDiv = 3.5
GuardDiv = 12
DefaultAlphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
DefaultSeps = "cfhistuCFHISTU"
struct Encoder {
@davidkellis
davidkellis / gist:f90febaec142b7acad39a0621ea45a40
Last active September 2, 2017 03:51
interface examples that need to play nice together
interface Enumerable T for E {
fn each(E, T -> Unit) -> Unit
}
impl Enumerable T for Array T {
fn each(array: Array T, f: T -> Unit) -> Unit { ... }
}
impl Enumerable T for I : Iterator T {
fn each(it: I, visit: T -> Unit) = ...
}
impl Enumerable T for Iterator T {