Skip to content

Instantly share code, notes, and snippets.


Joe Sak joemsak

View GitHub Profile
joemsak / rails.rb
Last active Apr 20, 2021
Dockerized Rails 6.1 Template
View rails.rb
gem 'sidekiq'
gem 'redis'
gem 'email_validator', require: 'email_validator/strict'
gem 'bcrypt'
gem 'friendly_id'
gem "tailwindcss-rails"
gem_group :development, :test do
gem 'pry-rails'
View convert_duration_to_seconds.rb
require 'test/unit'
# implementation
class Duration
def in_seconds(raw_duration)
match = raw_duration.match(/PT(?:([0-9]*)H)*(?:([0-9]*)M)*(?:([0-9.]*)S)*/)
hours = match[1].to_i
minutes = match[2].to_i
seconds = match[3].to_f
seconds + (60 * minutes) + (60 * 60 * hours)
joemsak / profiles_controller.rb
Created Aug 17, 2020
View profiles_controller.rb
def update
# TODO: explore why location details errors appear order-dependent
# and unable to run in the error path
if setting_location_without_location_details?
elsif ProfileUpdating.execute(profile, permitted_params)
View iteraptor.rb
query = "course"
original = {
"browse_courses"=>"Browse Courses",
joemsak / .gitignore
Created Feb 15, 2020
.gitignore for merge conflict backups
joemsak / .gitconfig
Created Feb 15, 2020
.gitconfig for rerere (Reuse Recorded Resolution)
View .gitconfig
enabled = true
joemsak / .gitconfig
Created Feb 15, 2020
.gitconfig for setting up pull with rebase
View .gitconfig
autosetuprebase = always
joemsak / .gitconfig
Last active Feb 15, 2020
.gitconfig for setting VS code as the merge conflict editor
View .gitconfig
tool = vscode
[mergetool "vscode"]
cmd = code --wait $MERGED
keepBackup = false
View app\controllers\application_controller.rb
class ApplicationController < ActionController::Base
rescue_from ActiveRecord::RecordNotFound, with: -> {
redirect_to root_path, alert: "We couldn't find that list or item on your account"
def current_user
@current_user ||= User.find_by!(auth_token: session[:user_auth_token])
# I am assuming that the details of storing