View this code at http://livecoding.io/7475492
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
fruits=(apple orange kiwi "dried mango") | |
for fruit in "${fruits[@]}"; do | |
echo "${fruit}" | |
done |
[ Launch: First Test ] 4599269 by tce
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
;; from http://twitch.nervestaple.com/2012/01/12/clojure-hbase/?utm_source=NoSQL%20Weekly%20Newsletter | |
(defn tool-run | |
"Provides the main function needed to bootstrap the Hadoop application." | |
[^Tool this args-in] | |
;; define our command line flags and parse out the provided | |
;; arguments | |
(let [[options args banner] | |
(cli args-in | |
["-h" "--help" |
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
;; from http://twoguysarguing.wordpress.com/2010/07/26/7-rules-for-writing-clojure-programs/ | |
(reduce #(assoc %1 %2 (inc (get %1 %2 0))) {} “aabcdcdcd”) | |
=> {\d 3, \c 3, \b 1, \a 2} |
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
;; allows you to say (hello jenny) instead of (hello "jenny") | |
(defmacro hello [s] `(println "Hello" ~(name 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
# rename from *.JPG to *.jpg | |
for x in *.JPG; do mv "$x" "${x/.JPG}".jpg; done | |
rename 's/\.JPG/\.jpg/' *.JPG | |
#strip spaces | |
rename 's/ //' *.JPG | |
# upper to lower case | |
rename 'y/A-Z/a-z/' *.JPG |
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
(comment "wildcardfilter from http://corfield.org/blog/post.cfm/real-world-clojure-powermta-log-files") | |
(defn- wildcard-filter | |
"Given a regex, return a FilenameFilter that matches." | |
[re] | |
(reify java.io.FilenameFilter | |
(accept [_ dir name] (not (nil? (re-find re name)))))) | |
(defn- nonhidden-filter | |
"return a FilenameFilter that ignores files that begin with dot or end with ~." |