Skip to content

Instantly share code, notes, and snippets.

View brenodamata's full-sized avatar
🌍
Remote

Breno da Mata brenodamata

🌍
Remote
View GitHub Profile
@brenodamata
brenodamata / database_report.rb
Created March 15, 2019 19:16
List record count for all tables
class DatabaseReport
def entry_counts
table_model_names.map do |model_name|
entity = model_name.constantize rescue nil
next if entity.nil?
{ entity.to_s => entity.count }
end.compact
end
private
### Keybase proof
I hereby claim:
* I am brenodamata on github.
* I am bren0 (https://keybase.io/bren0) on keybase.
* I have a public key ASDNGqNT5KBg5gMaG93pI7yh6Sy0S48eH82b1ctbL7XFPwo
To claim this, I am signing this object:
@brenodamata
brenodamata / better_routing_number.rb
Created April 6, 2016 19:58
New and improved (faster) Routing Number Generator
require 'rubygems'
require 'faker'
def generate_routing_number
number = Faker::Number.number(8).to_s
d = number.split('').map(&:to_i).select { |d| (0..9).include?(d) }
checksum = (3 * (d[0] + d[3] + d[6])) + (7 * (d[1] + d[4] + d[7])) + (d[2] + d[5])
if checksum%10 == 0
d << 0
else
@brenodamata
brenodamata / gist:a035c94f020d92ac21d7
Created September 25, 2015 15:17
Killing Rails Process
Assuming you're looking to kill whatever is on port 3000, type this in your terminal to find out the PID of the process:
$ lsof -wni tcp:3000
Then, use the number in the PID column to kill the process:
$ kill -9 PID
@brenodamata
brenodamata / routing_number.rb
Last active August 29, 2015 14:01
Generates and Validates banks Routing numbers
require 'rubygems'
require 'faker'
def generate_routing_number
valid = false
until valid
number = Faker::Number.number(9).to_s
valid = valid_routing_number? number
end
number