This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Multimethod | |
attr_accessor :dispatch, :methods, :heirarchy, :default_method | |
class NoMatchingMethodError < StandardError | |
end | |
def initialize(&dispatch) | |
@dispatch = dispatch | |
@methods = [] | |
@heirarchy = {} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |