Skip to content

Instantly share code, notes, and snippets.

require 'fileutils'
require 'date'
require 'yaml'
require 'rexml/document'
include REXML
doc = Document.new File.new(ARGV[0])
FileUtils.mkdir_p "_posts"
def binsearch(ar, v, s=0, e=ar.length)
#if we have an empty slice, return nil
return nil if s >= e
#if we have a slice with one element, return index if it's the value else nil
return ar[s] == v ? s : nil if e-s == 1
#get pivot as average of start and end
pivot = (e+s) / 2