Skip to content

Instantly share code, notes, and snippets.

View bluetwin's full-sized avatar

Brandon Sislow bluetwin

View GitHub Profile
@bluetwin
bluetwin / application_foot.js
Created February 3, 2017 22:19
application_foot.js deminified
This file has been truncated, but you can view the full file.
function _classCallCheck(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
}
function _classCallCheck(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
}
function _classCallCheck(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
@bluetwin
bluetwin / application_foot.js
Created February 3, 2017 22:19
application_foot.js deminified
This file has been truncated, but you can view the full file.
function _classCallCheck(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
}
function _classCallCheck(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
}
function _classCallCheck(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
@bluetwin
bluetwin / speadsheet_buffer.rb
Last active August 29, 2015 13:56
Trivial example of writing to a spreadsheet using a buffer
require 'spreadsheet'
def speadsheet_with_buffer
buf = StringIO.new
book = Spreadsheet::Workbook.new
sheet = book.create_worksheet :name => "New Worksheet"
sheet.row(0).concat %w{col_1, col_2, col_3}
sheet[1,0] = "next row, first column"
book.write buf
@bluetwin
bluetwin / running_stat.rb
Last active December 16, 2015 00:59
RunningStat Class that uses Welford's Method for computing variance on a dataset
class RunningStat
attr_reader :n, :oldM, :newM, :oldS, :newS
def initialize
@n = 0
end
def clear
@n = 0
end
@bluetwin
bluetwin / Fibonacci.rb
Last active December 15, 2015 13:39
Four versions of finding the nth element on the Fibonacci series
# Four versions of the Fibonacci solution for the nth element
# Iterative
def fib(n)
if n < 2
num = n
else
n1 = 1
n2 = 0
n-1.times do |i|
@bluetwin
bluetwin / SuffixArray.rb
Last active December 15, 2015 13:39
Suffix Array implementation in Ruby
# Originally viewed on Giorgio Gonnella's blog
# http://looks-interesting.blogspot.com/2009/07/simple-implementation-of-suffix-array.html
# added substring and binary search
class SuffixArray
attr_reader :suf, :string
def initialize(string)
@string = string
@bluetwin
bluetwin / dijkstra.rb
Last active December 10, 2015 19:28 — forked from yaraki/dijkstra.rb
Updated Graph with dijkstra's algorithm. Refactored from AdjacentList to Matrix. Used pqueue(https://github.com/rubyworks/pqueue) for shortest distance
#!/usr/bin/ruby
require 'pqueue'
class Graph
attr_reader :edges
INFINITY = 1 << 32
def initialize(size)
@edges = Array.new(size) {Array.new(size)}
end
@bluetwin
bluetwin / BinaryTree.rb
Last active December 10, 2015 18:08 — forked from anonymous/BinaryTree.rb
Basic BinaryTree class
#!/usr/bin/ruby
class BinaryTree
include Enumerable
attr_accessor :key, :data, :left, :right
def initialize(h) # assume h is form {:key => k, :data=>d}
@key = @data = nil
assign_key_data(h)
@left = @right = nil