Skip to content

Instantly share code, notes, and snippets.


Kat Padilla katpadi

View GitHub Profile
View gist:f23cfa4bcca07e8c6a7e985297974c86
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
View gracefully.rb
class Gracefully
class << self
alias_method :handle, :new
attr_reader :error, :value
def initialize
@value = nil
@error = nil
View bulky.rb
# 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']])
View gracefully.rb
class Gracefully
class << self
alias_method :handle, :new
attr_reader :error, :value
# Accepts a block, invokes it, and wraps the return value in an
# exception-free `Gracefully` object
katpadi / dev_profiler.rb
Last active Mar 5, 2018
My Ruby Profiler - wraps code to be profiled and prints result in a nice way (uses ruby-prof)
View dev_profiler.rb
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 / num_feels.rb
Last active Jan 9, 2018
Number Feels
View num_feels.rb
class NumFeels
attr_reader :number
def initialize(number)
@number = number
def happy?
fail ArgumentError if number < 0
sum = 0
katpadi /
Last active Jan 9, 2018
My Git Cheatsheet

Setting your branch to exactly match the remote branch:

git fetch origin
git reset --hard origin/master


katpadi / autocomplete_search.rb
Last active Feb 12, 2017
Autocomplete Kups Search
View autocomplete_search.rb
class AutocompleteSearch
class << self
def populate(query_scope)
query_scope.find_each do |item|
name = item.label
json_data = format_data(item)
name.length.times do |n|
key = name[0, n+1]
$redis.zadd "kupsearch:#{key.downcase}", 1, json_data
View gist:6cb1dc62211c6c4381116ee3e8c0d7f1
"auto_complete_commit_on_tab": true,
"caret_style": "solid",
"color_scheme": "Packages/User/RailsCastsColorScheme (SL).tmTheme",
"draw_white_space": "all",
"enable_tab_scrolling": false,
"ensure_newline_at_eof_on_save": true,
katpadi / .rubocop.yml
Created Jul 13, 2016
Kat's Preferred RuboCop Style Guide
View .rubocop.yml
Enabled: false
- '**/Rakefile'
- '**/'
- 'db/**/*'
- 'test/test_helper.rb'
- 'spec/spec_helper.rb'