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
./elastic-mapreduce --create --stream \ | |
--input s3n://YOUR_BUCKET/PATH_TO_FILES/ \ | |
--mapper s3n://YOUR_BUCKET/utf8-cleanup.rb \ | |
--reducer s3n://YOUR_BUCKET/utf8-cleanup-reducer.rb \ | |
--output s3n://YOUR_BUCKET/PATH_TO_FILES_CLEANED \ | |
--bootstrap-action "s3n://YOUR_BUCKET/ruby193.sh" \ | |
--debug \ | |
--num-instances 20 |
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
(ns santa.core) | |
(declare join-group) | |
(defn start-thread | |
[fn] | |
(.start | |
(Thread. fn))) | |
(defn random-delay [] |
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
(def letters | |
(set "abcdefghijklmnopqrstuvwxyz")) | |
;; If you don't know clojure it might be interesting that sets are functions of their elements | |
;; and return either nil or the element, so can be used as predicates | |
(defn counts [s] | |
(frequencies (filter letters (str/lower-case s)))) | |
;; Here we filter the string for letters we care about (after lowercasing it) |
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
(def fibs | |
(map first (iterate (fn [[a b]] [b (+ a b)]) [1 1]))) | |
(defn fibs-from [n] | |
(drop-while #(< % n) fibs)) | |
(take 5 fibs) | |
; (1 1 2 3 5) | |
(take 5 (fibs-from 1000000000000)) |
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
fib = (n) -> | |
r = [1,1] | |
for i in [2...n] | |
r.push(r[i-1] + r[i-2]) | |
r | |
console.log fib(5) |
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
input { | |
tcp { | |
port => 5544 | |
type => syslog | |
} | |
udp { | |
port => 5544 | |
type => syslog | |
} | |
} |
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
(def __ | |
(fn [n] | |
(let [ | |
big-p (fn [n] | |
(let [sn (str n)] | |
(str sn | |
(clojure.string/reverse sn)))) | |
small-p (fn [n] | |
(let [sn (str n) |
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
;Levenshtein Distance - Hard | |
;Given two sequences x and y, calculate the <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Levenshtein_distance">Levenshtein distance</a> of x and y, i. e. the minimum number of edits needed to transform x into y. The allowed edits are:<br/><br/>- insert a single item<br/>- delete a single item<br/>- replace a single item with another item<br/><br/>WARNING: Some of the test cases may timeout if you write an inefficient solution! | |
;tags - seqs | |
;restricted - | |
(ns offline-4clojure.p101 | |
(:use clojure.test)) | |
(def __ | |
(fn [s t] | |
(let [m (count s) |
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
; Graph Connectivity - Hard | |
; Given a graph, determine whether the graph is connected. A connected graph is such that a path exists between any two given nodes.<br/><br/>-Your function must return true if the graph is connected and false otherwise.<br/><br/>-You will be given a set of tuples representing the edges of a graph. Each member of a tuple being a vertex/node in the graph.<br/><br/>-Each edge is undirected (can be traversed either direction). | |
; tags - graph-theory | |
; restricted - | |
(ns offline-4clojure.p91 | |
(:use clojure.test)) | |
(def __ | |
(fn [s] |
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
; Analyze a Tic-Tac-Toe Board - Hard | |
; A <a href="http://en.wikipedia.org/wiki/Tic-tac-toe">tic-tac-toe</a> | |
; board is represented by a two dimensional vector. | |
; X is represented by :x, O is represented by :o, and empty is represented by :e. | |
; A player wins by placing three Xs or three Os in a horizontal, vertical, or diagonal row. | |
; Write a function which analyzes a tic-tac-toe board and returns :x if X has won, :o if O has won, and nil if neither player has won. | |
; tags - game | |
; restricted - | |
(ns offline-4clojure.p73 | |
(:use clojure.test)) |