Skip to content

Instantly share code, notes, and snippets.

View joemsak's full-sized avatar

Joe Sak joemsak

View GitHub Profile
@joemsak
joemsak / Gemfile
Last active January 26, 2024 18:59
Learn SQL the Hard Way Ex 6 in Ruby
source "https://rubygems.org"
ruby "3.3.0"
gem "activemodel"
gem "activesupport"
gem "sqlite3"
gem "pry"
admin, foo, bar
@joemsak
joemsak / rails.rb
Last active April 20, 2021 15:07
Dockerized Rails 6.1 Template
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'
@joemsak
joemsak / convert_duration_to_seconds.rb
Created November 12, 2020 20:18 — forked from natritmeyer/convert_duration_to_seconds.rb
Ruby ISO 8601 duration converter
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
joemsak / profiles_controller.rb
Created August 17, 2020 17:38
app/controllers/concerns/profile_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?
handle_blank_location_error
elsif ProfileUpdating.execute(profile, permitted_params)
handle_successful_profile_update
else
query = "course"
original = {
"en"=>{
"courses"=>"Courses",
"layouts"=>{
"navigation"=>{
"desktop"=>{
"browse_courses"=>"Browse Courses",
"this_one"=>false
@joemsak
joemsak / .gitignore
Created February 15, 2020 18:53
.gitignore for merge conflict backups
.orig
@joemsak
joemsak / .gitconfig
Created February 15, 2020 18:15
.gitconfig for rerere (Reuse Recorded Resolution)
[rerere]
enabled = true
@joemsak
joemsak / .gitconfig
Created February 15, 2020 18:13
.gitconfig for setting up pull with rebase
[branch]
autosetuprebase = always
@joemsak
joemsak / .gitconfig
Last active February 15, 2020 18:10
.gitconfig for setting VS code as the merge conflict editor
[merge]
tool = vscode
[mergetool "vscode"]
cmd = code --wait $MERGED
[mergetool]
keepBackup = false