Skip to content

Instantly share code, notes, and snippets.

Evan Prothro eprothro

View GitHub Profile
@eprothro
eprothro / communication via narrative.md
Last active Jun 9, 2020
Connextra, Gherkin, and Free-form prose for multidisciplinary communication via narrative.
View communication via narrative.md

Overview

Getting clients, managers, project managers, designers, and developers on the same page when it comes to feature expectations is hard. Everyone speaking the same language (literally) can go a long way to achieving the same, metaphorically.

There are three common formats that are great for written and verbal communication between stakeholders with different backgrounds, responsibilities, and risk exposures. They are each natural-language, narrative formats (they use plain english) that anyone can understand, but their structrued nature is proven to help clearly communicate behavior, specify intent and synchronize expectations.

Connextra user stories

  • Great for high level feature description
  • Typically bad for detailed behavior description
View rails paradigm.md

This is a work in progress.

Domain and Persistence Separation

Our primary motivation for this architecture is separating Domain and Persistence concepts.

  1. When Domain and Persistence logic are mixed together in ActiveRecord Models, the resulting code is hard to reason about, difficult to test well, and resists change.
  • AR Callbacks are a hellish way to manage domain logic
  • Managing different validation contexts is not straightforward
  • There is no clear Domain API (everything is a Model#save side effect)
View foreman development.md

bin/setup

#!/usr/bin/env ruby
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
View error rendering paradigm in rails.md

Use a glob route at the bottom of your scopes to catch invalid routes

# config/routes.rb
Rails.application.routes.draw do
  # ... all your scopes and routes
  match "(*any)", to: "application#render_not_found", via: :all
end
View https apex redirection rails heroku.md

Heroku DNS

For Heroku to receive traffic at the apex domain (your-tld.com) Your DNS provider must support ANAME / ALIAS resolution for a hostname (your-app-random-heroku-endpoint.herokudns.com) to the apex domain.

GoDaddy does not support this, you can only set up an A record to a static IP address for the apex.

They provide domain forwarding, but this does not work for HTTPS, so requests to https://your-tld.com will timeout. Their domain forwarding service will only work for forwarding from http://your-tld.com.

If you're using GoDaddy, it is recommended to transfer or switch name servers to a different service (e.g. Namecheap, DNSimple, etc).

@eprothro
eprothro / index.html.haml
Last active Dec 12, 2019
snippets from Materialize starter template from https://materializecss.com/getting-started.html
View index.html.haml
!!!
%html{lang: "en"}
%head
%meta{content: "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
%meta{content: "width=device-width, initial-scale=1, maximum-scale=1.0", name: "viewport"}/
%title Starter Template - Materialize
/ CSS
%link{href: "https://fonts.googleapis.com/icon?family=Material+Icons", rel: "stylesheet"}/
%link{href: "css/materialize.css", media: "screen,projection", rel: "stylesheet", type: "text/css"}/
%link{href: "css/style.css", media: "screen,projection", rel: "stylesheet", type: "text/css"}/
@eprothro
eprothro / shards.yml
Created Apr 12, 2013
Dynamic Octopus configuration for master/slave horizontal DB scaling with a Rails application on the Heroku stack. See the wiki page for more info: https://github.com/tchandy/octopus/wiki/Replication-with-Rails-on-Heroku. Props to Heroku for the idea, gleaned from the dynamic database.yml they inject at build-time for rails apps.
View shards.yml
<%
require 'cgi'
require 'uri'
def attribute(name, value, force_string = false)
if value
value_string =
if force_string
'"' + value + '"'
else
View Testing Modules with Rspec.md

It can be difficult to test the different scenarious for a module intended for use by including in another class.

If the class is statically defined in the spec, any later definitions extend, not replace, the first definition - which can cause test issues and breaks isolation between examples.

RSpec.describe SomeModule do
  class SomeIncluder
    include SomeModule
  end
  
View Sublime Text go to spec or test.md
View sidekiq_depth_printer.rb
# Sidekiq Reporter
#
# Emit key statistics about Sidekiq queues to a stream.
#
# Examples:
#
# Log to STDOUT by default:
#
# ruby sidekiq_reporter.rb
#
You can’t perform that action at this time.