Useful script to collect downloads from several sites
Keeps lecture documents and other downloadable files collected from multiple web pages without manual checking, using a configurable URL and CSS selector.
How to fix: "500 Internal Server Error" after adding Rack::Bug
Passenger and Apache can return 500 errors after adding Rack::Bug when the middleware is referenced as a string instead of loaded with require 'rack/bug'.
Request a gzipped response from a web server using Wget
Application servers often compress responses with gzip, but Wget downloads the uncompressed version unless Accept-Encoding: gzip is sent.
Embed Google Analytics code for some environments only
Google Analytics should run only in production to avoid polluting visitor statistics. Rails environment checks can gate the tracking snippet.
davetron5000/methadone - GitHub
Ruby framework for building command-line apps with parameter handling, utility classes, and Cucumber support for CLI testing.
How to fix "unknown role" errors in Capistrano recipes
Capistrano multistage recipes can fail with unknown role errors when a task targets a missing server group. Registering the role and skipping the task when no servers match prevents the failure.
Pick a random element from an array in Ruby
Choose one array element at random in Ruby with sample; weighted_sample can bias the result toward specific values.
Caching may break relative paths in your merged stylesheet
Stylesheet caching can merge files from different folders and leave relative image paths pointing to the wrong location, so images work locally but fail on the server.
Scenario outlines in Cucumber
Template-based examples reduce repetition in behavior-driven tests and make repetitive cases easier to maintain.
ERB templates and comments
Whitespace before # in ERB Ruby comments can produce unexpected HTML output; <%# ... %> and newline-indented comments avoid the problem.
Git instaweb
Git includes a built-in browser-based repository viewer for local inspection; git instaweb starts a temporary web server, with Apache or lighttpd support.
Graticule computes NULL distance for some records (and how to fix that)
Spherical distance queries in Graticule can return NULL because MySQL rounding pushes ACOS outside its valid range. Clamping the value to [-1, 1] prevents the zero-distance edge case.
Sequel: The Database Toolkit for Ruby
A lightweight database toolkit for Ruby bridges the gap between ActiveRecord and raw SQL when full ORM features are unnecessary.
DataMapper Retrospective
Two major projects started with DataMapper and later moved to a different ORM, raising questions about the framework’s long-term fit and maintainability.
Bulk-change multiple table rows in a migration
Multiple column changes in a migration can trigger repeated SQL and slow large tables; change_table can bundle them into one ALTER TABLE statement.
Rails ERD – Entity-Relationship Diagrams for Rails
Generate visual database relationship maps from Rails ActiveRecord models for easier schema understanding and documentation.
Ubuntu 11.10: Playing sound over front and back panel (or headphones and speakers) at once
Front and back audio outputs can stop playing together when jack sensing or auto mute disables one panel. alsamixer can turn off the behavior.
ActsAsTaggableOn: Cache tag lists
Cached tag lists in ActsAsTaggableOn reduce eager loading and improve performance by storing tag data directly in the model.
How to ignore new files or changed files in git
Untracked or modified files clutter Git status and can be hidden locally or for everyone with ignore rules and git update-index flags.
How to define a custom context menu within HTML (Firefox 8+)
Custom right-click menus can be built with HTML in Firefox 8+ instead of relying on browser defaults.
Configuration for Rails, the Right Way
Rails 3 lets applications define custom configuration elements directly, avoiding extra gems or plugins for miscellaneous settings.
Create a new gemset with RVM
Separate gemsets let each Ruby application use its own installed gems. rvm use 1.8.7-p323@makandra_project_xy --create creates and switches to a new gemset.
Error "execution expired (Timeout::Error)" when using Selenium and Webmock
Bulk test runs can fail with execution expired (Timeout::Error) when Selenium and WebMock interact; upgrading WebMock to 1.7+ resolves the timeout issue.
Excel files can't hold more than 65535 rows per worksheet
Classic XLS worksheets stop at 65,535 rows; the Spreadsheet gem writes only XLS, so larger exports need split sheets, extra columns, or XLSX output.