Skip to content

Instantly share code, notes, and snippets.

View stratigos's full-sized avatar
🧑‍🔬
Building the Internet

Todd stratigos

🧑‍🔬
Building the Internet
View GitHub Profile
@stratigos
stratigos / 2019-10-08_remote-video_wuts-gud.md
Last active November 22, 2019 18:34
Video Conferencing Tool Exploration

Explore Video Conferencing Tools

Why

☝ In the spirit of continuous improvement, I would like to explore video conferencing tools to use at work with clients, to see if there are other options available that provide a more smooth, clear, and reliable experience.

@stratigos
stratigos / 2019-07-19_elm-language-guide.md
Last active September 14, 2019 00:37
Elm Lang Guide

Elm Language Guide

  • 📆 2019-07-19
  • this spans many weeks / investment times
  • 📖 🌳️🕵‍♀️️ The Elm Language Guide
  • 👨‍💻📝️ an experienced OOP programmer learning FP and Elm

Installing Elm

Compared to my experiences using JavaScript over many years, I found installing

@stratigos
stratigos / 2019-04-19_functional-structures-scala.md
Last active July 12, 2019 23:29
Notes on "FSiS Part 1 - Type Constructors, Functors, and Kind Projector"

Functional Structures in Scala

  • 📆 2019-04-19
  • this spans many weeks / investment times
  • 📹 Screencast: Functional Structures
  • 👨‍💻📝️ an experienced OOP programmer learning FP and Scala
    • and maybe category theory? 🤔

On Kindedness

@stratigos
stratigos / clear_swap.sh
Created November 11, 2018 22:34
Clear Swap Space on Ubuntu Linux (14.04)
function clearswap { sudo swapoff -a && sudo swapon -a; }
@stratigos
stratigos / rspec_helper_token_auth_sign_in.rb
Last active August 28, 2020 17:23
RSpec Helper for Token-based Authentication Sign-In
# Helpers to assist with the `devise_token_auth` security features, such as
# generation of new authentication tokens for each request.
# @see [devise_token_auth Github issue](https://github.com/lynndylanhurley/devise_token_auth/issues/75)
module RequestSpecHelper::ApiAuthHelper
module Extensions
# Helper method for authenticating a User for each Request type spec.
# Use `devise_token_auth` callback to generate an authentication token
# for each request.
# Call this on a created User at the beginning of a `describe` or `context`
@stratigos
stratigos / respec_helper_bearer_token_session_headers.rb
Last active April 19, 2018 17:19
RSpec Helper for Validating Token-based Auth Headers Returned with Request
module RequestSpecHelper::SessionsHelper
# Set single expectation that checks auth headers were returned.
def expect_auth_headers(response)
expect(response.headers.keys).to include('access-token', 'client', 'expiry', 'uid')
end
end
########################################################################
@stratigos
stratigos / rspec_shared_example_defined_constants.rb
Created April 19, 2018 16:56
RSpec Shared Example Matcher for Class Constant Definition
# Shared specs for models with frozen CONST values. Expects two String values
# as parameters.
RSpec.shared_examples :has_const_model do |const_name, const_value|
it { expect(described_class).to be_const_defined(const_name.to_sym) }
it { expect("#{described_class}::#{const_name}".constantize).to be_frozen }
it { expect("#{described_class}::#{const_name}".constantize).to eq(const_value) }
end
@stratigos
stratigos / rspec_validates_numericality_with_shoulda_matchers.rb
Created April 19, 2018 16:54
RSpec Validates Numericality of Active Record Model with Shoulda Matchers
# Shared specs for models with the `:validates_numericality_of` validators.
# Usage: pass a hash of each of the symbolized names of each options for the
# numericality validator. If the option has a value with which to evaluate
# against, add it as the value of that option hash name.
# E.g.:
# `it_behaves_like :validates_numericality_model, :numeric_attr, { greater_than_or_equal_to: 0, only_integer: true }`
RSpec.shared_examples :validates_numericality_model do |attribute_name, options|
it { is_expected.to validate_numericality_of(attribute_name) }
@stratigos
stratigos / rspec_soft_delete_shared_example.rb
Created April 19, 2018 16:50
RSpec Matcher for ActsAsParanoid / Paranoia Active Record Model Specs
# Shared specs for models with the `acts_as_paranoid` features.
RSpec.shared_examples :soft_delete_model do
it { is_expected.to have_db_column(:deleted_at) }
it 'has a scope to select soft-deleted records' do
expect(described_class).to respond_to(:only_deleted)
end
it 'has a scope to select both not-deleted and soft-deleted records' do
@stratigos
stratigos / rspec_shared_example_with_shoulda_matchers_for_booleans.rb
Created April 19, 2018 16:46
RSpec Boolean Matcher Shared Example with Shoulda Matchers
# Shared specs for models with the `:validates_inclusion_of` validators, where
# Boolean values are specified. This is for use cases where Booleans are used
# in non-null DB columns, and validation errors need to be returned to actors
# attempting to store a NULL value (e.g., a IoT unit's firmware uploading a
# NULL value for an On/Off sensor reading).
# Additionally, `shoulda` will complain if `validate_inclusion_of` is used
# with the Booleans, and instead of turning off warnings, its best to just
# approach these specs differently. See
# [this github comment](https://github.com/thoughtbot/shoulda-matchers/issues/922#issuecomment-225752673)
# for more info.