I have the sneaking suspicion that some time the next 30 days I am going to build a freebsd gateway/router/NAT/dhcp box.
Table of Contents
I am really tired of this bullshit
the soho router/gateway/dhcp boxes most people have in their homes are crap. all they do is cause problems. And I have to deal with this shit. At home, at work, and other people’s homes. Ugh. I hate it. D-Link, Belkin, Linksys, etc. Burn in fire.
I am undone
A blackard, A villain.
Clojure multi-method
sort of pattern matchie
(defmulti fib identity) (defmethod fib 0 [x] 0) (defmethod fib 1 [x] 1) (defmethod fib :default [n] (+ (fib (- n 2)) (fib (- n 1))))
Form at line n
overly simple form parser
(defn form-reader [charsource] (loop [[c & r] (seq charsource) open-parens-count 0 out []] (cond (= \( c) (recur r (inc open-parens-count) (conj out c)) (= \) c) (recur r (dec open-parens-count) (conj out c)) (and (not= 0 (count out)) (= open-parens-count 0)) (apply str out) :else (recur r open-parens-count (conj out c))))) (defn form-at-n [n file] (let [pho (fn pho [file action] (try (let [chunk (action file)] (if chunk (lazy-cons chunk (pho file action)) (do (.close file) nil))) (catch java.io.IOException e nil))) rducer (fn [x y] (if (not (string? x)) (if (= n (.getLineNumber x)) (let [s (form-reader (pho x #(char (.read %))))] (.close x) s) x) x))] (reduce rducer (let [f (-> file java.io.File. java.io.FileReader. java.io.LineNumberReader.)] (cons f (pho f #(.readLine %)))))))
user=> (println (form-at-n 138 "code/math.clj")) (defn d "divisor function, totally useless" [n] (* 2 (apply + (map #(if (math/whole-number? (/ n %)) 1 0) (range 1 (inc (floor (sqrt n)))))))) nil user=>