Skip to content

Instantly share code, notes, and snippets.

View gvaughn's full-sized avatar
:atom:
Never trust an atom. They make up everything.

Greg Vaughn gvaughn

:atom:
Never trust an atom. They make up everything.
View GitHub Profile
@gvaughn
gvaughn / keybase.md
Created April 13, 2015 16:27
keybase.io identity

Keybase proof

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:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gvaughn
gvaughn / copr.md
Created July 18, 2014 16:15 — forked from chrismo/copr.md

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 
@gvaughn
gvaughn / gist:33d8a61d5cea03691732
Last active August 29, 2015 14:03 — forked from jimbojsb/gist:1630790
source highlighting in presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@gvaughn
gvaughn / VimAndGitCodeDemos.md
Last active August 29, 2015 14:03
Vim and Git in Code Demos

Vim and Git in Code Demos

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.

Here's how it's supposed to work:

  • I created a test_forward branch, and, yeah, it's hardcoded in the vimscript :-(
  • Then I created 3 consecutive commits with one line changes in my README
  • optional: I used "git tag $tag_name" to give a friendly name in my bash prompt for each commit (I wish the fugitive statusline would use it too though)
  • I checked out the 1st of the demo commits
@gvaughn
gvaughn / yamlpitfalls.md
Last active April 29, 2020 07:56
YAML pitfalls

Case 1: Missing Colon

.yml looks like:

  purchases_edit
    cannot_edit: "Purchase cannot be edited after submission"

We can test in irb:

@gvaughn
gvaughn / gist:1714728
Created February 1, 2012 02:36
Mars Rover Kata
#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.
@gvaughn
gvaughn / gist:1436816
Created December 6, 2011 04:57
Conway's Game of Life in functional ruby
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