Skip to content

Instantly share code, notes, and snippets.

@rockwood
rockwood / split_csv.bash
Last active June 29, 2018 00:08
Split CSV Files
#!/usr/bin/env bash
input_file=$1
header_file=./output/headers.csv
rows_file=./output/rows.csv
mkdir -p ./output
head -1 $input_file > $header_file
tail -n +2 $input_file > $rows_file
@rockwood
rockwood / archive_post_scenario.ex
Last active November 27, 2018 07:24
Ecto Soft-Delete Pattern
defmodule MyApp.ArchivePostScenario do
alias MyApp.Repo
alias Ecto.Multi
alias __MODULE__.Query
def run(options) do
post = Keyword.fetch!(options, :post)
archive_and_delete([
comments: Query.comments(post),
@rockwood
rockwood / bem.md
Created April 14, 2016 19:43
BEM Conventions

Dos:

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.

@rockwood
rockwood / server.js
Created July 19, 2012 16:22
Node Static File Server
var http = require('http');
var fs = require('fs');
var path = require('path');
var PORT = 3000;
var INDEX = './index.html';
http.createServer(function (request, response) {
console.log('request starting...');