Skip to content

Instantly share code, notes, and snippets.

Bill Caputo logosity

Block or report user

Report or block logosity

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:


start new with session name:

tmux new -s myname
logosity / wait-any.clj
Created Aug 9, 2013
Block a caller on any number of long-running/non-terminating functions continuing when any one of them returns (the others will run to completion, or presumably get cleaned up by the calling context):
View wait-any.clj
;;; 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
View immutability_and_safety_2.js
//"safe" version:
function listFruits(fs) {
var fruits = [].concat(fs);
for(var i in fruits) {
View immutability_and_safety.clj
(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!!
View immutability_and_safety.js
function listFruits(fs) {
for(var i in fs) {
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!!
logosity /
Created Jan 15, 2013
toggle screen saver on and off on an xwindows-using linux machine (tested only on Ubuntu)
case "$1" in
/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
logosity /
Created Jan 15, 2013
Run git commands in all sub directories of current directory.
find_command="find . -mindepth 0 -maxdepth 1 -type d -print"
git_command="git $*"
for i in $($find_command | sort)
[ -d $i/.git ] && echo ${i:2}: $(cd $i; $git_command 2> /dev/null)
logosity /
Created May 9, 2012
Tail Recursion in 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
logosity / learn_clojure.clj
Created Apr 27, 2012
Get this code running and you'll have everything you need...
View learn_clojure.clj
(use '[clojure.string :only (join)])
(use '[ :only (read-json)])
(defmacro google [& terms]
`(map :url
(get-in (read-json (slurp (str ""
~(join \+ (map str terms))))) [:responseData :results])))
(google learning clojure)
(google learning clojure eclipse)
logosity / print-stack.clj
Created Mar 22, 2012
print out current stack in clojure
View print-stack.clj
;;; 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#)))
You can’t perform that action at this time.