Skip to content

Instantly share code, notes, and snippets.

Avatar

Joe Sak joemsak

View GitHub Profile
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
joemsak / profiles_controller.rb
Created Aug 17, 2020
app/controllers/concerns/profile_controller.rb
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?
handle_blank_location_error
elsif ProfileUpdating.execute(profile, permitted_params)
handle_successful_profile_update
else
View iteraptor.rb
query = "course"
original = {
"en"=>{
"courses"=>"Courses",
"layouts"=>{
"navigation"=>{
"desktop"=>{
"browse_courses"=>"Browse Courses",
"this_one"=>false
@joemsak
joemsak / .gitignore
Created Feb 15, 2020
.gitignore for merge conflict backups
@joemsak
joemsak / .gitconfig
Created Feb 15, 2020
.gitconfig for rerere (Reuse Recorded Resolution)
View .gitconfig
[rerere]
enabled = true
@joemsak
joemsak / .gitconfig
Created Feb 15, 2020
.gitconfig for setting up pull with rebase
View .gitconfig
[branch]
autosetuprebase = always
@joemsak
joemsak / .gitconfig
Last active Feb 15, 2020
.gitconfig for setting VS code as the merge conflict editor
View .gitconfig
[merge]
tool = vscode
[mergetool "vscode"]
cmd = code --wait $MERGED
[mergetool]
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"
}
private
def current_user
begin
@current_user ||= User.find_by!(auth_token: session[:user_auth_token])
# I am assuming that the details of storing
View 1_method_missing.rb
class Drink
def sip
puts "You drank with caution"
end
end
class Coffee < Drink
def method_missing(method_name, *args, &block)
if method_name == :gulp
puts "Please don't gulp your coffee!"
View firebase-debug.log
[debug] [2018-04-03T13:10:15.938Z] ----------------------------------------------------------------------
[debug] [2018-04-03T13:10:15.941Z] Command: /Users/joemsak/.asdf/installs/nodejs/9.9.0/bin/node /Users/joemsak/.asdf/installs/nodejs/9.9.0/.npm/bin/firebase auth:import db/export/accounts.json --hash-algo=BCRYPT --project technovation-ed789 --debug
[debug] [2018-04-03T13:10:15.942Z] CLI Version: 3.17.7
[debug] [2018-04-03T13:10:15.942Z] Platform: darwin
[debug] [2018-04-03T13:10:15.942Z] Node Version: v9.9.0
[debug] [2018-04-03T13:10:15.942Z] Time: Tue Apr 03 2018 08:10:15 GMT-0500 (CDT)
[debug] [2018-04-03T13:10:15.943Z] ----------------------------------------------------------------------
[debug]
[debug] [2018-04-03T13:10:15.951Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
[debug] [2018-04-03T13:10:15.951Z] > authorizing via signed-in user