Last active
March 19, 2017 13:59
-
-
Save ernestas/c5919d41fbaae50d63f991906d1a4adc to your computer and use it in GitHub Desktop.
Download InfoQ Slides
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 infoq-slides.core) | |
(def url-template "https://cdn.infoq.com/statics_s1_20170314-0434/resource/presentations/Deconstructing-Database/en/slides/sl%s.jpg") | |
(def last-slide 46) | |
(def file-template "/home/ernestas/Downloads/rich-hickey/2013-02-deconstructingthedb/sl%s.jpg") | |
(defn uri [index] | |
(java.net.URI. (format url-template index))) | |
(defn file [index] | |
(java.io.File. (format file-template index))) | |
(defn copy-uri-to-file [uri file] | |
(try (with-open [in (clojure.java.io/input-stream uri) | |
out (clojure.java.io/output-stream file)] | |
(clojure.java.io/copy in out)) | |
(catch Exception e (str "caught exception: " (.getMessage e))))) | |
(def indexes (range 1 (inc last-slide))) | |
(defn prefix-int [i] | |
(cond (<= i 9) (str "00" i) | |
(<= i 99) (str "0" i) | |
:else (str i))) | |
(defn get-slides [] | |
(for [i indexes] | |
(copy-uri-to-file (uri i) | |
(file (prefix-int i))))) | |
;; (get-slides) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment