Scaling Pinterest - From 0 to 10s of Billions of Page Views a Month in Two Years

Pinterest’s growth to tens of billions of page views per month exposed scaling limits and drove careful infrastructure choices around storage, search, caching, and reliability.

How to discard a surrounding Bundler environment

Bundler variables leak into child processes and can force the wrong gemset when running nested bundle commands. Bundler.with_original_env restores the pre-Bundler environment; Bundler.with_unbundled_env is the modern Bundler-free variant.

How to fix: "unexpected token" error for JSON.parse

JSON.parse raises unexpected token when given a top-level string value that is not valid JSON text. Wrap data in an array or object, or use quirks_mode as a workaround.

kamens/jQuery-menu-aim

jQuery plugin for detecting cursor intent over dropdown menus, useful for responsive mega menus that open only when users aim at specific items.

How to access your Rails session ID

Accessing the Rails session ID is only possible when a session ID exists; exposing it is risky and should be done carefully.

Controller specs do not persist the Rails session across requests of the same spec

Controller specs reset the Rails session on every request, so data written earlier disappears between calls. Stubbing controller.session with a shared TestSession preserves state for testing.

Firefox >= 23 will block mixed content when using SSL

Firefox 23 blocks insecure active content on secure pages by default, reducing mixed-content risks while leaving images, video, and audio unblocked.

parallel_tests: Disable parallel run for tagged scenarios

Tag specific Cucumber scenarios so they avoid running together when they contend for a shared resource or browser focus, at the cost of slower tests.

Markdown-like emphasizing for text fields

Lightweight emphasis for text fields without full Markdown, replacing **text** with <strong>text</strong> in Rails views.

How to rotate log files explicitly

Force logrotate to rotate logs immediately when nightly rotation has not run. Useful for huge logs or manual maintenance; Apache configs may restart the service.

What `var` actually does in Javascript

Undeclared assignments in Javascript often create or reuse globals instead of local variables, causing scope leaks and hard-to-track bugs.

ApacheBench may return "Failed requests" for successful requests

ab can report successful responses as failed when later replies differ in content length from the first response. The Length counter often indicates this false positive.

How to horizontally center absolute positioned container with CSS

Absolute positioned containers do not center with auto margins; a left-50% offset with negative half-width margin can align them horizontally.

YAML syntax compared with Ruby syntax

YAML and Ruby have different syntax, and YAML aliases and merge keys often matter when writing Rails locale files. Duplicate keys override earlier values instead of merging nested content.

Article "Pricing Experiments You Might Not Know, But Can Learn From"

Pricing decisions are hard to get right, and small changes can affect revenue and customer response. Practical pricing experiments offer ideas for improving pricing strategy.

Center a float horizontally

Centering a floated element can fit content width when inline-block is unavailable. A CSS/SASS wrapper and Rails helper provide IE7+ support.

Rails: How to use a n:m association as 1:n association

A join model can enforce a single associated record when a foreign key on the target model is not possible; validates_uniqueness_of on the join row limits the relation to one.

How to use helper methods in a controller

Expose controller logic to views so helper-style methods can be called from templates, with different APIs in Rails 2 and Rails 3+.

How to set the user agent in tests

Customizing the User-Agent header in tests makes browser- and crawler-specific behavior reproducible across Rack::Test, Selenium, and request specs.

Spreewald: When using `patiently do`, don't reuse existing variable names

patiently do repeats a block until it passes or times out; reusing outer variable names inside the repeated block can make repeated evaluations fail.

def vs. define_method

Ruby’s def and define_method differ in scope, closure behavior, and how the receiver is chosen, affecting access to outer variables and method definition targets.

How to make Rational#to_s return strings without denominator 1 again

Ruby 1.9+ renders integer-valued Rational objects as 2/1, which can leak into views and date calculations. A small override restores the Ruby 1.8-style integer string output.

Test redirects to an external URL with Cucumber/Capybara

External redirects are awkward to test with Cucumber and Capybara: Rack::Test ignores the host, while Selenium follows it. Controller specs or an observable redirect make the target URL verifiable.