I hereby claim:
- I am gvaughn on github.
- I am gvaughn (https://keybase.io/gvaughn) on keybase.
- I have a public key whose fingerprint is C533 8C70 3D72 1F62 AA4C 904F 3580 16C3 FDA7 0311
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
Greg Vaughn posted this cool alias the other day:
copr = "!f() { git fetch -fu origin refs/pull/$1/head:pr-$1; git checkout pr-$1; } ; f"
Preferring to be a stock-tools person, I wanted to deconstruct this to see how I'd use it off-the-shelf without the alias.
git fetch -- I'm already familiar with this command
-fu -- these two flags I'm not sure are necessary, esp. -u since the help says,
"unless you are implementing your own Porcelain you are not supposed to use
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
I want to give a code demo that shows progression of the code. I thought it would be great if I could craft the series of commits on a branch and have a single vim keystroke that would checkout the next (or previous) commit and force my buffers to reload. That would allow me to show one commit, then give me the freedom to live code how the next step is done, but when I advance to the next commit I know I'll have working code. It's like a safety harness for live coding.
#Mars Rover Kata | |
#Develop an api that moves a rover around on a grid. | |
#You are given the initial starting point (x,y) of a rover and the direction (N,S,E,W) it is facing. | |
#The rover receives a character array of commands. | |
#Implement commands that move the rover forward/backward (f,b). | |
#Implement commands that turn the rover left/right (l,r). | |
# | |
#Implement wrapping from one edge of the grid to another. (planets are spheres after all) | |
#Implement obstacle detection before each move to a new square. If a given sequence of commands encounters an obstacle, the rover moves up to the last possible point and reports the obstacle. |
def evolve(generation) | |
live_neighbor_stats = generation_stats(generation) | |
live_neighbor_stats[3] + (live_neighbor_stats[2] & generation) | |
end | |
def generation_stats(live_cells) | |
live_cells.each_with_object(Hash.new(0)) {|live_cell, counter| | |
neighbors(*live_cell).each {|neighbor| counter[neighbor] += 1 } | |
}.each_with_object(Hash.new {|h,k| h[k] = []}) {|(cell, count), collector| collector[count] << cell} | |
end |