View recursive_block.rb
def foo(n, &block)
if n > 0
yield(n)
foo(n - 1, &block)
end
end
View selection.rb
def selection_sort(array, start_idx=0)
smallest_value, swap_idx = nil, nil
for idx in start_idx..(array.size - 1)
val = array[idx]
if smallest_value.nil? || smallest_value > val
smallest_value = val
swap_idx = idx
end
end
View bubble.rb
def bubble_sort(array)
@swap_needed = false
array.each_with_index do |val, idx|
a = val
b = array[idx + 1]
if !b.nil? && a > b
@swap_needed = true
array[idx] = b
array[idx + 1] = a
View git-index.sh
$ git init .
Initialized empty Git repository in /Users/swittnekamp/tmp/git_index/.git/
$ cat <<EOF > foo.txt
Some example content
EOF
$ git add foo.txt
$ git status
View osx-10.11-setup.md

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

View extract_values.rb
class Hash
def extract_nested_values(hsh=self)
return hsh unless hsh.respond_to?(:keys)
hsh.keys.map do |k|
extract_nested_values(hsh[k])
end.flatten
end
end
View destructuring.rb
#
# ruby splat destructuring
#
class Bar
def qux
42
end
end
View hipchat.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; use jabber-connect to connect. Make sure you tab to select the hipchat account if it's the ;;
;; only connection configured. ;;
;; ;;
;; a fork of https://gist.github.com/puffnfresh/4002033 ;;
;; ;;
;; shout out to http://emacs.stackexchange.com/questions/10940/connecting-to-hipchat-xmpp-via-jabber-el ;;
;; for the help. ;;
;; ;;
;; you can look up the necessary jabber info on the account i
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
View find_it.sh
#!/bin/bash
grep -r -E '[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}' *