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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Capistrano + Rails: Automatically skipping asset compilation when assets have not changed
Rails deployments can spend minutes precompiling assets; Capistrano can skip that work automatically when the code and asset files have not changed.
Analyse TCP/UDP traffic with netcat
Inspect raw TCP or UDP data arriving on a port, such as an HTTP request, with nc and redirect the output to stdout or a file.
Copy a file over SSH
Ubuntu lets you mount an SSH shell into Nautilus from Places -> Connect to server (select "SSH" as server type).
In order to copy a file over SSH from a shell:
scp filename username@remotehost:
The trailing ":" directs the file to username's home directory on the remote host.
You can also copy a file from the remote host to your local machine:
scp remotehost:remotepath localpath