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
tables = [] | |
ActiveRecord::Base.connection.tables.each do |t| | |
count = ActiveRecord::Base.connection.exec_query("select count(*) from #{t}").rows[0][0] | |
tables << [t, count.to_i] | |
end | |
tables.sort_by { |t| t[1] }.reverse! |
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 | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'thor' | |
gem 'rainbow' | |
gem 'awesome_print' | |
gem 'terminal-table' | |
gem 'terminal-emojify' |
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
/** | |
* This Google Sheets script keeps data in the specified column sorted any time | |
* the data changes. | |
* | |
* After much research, there wasn't an easy way to automatically keep a column | |
* sorted in Google Sheets, and creating a second sheet to act as a "view" to | |
* my primary one in order to achieve that was not an option. Instead, I | |
* created a script that watches for when a cell is edited and triggers | |
* an auto sort. | |
* |
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
# Put this in Rakefile (doesn't matter where) | |
require 'benchmark' | |
class Rake::Task | |
def execute_with_benchmark(*args) | |
bm = Benchmark.measure { execute_without_benchmark(*args) } | |
puts " #{name} --> #{bm}" | |
end | |
alias_method :execute_without_benchmark, :execute |
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 'mina/rails' | |
require 'mina/git' | |
require 'mina/rbenv' # for rbenv support. (https://rbenv.org) | |
# require 'mina/rvm' # for rvm support. (https://rvm.io) | |
set :application_name, 'my_app' | |
set :domain, 'my_server' | |
set :deploy_to, '/home/rails/my_app' | |
set :repository, '[email protected]:my_user/my_app.git' | |
set :branch, 'master' |
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
2.3.1 :031 > a = Hash.new([]) | |
=> {} | |
2.3.1 :032 > a[:b] | |
=> [] | |
2.3.1 :033 > a[:b].push(4) | |
=> [4] | |
2.3.1 :034 > a | |
=> {} | |
2.3.1 :035 > a[:b] | |
=> [4] |
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
module Foo | |
def self.included(base) | |
base.class_eval do | |
def self.method_injected_by_foo | |
... | |
end | |
end | |
end | |
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
How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS | |
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing). | |
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here: | |
* Heroku Hostname SSL | |
* GoDaddy Standard SSL Certificate | |
* Zerigo DNS |
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 ProfileProject < ApplicationRecord | |
acts_as_votable | |
scope :join_votes, (lambda do | |
joins(sanitize_sql_array([%( | |
LEFT JOIN votes ON votes.votable_id = profile_projects.id | |
AND votes.votable_type = 'ProfileProject' | |
) | |
])) | |
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
config.log_level = :debug | |
config.middleware.use LogPrettyJson |
NewerOlder