Bash: How to count and sort requests by IP from the access logs
Count and sort request frequencies by client IP in access logs with a short awk pipeline for quick traffic checks and abuse spotting.
Puma: How to force a single threaded boot in development
Single-threaded Puma in development avoids overlapping requests and noisy console output when debugging. Setting -t 0:1 makes other requests wait.
Web development: Accepting a self-signed certificate in Google Chrome
Chrome can reject locally generated self-signed certificates and hide HTTPS even when they work. Importing the certificate or launching with --ignore-certificate-errors allows testing.
Beware when using ActiveSupport time and date calculation methods
Duration#ago and Duration#from_now return ActiveSupport::TimeWithZone, which can introduce unexpected timezone behavior when an app assumes local or timezone-unaware dates.
Debugging Webpacker config
Webpacker configuration can be hard to inspect when builds misbehave; dumping the environment, using browser or Node debugging, and emitting warnings help reveal the active webpack settings.
skorks/nesty
Preserve the original failure when re-raising a different Ruby exception so stack traces still point to the root cause; Nesty merges nested errors automatically.
better rails app restart with the passenger restart-app tool
passenger-config restart-app restarts a Rails app immediately without touching tmp/restart.txt, avoiding the next-request delay and fitting Capistrano deployments.
Generating and streaming ZIP archives on the fly
Large ZIP downloads can start immediately without writing files to disk, using zip_tricks_stream for custom content or zipline for existing attachments.
Howto respond html or json in the same controller action with Rails 2
Rails 2.3 can return either HTML or JSON from one controller action, but render_to_string inside format.json may trigger ActionView::MissingTemplate.
PSA: Dont allow private gems to be pushed to rubygems.org
Bundler’s default release task can publish private gems to rubygems.org; allowed_push_host in gem metadata restricts pushes to a trusted host.
Shell script to quickly switch Apache sites
Quickly make one Apache virtual host available at localhost while switching projects. The script disables other sites, can re-enable the default site, and lists available sites without arguments.
How to deal with strange errors from WEBrick
WEBrick can emit unreadable URI and request-line errors when a browser connects with HTTPS; switching the URL to http avoids the SSL mismatch.
console-for opens a Rails console remotely on a Capistrano deployment target
console-for opens a remote Rails console on a Capistrano deployment target with one command, so staging and other environments can be accessed quickly.
Ruby and Rails: Debugging a Memory Leak
Growing memory usage in Ruby and Rails can exhaust a process and cause crashes; ObjectSpace.count_objects helps identify leaking object types, and derailed_benchmarks can aid diagnosis.
Setup or update Passenger to use Ruby Enterprise
Passenger can be configured or upgraded to use Ruby Enterprise instead of MRI, then Apache is restarted with the generated module instructions.
Announcing YARD 0.6.0 (gnuu.org)
YARD 0.6 adds the ability to serve documentation for gems as well as the current project with yard server. Just like gem server in RubyGems, you can serve gem docs. The advantage to YARD’s server is that you don’t need to pre-generate the static docs (with a gem install) before running the server. If you installed your gem with --no-rdoc, YARD will just generate it on the fly!
SSH: X-Forwarding
Remote graphical programs can run on your local desktop through SSH, but X11 forwarding is slower and exposes your X session to a trusted host.
Using Passenger for development (with optional SSL)
Run a Rails app locally with Apache and Passenger for development, including optional HTTPS using a self-signed certificate.
How to look at hidden X screens
Hidden X displays can be inspected by taking a screenshot of the active display, including Xvfb-backed sessions used for headless tests.
ActionMailer: How to send a test mail directly from the console
Rails console debugging for mail delivery failures, with ActionMailer settings inspection and a direct test message to verify SMTP and spam score.
Rails: Kill spring with fire
Rails Spring processes can linger and restart unexpectedly, interfering with command runs; stopping the process and disabling auto-start prevents it from coming back.
Live CSS / view reloading
Automatic browser refresh for stylesheet and view changes reduces manual reloads during front-end work and keeps page updates visible immediately.
Geordi: run a capistrano task on all stages
Run a Capistrano command across every known deploy target, including staging and production, with geordi cap or geordi capistrano shortcuts.
How to hide your selenium browser window with "headless"
Selenium browser windows can steal focus during Cucumber acceptance tests; headless with xvfb keeps them hidden while running Selenium WebDriver through Capybara.