Skip to content

Instantly share code, notes, and snippets.

View proctitle_for_rails.rb
# Add info in the ps listing of rails server and delayed jobs processes
# app/controllers/application_controller.rb
before_action :proctitle
after_action :unproctitle
def proctitle
path = request.env['REQUEST_PATH']&.first(25)
Process.setproctitle("#{$PROGRAM_NAME} - #{path}")
View http_bench.rb
#!/usr/bin/env ruby
require 'benchmark'
require 'cgi'
require 'net/http'
host = ''
period = 10
count = 3
verbose = false
user_agent = $PROGRAM_NAME
View rails_sql_client.rb
#!/usr/bin/env ruby
env_rb = ['../config/environment.rb', 'config/environment.rb'].detect { |file| File.exist? file }
raise 'Run this from rails root or a subdirectory.' unless env_rb
require File.expand_path(env_rb)
if ARGV[0] =~ /^-[cexq]$/
sql_in = ARGV.join(' ')
View editor.rb
#! /usr/bin/env ruby
# adapted from
# but it actually edits a file!
# `editor.rb [filename]`
# arrows, letters, backspace... Just the basics.
require 'curses'
include Curses
include Curses::Key