Skip to content

Instantly share code, notes, and snippets.

View radavis's full-sized avatar

Richard Davis radavis

View GitHub Profile

Logs

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 ...

Middleware

  • HTTP Request/Response Cycle
  • MVC

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

Rack::Middleware

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

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.

https://username:GITHUB_ACCESS_TOKEN@github.com/username/repo.git

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.

source

ActiveSupport::Concern

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.

module TimeHelper
def now
Time.new.to_i
end
def time_ago(seconds, now = Time.now.to_i)
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|

Clone a folder from a repo

Create an access token

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

https://username:GITHUB_ACCESS_TOKEN@github.com/username/repo.git