This file contains hidden or 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 slideshow.images | |
(:use [clojure.java.io :only [copy file input-stream output-stream]]) | |
(:import [java.io File FileReader FileWriter])) | |
(defn get-files [dir] | |
(let [data (filter #(.isFile #^File %) | |
(file-seq (java.io.File. dir)))] | |
(sort-by #(.lastModified %) < data))) | |
(defn get-images [dir] |
This file contains hidden or 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
(defn copy-imgs [dir] | |
(let [imgs (get-images dir)] | |
(for [img imgs] | |
(with-open [i (input-stream img) | |
o (output-stream (file (str | |
"static/copies/" | |
(.getName img))))] | |
(copy i o))))) |
This file contains hidden or 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
(defn test-copy [str-from str-to] | |
(let [from (file str-from) | |
to (file str-to) | |
in (java.io.FileReader. from) | |
out (java.io.FileWriter. to)] | |
(copy in out))) |
This file contains hidden or 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
;;problem 18 | |
(def triangle18-str "75 | |
95 64 | |
17 47 82 | |
18 35 87 10 | |
20 04 82 47 65 | |
19 01 23 75 03 34 | |
88 02 77 73 07 63 67 | |
99 65 04 28 06 16 70 92 | |
41 41 26 56 83 40 80 70 33 |
This file contains hidden or 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
(defn pow [x y] | |
(apply * (repeat y x))) |
This file contains hidden or 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
;;problem 14 | |
(defn do-to-odd [x] | |
(+ 1 (* 3 x))) | |
(defn do-to-even [x] | |
(/ x 2)) | |
(defn get-next [x] |
This file contains hidden or 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
(do | |
(use 'clojure.test) | |
(defn re-test [ns] | |
(remove-ns ns) | |
(require :reload-all ns) | |
(run-tests ns))) | |
;; pick a namespace | |
(re-test 'clojure.test-clojure.other-functions) |
This file contains hidden or 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
;;restart swank | |
(fset 'restart-swank | |
"\C-[xslime-disconna\C-?ect-all\C-m\C-[xswank-clojure-project\C-m\C-m") | |
(global-set-key "\C-cS" 'restart-swank) |
This file contains hidden or 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 attendance.core | |
(:use karras.core | |
karras.collection | |
karras.sugar | |
compojure.core | |
ring.adapter.jetty | |
hiccup.core) | |
(:require [compojure.route :as route])) | |
(defn home [] |
This file contains hidden or 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 student.learning | |
(:refer-clojure :exclude [get]) | |
(:use [clojure.contrib.str-utils :only [str-join]] | |
[clojure.contrib.math :only [sqrt lcm]] | |
[clojure.contrib.lazy-seqs :only [primes]])) | |
(defn babyize [s] "replace l and r with w if first letter of each word" | |
(let [b-word (fn [[first-letter & word]] | |
(let [new-first (cond (some #{first-letter} [\l \r]) \w | |
(some #{first-letter} [\L \R]) \W |