Skip to content

Instantly share code, notes, and snippets.

Mac Network Commands Cheat Sheet
After writing up the presentation for MacSysAdmin in Sweden, I decided to go ahead and throw these into a quick cheat sheet for anyone who’d like to have them all in one place. Good luck out there, and stay salty.
Get an ip address for en0:
ipconfig getifaddr en0
Same thing, but setting and echoing a variable:
@ilazarte
ilazarte / .gitignore
Created March 9, 2016 07:36
This is a comprehensive .gitignore for AndroidStudio 1.5, since the default .gitignore generated causes all sorts of headaches when sharing across .git. Basically, it treats the project as a pure gradle project as opposed to Android Studio one. Credit goes to authors in links.
# https://code.google.com/p/android/issues/detail?id=156708
# http://stackoverflow.com/questions/16736856/what-should-be-in-my-gitignore-for-an-android-studio-project
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
(defn partition-every
"adapted from clojure core version of partition-by
partition a collection every time a predicate returns true
=> (partition-every keyword? [:a 1 2 3 :b :c 4 5 6 7 :d :e])
((:a 1 2 3) (:b) (:c 4 5 6 7) (:d) (:e))"
[pred coll]
(lazy-seq
(when-let [s (seq coll)]
(let [fst (first s)
run (cons fst (take-while (complement pred) (next s)))]
/**
* Cycle detection function
* Outputs count and grouped cycles with a from key path and to key path.
* The executing browser should have console.group and .groupEnd functions.
*
* Based on:
* http://stackoverflow.com/questions/14962018/detecting-and-fixing-circular-references-in-javascript/14962496#14962496
*
* @param {Object} obj Any js object
* @return {void}
@ilazarte
ilazarte / let-map.clj
Last active December 22, 2015 21:19
Combining the let and map form in a macro. Declare as many bindings as you want, and it will map across them using the symbols. Came to me when I needed something like a "foreach" for templating in Hiccup, but usable in a general context as well. Obviously the macro doesn't generate too much different, but I think its easier on the eyes.
;=> (let-map [i (range 5)] (inc i))
;(1 2 3 4 5)
;=> (def books '({:name "The Great Gatsby" :href "urlA"}
; {:name "The Unbearable Lightness of Being" :href "urlB"}))
;=> (let-map [b books] [:li [:a {:href (:href b)} (:name b)]])
;([:li [:a {:href "urlA"} "The Great Gatsby"]] [:li [:a {:href "urlB"} "The Unbearable Lightness of Being"]])
(defmacro let-map
[decl form]
"Usage: (let-map [i (range 5)] (inc i))"