Skip to content

Instantly share code, notes, and snippets.

View frank-who's full-sized avatar
👌
¯\_(ツ)_/¯

frank._who? frank-who

👌
¯\_(ツ)_/¯
View GitHub Profile
@frank-who
frank-who / simple_authentication_rails_5_bcrypt_and_has_secure_password.md
Created November 14, 2024 10:54 — forked from iscott/simple_authentication_rails_5_bcrypt_and_has_secure_password.md
Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

Cheat Sheet: Simple Authentication in Rails 6 with has_secure_password

The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.

First the simplest/core layers, then optional layers depending on which features/functionality you want.

Specs
AUTHOR Ira Herman
LANGUAGE/STACK Ruby on Rails Version 4, 5, or 6
@frank-who
frank-who / snippet.rb
Created January 6, 2021 14:57 — forked from timm-oh/snippet.rb
Ozow integration
# refer to https://ozow.com/integrations/ for more information
# Ordering with the params matters, see the link above for more information
ozow_params = {
'SiteCode': 'SOME_SITE_CODE', # find this here https://dash.ozow.com/MerchantAdmin/Site
'CountryCode': 'ZA', # only supports ZA currently
'CurrencyCode': 'ZAR', # only supports ZAR currently
'Amount': 1000.00, # this is R1000.00
'TransactionReference': 'SOME_TEST', # your internal reference to match against
'BankReference': "Nice Reference", # the reference that the customer will see on their bank statement
@frank-who
frank-who / 01_readme.md
Last active June 15, 2020 06:52
Sass baseline mixin

Usage

  h1,
  h2,
  h3,
  h4,
  h5,
  h6
 color: $c-txtPrimary
@frank-who
frank-who / application_helper.rb
Last active March 19, 2021 11:35
Stimulus slim view helpers
# app/helpers/application_helper.rb
module ApplicationHelper
include StimulusHelper::HelperMethods
end
@frank-who
frank-who / .travis.yml
Created August 19, 2018 19:33
Postgres 10 on Travis
env:
global:
- PGPORT=5433
language: ruby
rvm:
- 2.5.1
cache:
@frank-who
frank-who / USAGE.md
Created July 19, 2018 09:44
Basic Sidekiq config

Starting Sidekiq

bundle exec sidekiq -C config/sidekiq.yml

Perform Job Immediately

TestJob.perform_now(user_id: current_user.id)
@frank-who
frank-who / control_indicator_helper.rb
Last active July 18, 2018 00:01
SimpleForm Initializer for Foundation 6 with additional markup to allow styling of checkboxes, radio buttons and file controls
# lib/components/control_indicator_helper.rb
module ControlIndicatorComponent
def select_arrow(wrapper_options=nil)
@arrow_icon ||= begin
if options[:arrow_icon].nil? || options[:arrow_icon].to_s == 'default'
''
else
options[:arrow_icon].to_s.html_safe
end
@frank-who
frank-who / gist:af1e3c3dba1627451abc8552a5e99baf
Last active June 25, 2018 13:13
Ruby random South African ID number generator
def id_number(birthday, gender)
gender = (0..4).to_a.sample if gender == 'female'
gender = (5..9).to_a.sample if gender == 'male'
random_sequence = rand.to_s[2..5]
citizenship = 0
race = 8
id_number = [
birthday.gsub('-', '')[2..-1],
gender,
@frank-who
frank-who / 1-README.md
Last active August 1, 2017 10:12
Heroku Reporting Dynos

Setup

  • Add a new worker to your Procfile. In this gist I used reporter
  • Add the Heroku Platform gem to your Gemfile
  • Create the HerokuReporterDyno module in lib or any other auto-loadable path
  • Create two jobs. A caller (Reporting::GeneratorJob) and a runner (Reporting::RunnerJob)
  • Deploy
  • Once deployed, log into Heroku and change the newly added reporter dyno to a Performance M or Performance M dyno

How this all works

@function hsb($hue, $saturation, $brightness, $alpha: 1, $hsl-saturation: '') {
@if $brightness == 0 {
@return hsla(0, 0, 0, $alpha);
} @else {
$hsl-lightness: (2 - $saturation / 100) * ($brightness / 2);
$hsl-saturation: ($brightness * $saturation) / if($hsl-lightness < 50, $hsl-lightness * 2, 200 - $hsl-lightness * 2);
@return hsla($hue, $hsl-saturation, $hsl-lightness, $alpha);
}
}