Skip to content

Instantly share code, notes, and snippets.

View owainlewis's full-sized avatar

Owain Lewis owainlewis

View GitHub Profile
@owainlewis
owainlewis / deployer.rake
Created May 8, 2012 10:18 — forked from morgoth/deployer.rake
Rake task to copy local files to remote server via FTP
# Rake task to copy local files to remote server via FTP
# required credentials.yml file, that contains keys:
# server, username, password
require "net/ftp"
require "yaml"
class FTPClient
attr_reader :remote_path
@owainlewis
owainlewis / multimethod.rb
Created August 11, 2012 18:32 — forked from alandipert/multimethod.rb
Multimethods in Ruby
class Multimethod
attr_accessor :dispatch, :methods, :heirarchy, :default_method
class NoMatchingMethodError < StandardError
end
def initialize(&dispatch)
@dispatch = dispatch
@methods = []
@heirarchy = {}
end
@owainlewis
owainlewis / rbtree.lisp
Created October 9, 2012 15:49 — forked from Mozk0/rbtree.lisp
Red Black Tree for Common Lisp.
;; The following implementation of rb-tree is based on http://www.cs.kent.ac.uk/people/staff/smk/redblack/.
(defun change-to-black (tree)
(pattern-match tree
((:pattern (_ . rest) :variable rest :ignore _) `(:B . ,rest))
(:otherwise nil)))
(defun rb-insert (tree obj cmp)
(change-to-black (rb-insert% tree obj cmp)))
@owainlewis
owainlewis / bktree.hs
Created October 11, 2012 12:00 — forked from ehamberg/bktree.hs
Implementation of a BK-Tree in Haskell
import qualified Data.Map as M
import Control.Applicative
import Data.Maybe (mapMaybe)
-- A BK-Tree is has a root word and more trees connected to it with branches of
-- lengths equal to the Levenshtein distance between their root words (i.e. an
-- n-ary tree).
data BKTree s = BKTree s (M.Map Int (BKTree s)) | Empty deriving (Show)
-- Inserting a word is done by inserting it along a branch of lenght
@owainlewis
owainlewis / 0_reuse_code.js
Created January 1, 2014 14:38
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console