Skip to content

Instantly share code, notes, and snippets.

Kevin Rockwood rockwood

Block or report user

Report or block rockwood

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
rockwood / archive_post_scenario.ex
Last active Nov 27, 2018
Ecto Soft-Delete Pattern
View archive_post_scenario.ex
defmodule MyApp.ArchivePostScenario do
alias MyApp.Repo
alias Ecto.Multi
alias __MODULE__.Query
def run(options) do
post = Keyword.fetch!(options, :post)
comments: Query.comments(post),
rockwood / split_csv.bash
Last active Jun 29, 2018
Split CSV Files
View split_csv.bash
#!/usr/bin/env bash
mkdir -p ./output
head -1 $input_file > $header_file
tail -n +2 $input_file > $rows_file
rockwood / rps.ex
Created Jan 17, 2018
Rock Paper Scissors
View rps.ex
defmodule Rps do
def run(input) do
player1 = String.split(input, "")
player2 = Enum.shuffle(["r", "p", "s"])
result =
[player1, player2]
|> Enum.sum()
|> case do

Ranger Keybindings

Search for a File / Directory

Key Binding Description
f search for file / directory

Copy, Rename/Move or Delete

rockwood /
Last active May 4, 2018
Seoul Elixir Meetup

1. Install Phoenix 1.3

mix archive.install

2. Create a new Phoenix project

mix demo

3. Create the database

rockwood /
Created Apr 14, 2016
BEM Conventions


Avoid page specific stylesheets

It's easy to organize styles by page when the app is small, but a year from now we'll probably have 50+ pages and having a separate stylesheet for each page will result in tons of duplication.

Use the grid as much as possible

The grid has a ton of feature and it's really customizable from variables.scss. Anywhere you're doing multi-column layouts, try to use the grid.

View gist:5c5a2e31ddf3941422f0
class TestServer
def initialize(options)
@server_port = options.fetch(:server_port)
@client_port = options.fetch(:client_port)
def start
@pid = spawn(command)
View gist:ea59c05b2378f5e73bb9
# Taken from
# usage:
# it "should return a result of 5" do
# eventually { long_running_thing.result.should eq(5) }
# end
module AsyncHelpers
def eventually(options = {})
timeout = options[:timeout] || 2
rockwood / data
Last active Aug 29, 2015
Heroku new pg:backups data script
View data
set -x
set -e
dropdb ${DATABASE}
rockwood /
Last active Aug 29, 2015
angular.module("rails").factory "RailsResourceCollection", (_) ->
class RailsResourceCollection
constructor: (models=[]) ->
@models = models
angular.module("rails").factory "RailsResourceCollectionMixin", (RailsResourceCollection) ->
RailsResourceCollectionMixin = ->
RailsResourceCollectionMixin.extended = (Resource) ->
Resource.intercept "afterResponse", (result, resource, context) ->
You can’t perform that action at this time.