Ruby: How to convert hex color codes to rgb or rgba

Convert hex color codes to RGB or rgba values in plain Ruby, including 3-, 6- and 8-digit forms with optional opacity.

Rails 4 introduced collection_check_boxes

Rails 4.0 adds collection_check_boxes for rendering checkbox groups from a collection and handling multi-value form params safely.

Online tool to convert tables between different formats

Online table conversion helps move data between JSON, Markdown and CSV, with transpose support for rotated tables. Not suitable for sensitive data.

Capybara: Preventing headless Chrome from freezing your test suite

Headless Chrome can freeze end-to-end test runs and leave Capybara waiting through long timeouts; restarting sessions regularly and failing fast on lost browser communication reduces hangs.

Capybara: Pretending to interact with the document

Browsers block autoplay and popup APIs until a user gesture occurs; a tiny clicked element can unlock them in Capybara tests.

RSpec: How to test the content of a flash message in a request spec

Rails request specs can verify flash messages in the response, letting controller updates surface user feedback such as success or alert notices.

makandra/capybara-lockstep

Flaky end-to-end tests often fail because Capybara outpaces client-side JavaScript and AJAX; synchronizing commands with browser activity makes full-stack integration suites more stable.

Ruby: Generating and parsing JSON, or: understanding JSON::ParserError "unexpected token"

JSON.parse rejects JSON values produced by to_json for non-Hash and non-Array objects; JSON.generate pairs with JSON.parse, while JSON.load restores Ruby objects and should not handle untrusted input.

Geordi 5.4.0 released

Geordi 5.4.0 adds geordi branch, MySQL dump speedups, Pivotal Tracker ID support in global config, and fixes for dump load requirements and test processor documentation.

Parsing JSON with edge cases

Ruby json accepts duplicate keys by keeping the last value, tolerates comment-like truncation in some cases, and can decode huge exponents to Infinity.

Webmock < 3.12.1 cannot handle IPv6 addresses correctly

WebMock fails on IPv6 URLs because addresses need brackets before the port, causing invalid URI and port parsing errors in CarrierWave and SsrfFilter.

Making ZSH the default shell on Ubuntu 20.04

ZSH can replace Bash on Ubuntu 20.04 and adds command-line conveniences like completion, corrections, themes, and plugins.

Mixed Content Examples

Mixed content behavior differs when secure pages load assets over HTTPS versus HTTP, exposing browser handling of blocked or downgraded resources.

Rails: Parsing a time in a desired timezone

Create a Time in a fixed timezone regardless of Rails or system settings; useful for tests and API date comparisons when parsing otherwise shifts by environment.

How to fix: WrongScopeError when using rspec_rails with Rails 6.1

rspec_rails with Rails 6.1 can raise WrongScopeError; upgrading the gem to 4.0.1 or later resolves the failure.

Best practices for REST API design

REST API design often fails on timestamps, number handling, pagination, filtering, and versioning. Consistent conventions improve interoperability and client stability.

Running old ImageMagick versions in a Docker container

Legacy ImageMagick installs can be kept available when the system package is unavailable by running convert and related tools in a Docker container with absolute paths.

Make your Rails console (and irb) output better readable

Colorized, structured output in Rails console and irb makes long strings, objects, and classes easier to inspect. awesome_print adds the ap command for readable formatting.

Some tips for upgrading Bootstrap from 3 to 4

Migrating a larger Rails app from Bootstrap 3 to 4 often breaks styles, components and helper gems; planning library upgrades and rebuilding variables reduces the pain.

ActiveType #change_association: Define { autosave: true } on parent models

Nested form records on overridden associations are not persisted unless the parent association enables autosave.

How to fix: Version in "./docker-compose.yml" is unsupported

Old docker-compose versions can reject modern Compose file formats and report an unsupported version in docker-compose.yml. Upgrading to a newer Compose release resolves the mismatch.

WYSIWYG with Action Text

Rails 6 Action Text provides a built-in WYSIWYG editor for rich text fields, with Trix hooks for custom toolbar buttons and attachment handling.

Rails: Postgres Partial Indexing

PostgreSQL partial indexes reduce index size and write overhead by indexing only rows that match a condition, useful for conditional uniqueness and large tables.

How to fix "Command "webpack" not found"

Deployment asset precompilation can fail with Command "webpack" not found when Yarn dependencies are missing. A bin/yarn binstub lets yarn install run during deploy.