Skip to content

Instantly share code, notes, and snippets.

Richard Davis radavis

Block or report user

Report or block radavis

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
View gist:f5118eebd67b3cb2e664be2b9ac97303
git diff --name-only --cached | grep -q package-lock.json
git diff --name-only --cached | grep -q package.json
if [[ "$pkglock_staged" -eq 0 && "$pkgjson_staged" -eq 1 ]]; then
echo "attempted commit of package-lock.json without changes to package.json!"


Log levels

From 0 to 5 in severity:

  • debug - for debugging purposes, only
  • info - an informative message
  • warn - this may or may not be an issue
  • error - this is an issue, but the application can continue running

The Path from Idea to Software

User Story -> Acceptance Criteria -> Feature Test

Generic User Story

As a ...
I want ...
So that ...


  • HTTP Request/Response Cycle
  • MVC

How does the application know how to map HTTP requests to Controller actions?


Rails routes are a middleware that map the HTTP Verb and Path (within a HTTP request) to a Controller action.

View objectives-and-key-results-(okr).md

Objectives and Key Results (OKRs)

OKRs should be directly linked to the company's strategy.

Key Results are (a) outcome based, or (b) output based.

Answers the question: "How, as a group, will we consider our company successful?"

OKRs for software engineers


Linux Environment Variables

Bash reads different configuration files depending on how the shell session is started.

Shell Sessions

  • login: A user was authenticated (via user/password).
  • non-login: A new shell session was created within an authenticated session. A user was not authenticated.
  • interactive: A shell session attached to a terminal session (foreground).
  • non-interactive: A shell session not attached to a terminal session (background).

Clone a folder from a GitHub repo

Create an access token

Providing an access token allows you to avoid a user/password authentication prompt.

Aggregate Tables

Aggregate tables, in general, are simply database tables that contain aggregated values.

An aggregate fact table is simply one that combines multiple rows of data, loses some detail and aggregates numerical values.




Instead of defining an included method to handle extending a class, we can extend ActiveSupport::Concern.

It is actually a pretty simple but powerful concept. It has to do with code reuse as in the example below. Basically, the idea is to extract common and/or context specific chunks of code in order to clean up the models and avoid them getting too fat and messy.

View time_helper.rb
module TimeHelper
def now
def time_ago(seconds, now =
minutes = (now - seconds) / 60
quantity = [minutes / 525600, minutes / 43200, minutes / 1440, minutes / 60, minutes]
%w(year month day hour minute).each_with_index do |type, i|
You can’t perform that action at this time.