Skip to content

Instantly share code, notes, and snippets.

Ron Green rgreenjr

Block or report user

Report or block rgreenjr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View vim_notes.md

select to end of line

v g _

split arguments

g ,
@rgreenjr
rgreenjr / object_oriented_design_notes.md
Last active Aug 2, 2017
Object Oriented Design Notes
View object_oriented_design_notes.md

Sandi Metz

  • Inheritence 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
rgreenjr / bootstrap_buttons.html
Last active Jun 15, 2019
Bootstrap 3 Right Aligned Buttons
View bootstrap_buttons.html
<div class="clearfix">
<div class="pull-right">
<button type="submit" class="btn btn-default">Cancel</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
@rgreenjr
rgreenjr / Bounce Email.workflow
Created May 1, 2013
Bounce Email Automater Workflow
View Bounce Email.workflow
on run {input, parameters}
tell application "Mail"
repeat with eachMessage in input
bounce eachMessage
end repeat
end tell
end run
@rgreenjr
rgreenjr / postgresql_upgrade.sh
Last active Aug 22, 2019
PostgreSQL Upgrading
View postgresql_upgrade.sh
# Taken from http://robots.thoughtbot.com/post/33706558963/migrating-data-from-an-upgraded-postgres
#
# 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/postgres.new -E utf8
# Run the upgrade script, providing the correct paths for the various flags.
@rgreenjr
rgreenjr / postgres_config.md
Last active Aug 22, 2019
PostgreSQL Configuration Optimization
View postgres_config.md

PostgreSQL Configuration Optimization

Memory

Only four values really matter:

  • shared-buffers: below 2GB: set it to 20% of full memory; below 32GB: 25% of your full memory.
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active Oct 20, 2019
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
rgreenjr / gutenberg_text2audio.rb
Created Jan 18, 2010
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 = String.new
File.open(ARGV.first) { |f| text = f.read }
chapters = text.split(/^CHAPTER .*$/)
chapters.each_with_index do |chapter, index|
@rgreenjr
rgreenjr / goodreads_csv_filter.rb
Created Jan 18, 2010
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
rgreenjr / word_freq.rb
Created Jan 18, 2010
Script to count word frequency.
View word_freq.rb
#!/usr/bin/env ruby -w
text = IO.read(ARGV.first)
words = text.split(/[^a-zA-Z]/)
freqs = Hash.new(0)
words.each { |word| freqs[word] += 1 }
freqs = freqs.sort_by { |x, y| y }
freqs.reverse!
freqs.each { |word, freq| puts sprintf("%20s %s", word, freq.to_s) }
You can’t perform that action at this time.