start new:
tmux
start new with session name:
tmux new -s myname
| ;;; block caller until any one of the passed functions complets and return its result | |
| (defn wait-any [& fns] | |
| (let [p (promise)] | |
| (doseq [f fns] (future (deliver p (f)))) | |
| (deref p))) | |
| ;;; (wait-any #(do (Thread/sleep 4000) 1) #(do (Thread/sleep 2000) 2) #(do (Thread/sleep 3000) 3)) | |
| ;;; output: 2 |
| //"safe" version: | |
| function listFruits(fs) { | |
| var fruits = [].concat(fs); | |
| fruits.sort(); | |
| for(var i in fruits) { | |
| console.log(fruits[i]); | |
| } | |
| } |
| (defn listFruits [fruits] | |
| (doall (map println (sort fruits)))) | |
| (def fruits ["Banana", "Orange", "Apple", "Mango"]) | |
| (listFruits fruits) ;prints Apple Banana Mango Orange each on their own line | |
| (println fruits) ;["Banana" "Orange" "Apple" "Mango"] yay!! |
| function listFruits(fs) { | |
| fs.sort(); | |
| for(var i in fs) { | |
| console.log(fs[i]); | |
| } | |
| } | |
| var fruits = ["Banana", "Orange", "Apple", "Mango"]; | |
| listFruits(fruits); //prints Apple Banana Mango Orange each on their own line | |
| console.log(fruits); //["Apple", "Banana", "Mango", "Orange"] ouch!! |
| #!/bin/bash | |
| case "$1" in | |
| on) | |
| /usr/bin/xset -display :0.0 dpms force on | |
| /usr/bin/xset -display :0.0 -dpms | |
| /usr/bin/xset -display :0.0 s off | |
| /usr/bin/xset -display :0.0 s reset | |
| ;; | |
| off) |
| #!/bin/bash | |
| find_command="find . -mindepth 0 -maxdepth 1 -type d -print" | |
| git_command="git $*" | |
| for i in $($find_command | sort) | |
| do | |
| [ -d $i/.git ] && echo ${i:2}: $(cd $i; $git_command 2> /dev/null) | |
| done |
| #!/bin/bash | |
| # warning you need to build in something to stop the loop | |
| # in practice, I used a kill file check before invoking the script again | |
| echo 'tail recursive bash ftw' | |
| sleep 10 | |
| $0 & | |
| # if you didn't listen and ran this as-is, try: | |
| # killall tail.sh |
| (use '[clojure.string :only (join)]) | |
| (use '[clojure.data.json :only (read-json)]) | |
| (defmacro google [& terms] | |
| `(map :url | |
| (get-in (read-json (slurp (str "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" | |
| ~(join \+ (map str terms))))) [:responseData :results]))) | |
| (google learning clojure) | |
| (google learning clojure eclipse) |
| ;;; print out the stack at the point of invocation of the macro (and continue execution) | |
| ;;; | |
| (defmacro print-stack [] | |
| `(doseq [s# (.getStackTrace (Thread/currentThread))] | |
| (println s#))) |