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.
How to disable cookies in cucumber tests
Capybara has no built-in switch for disabling cookies in browser tests; a small Rack middleware can strip request cookies so scenarios can verify sign-in failures without them.
Cucumber step to set cookies in your Capybara session
Set browser cookies in Cucumber feature tests when you need to simulate visitors with existing cookie data across the full application stack.
Capybara 0.3.9 Bug: Chaining .find to scope doesn't work
Chaining find calls in Capybara can ignore the current scope, causing the second lookup to search the whole DOM instead of the intended element.
The Plight of Pinocchio: JavaScript's quest to become a real language - opensoul.org
JavaScript has become essential for production applications, but maintainable code still depends on structured design, object-oriented principles, and test-driven development.
What's in a View? A look at the alternatives
Tradeoffs between progressive enhancement with jQuery-style approaches and client-side views affect interactivity, complexity, and how much rendering stays on the server.
Ruby: Debugging a method's source location and code
Find where a Ruby method is defined and inspect its implementation; Method#source_location reveals file and line, while method_source can return the method body.
Initiate SSL secured TCP connections to remote services
telnet and nc cannot open SSL-secured TCP connections to remote services; openssl s_client can test the connection and handshake.
Chart.js - a promising JavaScript charting library with MIT-license
Lightweight canvas-based charting for web apps with high configurability and broad browser support. A permissive MIT-licensed alternative to Google Charts and commercial libraries.
Comparing Rails' flash hashes will not respect their internal lists of used entries
Rails FlashHash comparisons ignore the internal used-entry state, so two flashes can look equal even when their next-request behavior differs.
Fix „rvm no such file to load -- openssl“ or "rvm no such file to load -- zlib"
Missing system libraries can break RVM Ruby installs, causing no such file to load -- openssl or zlib errors. Reinstalling the required dependencies and recompiling Ruby fixes the issue.