...links. Popular pagination libraries like will_paginate or Kaminari do this for us by simply issuing an extra query, like this: SELECT post.* FROM posts LIMIT 20 OFFSET 100;

...of the time. But rarely, you might have very complicated WHERE conditions or a subquery that takes time to run. In these cases, doing two queries is slower than it...

makandra dev
github.com

The debugger gem does not seem to be properly working on Ruby 2. Use byebug instead! Byebug is a simple to use, feature rich debugger for Ruby 2. It uses...

...new TracePoint API for execution control and the new Debug Inspector API for call stack navigation, so it doesn't depend on internal core sources. It's developed as a...

Running rails server will start a local server that you can access via http://localhost:3000. When you are working on multiple web apps, they will likely set cookies with...

...generic names on localhost. This is annoying, since you will sign out your current user whenever you switch to another app. A better way is to use our own daho.im...

When using jQueryUI's Sortable plugin (either directly or via Angular's ui.sortable), you might struggle testing your nice drag&drop GUI since Selenium webdriver does not support native dragging...

But jQueryUI uses jquery.simulate for their testing, so why shouldn't you? There is even an extension to it that makes testing drag & drop quite easy.

It's generally not trivial to change a datetime's seconds, minutes, etc in SQL. Here is how it works when speaking PostgreSQL. Consider you have a timestamp column whose...

...seconds you want to zero: SELECT born_at FROM users; born_at --------------------- 2015-05-01 13:37:42 You can the TO_CHAR function to convert date or time values...

...message like this, rubygems.org might have issues with their ipv6 connectivity: $ bundle install Fetching source index from https://rubygems.org/ Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch...

...specs from https://rubygems.org/ due to underlying error <timed out (https://rubygems.org/specs.4.8.gz)> The (a little bit dirty) possible solution If that's actually the case, then you can try...

jQuery doesn't store information about event listeners and data values with the element itself. This information is instead stored in a global, internal jQuery cache object. Every time you...

...gets deleted is when you call remove() on the element that put it there! Since cache entries also have a pointer back to the element that spawned them, it is...

In Thunderbird, you can set custom font faces and sizes for reading plain-text e-mails. However, Thunderbird sometimes "randomly" does not respect your choices. This is actually not a...

...some Western (ISO 8859-1), and some maybe yet another encoding. The advanced font settings dialog by default just opens on "Western". Choose a different encoding from the "Fonts for...

Consider this Sass: .comment width: 320px; height: 240px; Any textarea with the comment class will be sized 320 by 240 pixels. In WebKit browsers (Chrome, Safari, ...) or Firefox, this is...

...only the initial size -- users can resize textareas to become bigger. This is helpful to the user, but may be breaking your application layout in some cases.

Variables are colored in the console output You don't need to stringify arguments so the + operator doesn't explode If the variable is a structured object like...

...inside the console and look at its contents Another concise way to write the statement is this: console.log({ foo, bar }); This uses Javascript's new destructuring syntax and is actually...

...exciting" case of auto-loading classes inside a thread which caused the application to stop responding. Rails 4.x ActiveSupport::Dependencies includes logging support. It is easy to use:

...Dependencies.logger = Rails.logger Rails 5+ Logging support was removed for Rails 5. You need to manually patch yourself into the module's code. Here is a dirty solution that works.

...inputs, where one contains the name of the other (eg. Name and Name with special treatment), Capybara's fill_in method will fail with the following message: Ambiguous match, found...

...value = 'Bettertest Cucumberbatch' fill_in(field, with: value, match: :prefer_exact) Furthermore, we recommend setting Capybara's matching strategy globally to :prefer_exact. This will positively affect all you steps...

phrogz.net

...some non-default behavior that you know from other tags. Do not try to style html or body for positioning, width/heigth, or similar. Every browser has its own caveats and...

...you can not test them all. Generally speaking: Use the html tag to define your page's default background color (because on short pages or large screens, your body may...

sslscan is a nice tool to show details about TLS/SSL connections: ~> sslscan some-host-at.makandra.de Testing SSL server some-host-at.makandra.de on port 443 Supported Server Cipher(s): Failed SSLv3 256 bits ECDHE-RSA...

...AES256-GCM-SHA384 Failed SSLv3 256 bits ECDHE-ECDSA-AES256-GCM-SHA384 Failed SSLv3 256 bits ECDHE-RSA-AES256-SHA384 Failed SSLv3 256 bits ECDHE-ECDSA-AES256-SHA384 Rejected SSLv3...

...When your tests involve a Rails test application, your tool's Bundler environment will shadow that of the test application. To fix this, just call unset_bundler_env_vars in...

...a Cucumber Before block. Previously suggested solution Put the snippet below into your tool's features/support/env.rb -- now any command run through Aruba (e.g. via #run_simple) will have a clean...

...Rails 2 applications that use RSpec, so don't upgrade if that is your setup. The rspec-rails gem has a fatal bug that was only fixed for rspec-rails...

...x, which only supports Rails 3. There is no fix for the rspec-rails-1.3.x series of the gem which supports Rails 2. Anyway, here are upgrade instructions if...

makandra dev

...fully integrate your Dropbox account(s) into nautilus (Gnome's file manager) with automatic synchronization. Get the .deb file for your system architecture (32 or 64 bit) from the Linux...

...Install the downloaded package using either the Gnome integration (double-click it) or the shell, e.g.: dpkg -i nautilus-dropbox_?.?.?_amd64.deb Follow the graphical installer (use the custom installation for...

...Sometimes you have search entries in the autocomplete of the address bar, which are higher weighted than your bookmarks. Pressing SHIFT + DEL while searching removes them from the history immediately...

...Sometimes you have search entries in the autocomplete of the address bar, which are all higher weighted than your recently visited sites. Add a search for your history, so you...

...we noticed your project(s) has not accessed or used the YouTube Data API Service in the past 60 days. For reference, your inactive project number is ... While projects do...

...only tell you its (generated) number. But if you use the API Console's search, you won't get any results for project numbers. Also, project numbers are not visible...

stackoverflow.com

I had some problems with Git and the file spec/fixtures/ČeskýÁČĎÉĚÍŇÓŘŠŤÚŮÝŽáčďéěíňóřšťúůýž. After pulling the latest commits, it would show that file as untracked, but adding and committing it would throw...

...unicode fixture file once again' did not match any file(s) known to git. Solution Install Git version > 1.8.2 using homebrew and set git config --global core.precomposeunicode true Done.

developer.mozilla.org

When building a form with a file select field, you may want to offer your users a live preview before they upload the file to the server. HTML5 via jQuery...

...Luckily, HTML5 has simple support for this. Just create an object URL and set it on an tag's src attribute: $('img').attr('src', URL.createObjectURL(this.files[0])) Unpoly Compiler

...Use Before and After to avoid that. Details Consider this Cucumber feature file: Feature: Something that needs to be tested Background: Given a user And I sign in Scenario: Sign...

When I sign out Then I should see "Signed out" Scenario: Something else # ... Now, assume you have these step definitions: Around do puts "** Around: before yield" yield puts "** Around...

...that happens on your local machine Manually remove the offending's gem files and specifications. The paths will be something like /usr/lib/ruby/gems/1.8/gems/your-broken-gem and /usr/lib/ruby/gems/1.8/specifications/your-broken-gem Update Rubygems or Slimgems by running...

...gem update --system Run bundler on your project to reinstall the offending gem. If this happens to your during deployment Ask your operations team to do it. After the update...

joshmcarthur.com

...to those fields that is case-insensitive. The model looked like this: create_table :shop_locations do |t| t.string :street t.string :house_number t.string :zip_code t.string :city t.belongs_to...

end But how to solve the uniqueness problem? Another day, another undocumented Rails feature! This time, it’s that ActiveRecord::Base.connection.add_index supports an undocumented option to pass a...