Add to Gemfile
:
gem 'puma'
gem 'god'
Run in app folder:
bundle install
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! |
#!/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 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. | |
* |
# 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 |
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' |
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 |
I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.
Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.
A traditional approach for this on a Rails project is to use something like the acts_as_list
gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position
SQL query.
This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri
git ls-files -z | xargs -0n1 git blame -w | perl -n -e '/^.*\((.*?)\s*[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n |