Skip to content

Instantly share code, notes, and snippets.

View katpadi's full-sized avatar
🎯
Focusing

Kat Padilla katpadi

🎯
Focusing
View GitHub Profile
@katpadi
katpadi / underscore_log.rb
Last active March 4, 2022 10:33
UnderscoreLog
# frozen_string_literal: true
# Usage:
# class ServiceX
# include UnderscoreLog
#
# def initialize
# end
#
# def call
@katpadi
katpadi / jotter.rb
Created February 25, 2022 15:39
Jotter
# frozen_string_literal: true
module Jotter
def jot_info(tag = '')
Rails.logger.tagged(facility + " #{tag}") do
Rails.logger.info { yield }
end
end
def jot_debug(tag = '')
@katpadi
katpadi / .gitconfig
Last active October 18, 2021 14:18
.gitconfig
[user]
name = Kat Padilla
email = hello@******.ph
[core]
excludesfile = /Users/katpadi/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/Sourcetree 3.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
awk -F'[ :,]' '{a[$1":"$2"["$10 "["$16"]"]++}END{for(i in a){if(a[i] > 3){print i "-" a[i]}}}' dups.log
awk -F'[ :,]' '{print $1":"$2":"$3"["$10 "["$16"]"}' dups.log
@katpadi
katpadi / gracefully.rb
Created April 5, 2018 14:34
Gracefully
class Gracefully
class << self
alias_method :handle, :new
end
attr_reader :error, :value
def initialize
@value = nil
@error = nil
@katpadi
katpadi / bulky.rb
Last active April 5, 2018 11:51
Bulky
# Bulky
#
# Bulky is a simple ActiveRecord extension to insert or update a bulk of rows in a single statement.
#
module Bulky
# Bulk insert multiple rows into a table
#
# Usage:
#
# Post.bulk_insert(['name', 'label'], [['ch', 'Label 1'], ['ch_2', 'Label 2']])
@katpadi
katpadi / gracefully.rb
Created April 5, 2018 09:54
Gracefully
class Gracefully
class << self
alias_method :handle, :new
end
attr_reader :error, :value
# Accepts a block, invokes it, and wraps the return value in an
# exception-free `Gracefully` object
#
@katpadi
katpadi / dev_profiler.rb
Last active March 5, 2018 11:34
My Ruby Profiler - wraps code to be profiled and prints result in a nice way (uses ruby-prof)
require 'ruby-prof'
#
# This will use ruby-prof and print in a nice way.
#
# Input params:
# file_name = File name of output
# printer = graph || flat || stack
#
# Output format:
# E.g.:
@katpadi
katpadi / num_feels.rb
Last active January 9, 2018 11:26
Number Feels
class NumFeels
attr_reader :number
def initialize(number)
@number = number
end
def happy?
fail ArgumentError if number < 0
sum = 0
@katpadi
katpadi / git-cheatsheet.md
Last active January 9, 2018 09:44
My Git Cheatsheet

Setting your branch to exactly match the remote branch:

git fetch origin
git reset --hard origin/master

.gitconfig