This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
# ensure all classes have been laoded | |
Rails.application.eager_load! | |
def calc_callback_counts | |
models = ApplicationRecord.descendants | |
class_callback_counts = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CALLBACKS = [ | |
'before_validation', | |
'after_validation', | |
'before_save', | |
'around_save', | |
'before_create', | |
'around_create', | |
'after_create', | |
'after_save', | |
'after_commit', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'octokit' | |
require 'pp' | |
def obtain_comment_stats | |
# takes about a minute for 1 months of PRs | |
stats = {} | |
# sample_output = { | |
# "kallin" => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
current_branch = `git symbolic-ref --short HEAD`.chomp | |
if current_branch != "master" | |
if $?.exitstatus == 0 | |
puts "WARNING: You are on branch #{current_branch}, NOT master." | |
else | |
puts "WARNING: You are not on a branch" | |
end | |
puts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
current_branch = `git symbolic-ref --short HEAD`.chomp | |
if current_branch != "master" | |
if $?.exitstatus == 0 | |
puts "WARNING: You are on branch #{current_branch}, NOT master." | |
else | |
puts "WARNING: You are not on a branch" | |
end | |
puts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def num_to_digits(num) | |
digits = [] | |
until num == 0 | |
digits << num % 10 | |
num = num / 10 | |
end | |
digits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_descendants(person) | |
descendants = [] | |
stack = person[:children] | |
until stack.empty? | |
current_node = stack.pop | |
children = current_node[:children] | |
if children | |
children.each do |child| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_descendants(person) | |
descendants = [] | |
children = person[:children] | |
if children | |
descendants << children | |
children.each do |child| | |
descendants << find_descendants(child) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vegetable | |
attr_accessor [ | |
:rarity | |
] | |
def ferment | |
# let's make some vegetable jam! | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@fibs = { | |
0 => 0, | |
1 => 1, | |
} | |
def fib(n) | |
cached_result = @fibs[n] | |
return cached_result if cached_result | |
new_result = fib(n-1) + fib(n-2) |
NewerOlder