Skip to content

Instantly share code, notes, and snippets.


Ron Green rgreenjr

View GitHub Profile
View SSH Host
# open the ssh configuration file
sudo vi /etc/ssh/sshd_config

Make the following changes to /etc/ssh/sshd_config:

# disable password authentication
PasswordAuthentication no
rgreenjr /
Created November 2, 2017 16:52
VIM Notes

select to end of line

v g _

split arguments

g ,
rgreenjr /
Last active June 8, 2022 00:42
Object Oriented Design Notes

Sandi Metz

  • Inheritance is not for sharing behavior
  • Active Nothing (Null Object Pattern)
    • Must believe in nothing
  • No such thing as one specialization
    • The new behavior is one thing and the original behavior is the other
    • Isolate the difference, name the concept, define the role, inject the players

Model Names

rgreenjr /
Last active December 8, 2022 02:10
PostgreSQL Upgrading
# Taken from
# Note: these steps assume installation with Homebrew.
# Initialize a new database, adding a .new suffix to the directory that Homebrew recommends.
initdb /usr/local/var/ -E utf8
# Run the upgrade script, providing the correct paths for the various flags.
rgreenjr /
Last active October 27, 2022 05:39
PostgreSQL Configuration Optimization
rgreenjr / postgres_queries_and_commands.sql
Last active September 22, 2023 09:13
Useful PostgreSQL Queries and Commands
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
rgreenjr / Git Cheat
Last active September 12, 2023 20:54
Git Cheat Sheet
View Git Cheat
rgreenjr / gutenberg_text2audio.rb
Created January 18, 2010 17:29
Converts Gutenberg text files into spoken audio files.
View gutenberg_text2audio.rb
#!/usr/bin/env ruby -w
# Converts Gutenberg text files into spoken audio files.
require 'rubygems'
text = { |f| text = }
chapters = text.split(/^CHAPTER .*$/)
chapters.each_with_index do |chapter, index|
rgreenjr / goodreads_csv_filter.rb
Created January 18, 2010 17:25
Trims Goodreads CSV files so they import into Delicious Library essential data only.
View goodreads_csv_filter.rb
#!/usr/bin/env ruby -w
# Trims Goodreads CSV files so they import into Delicious Library essential data only.
require 'rubygems'
require 'faster_csv'
path = ARGV.empty? ? "/Users/rgreen/Downloads/goodreads_export.csv" : ARGV[0]
rgreenjr / word_freq.rb
Created January 18, 2010 15:30
Script to count word frequency.
View word_freq.rb
#!/usr/bin/env ruby -w
text =
words = text.split(/[^a-zA-Z]/)
freqs =
words.each { |word| freqs[word] += 1 }
freqs = freqs.sort_by { |x, y| y }
freqs.each { |word, freq| puts sprintf("%20s %s", word, freq.to_s) }