How to show an ordered crontab
Unordered crontabs are hard to scan; sorting scheduled rows by time makes recurring jobs easier to read, including @reboot entries.
RSpec: Stubbing a method that takes a block
RSpec stubs for methods that yield blocks need and_yield instead of and_return; multiple yields can be chained, and return values can be combined.
Dumping and importing from/to MySQL in an UTF-8 safe way
MySQL dumps can corrupt UTF-8 when shell redirection changes character encoding. Using -r for export and SOURCE for import preserves the dump bytes.
How to drop all tables in PostgreSQL
Removing every table while keeping the PostgreSQL database can be done by dropping the schema or iterating through tables with DROP TABLE statements.
OpenStack instance not configuring network (DHCP) correctly
OpenStack VM instances on new compute nodes can stop after DHCPOffer because outgoing DHCP traffic never reaches the guest. Recalculating UDP checksums with iptables fixes the network setup.
Ruby constant lookup: The good, the bad and the ugly
Ruby constant resolution can pick the wrong class through namespace fallbacks, causing autoloading bugs and unexpected references in Rails, especially with nested models.
Protip: Clone large projects multiple times
Long test suites block new work on large projects; cloning the repository into a separate directory lets tests run in parallel while development continues.
Angular: Keeping attributes with invalid values in an ngModel
Angular 1.2 invalid form values can disappear from ngModel, leaving old data unchanged; a directive can keep empty strings, and Angular 1.3 adds allowInvalid.
Good real world example for form models / presenters in Rails
Rails form-specific model layer for screen logic, separate validations, and callbacks without bloating the base model; useful for different workflows and presentable collections.
Solve screen error "Cannot open your terminal '/dev/pts/0' - please check"
screen can fail with “Cannot open your terminal '/dev/pts/0'” after switching users in the same session; owning the shell correctly or reconnecting as the target user avoids it.
Fix error: Invalid gemspec / Illformed requirement
Broken gem specifications trigger “Invalid gemspec” and “Illformed requirement” errors; updating Rubygems, removing corrupted gem files, and reinstalling fixes Bundler failures.
Rack dies when parsing large forms
Rack can reject large nested forms by miscounting input fields against its parameter limit, causing low-level Ruby errors or Rails error pages.
Howto provide a single page preview for PDF & TXT with carrierwave
Single-page previews for PDF and TXT uploads can be generated with CarrierWave and RMagick by rendering the first page as a JPG thumbnail.
Fix error: rails console No such file to load -- irb/encoding_aliases.rb (LoadError)
Rails console fails after upgrading Ruby because spring tries to load a missing irb file. Updating binding_of_caller to 0.8.0 restores console startup.
postgresql create extension without giving the application superuser rights
PostgreSQL extensions do not require application users to be superusers; create them once with a superuser account such as postgres.
Installing Adobe Reader on Ubuntu
Adobe Reader is no longer supported on Linux, but some PDFs and forms still need acroread when Ubuntu's default viewer fails.
Gherkin: Error during installation
gherkin gem installation can fail because native extension warnings are treated as errors. Disabling warnings with --with-cflags=-w lets bundle install succeed.
Select a random table row with ActiveRecord
Randomly selecting a database row with ActiveRecord is possible, but ORDER BY RAND() scales poorly and can overload large tables.
Offtopic: Floppy-disc OS
MenuetOS is a tiny 32/64-bit x86 operating system in assembly, fitting on a floppy and supporting GUI apps, USB, networking and SMP.
XHR is not JSON
request.xhr? is not a reliable signal for JSON responses in Rails; respond_to respects the client’s Accept header and supports both HTML and JSON.
Cast a string to the type of an ActiveRecord attribute
ActiveRecord columns can convert string input to the underlying attribute type, such as integers and booleans, using column metadata.
Using Firebug Lite to inspect HTML in Internet Explorer and other browsers
Firebug Lite brings Firebug-style DOM inspection to Internet Explorer and other browsers, including older IE versions, using a JavaScript bookmarklet.
Legacy CarrierWave: How to generate versions with different file extensions
CarrierWave can create versions with fixed extensions like mp4, but it needs custom uploader logic to keep filenames, MIME types, and cache handling consistent.
pgAdmin has a "graphical EXPLAIN" feature
pgAdmin can present PostgreSQL EXPLAIN output in a readable graphical form, making query plans easier to inspect than raw console text.