github.com

...default it allows only accessing visible elements -- when you are using a driver that supports it (e.g. Selenium, not the default Rack::Test driver). Consider the following HTML: One

...true) or find(..., visible: :visible). Note that you could change the default behavior by setting the ignore_hidden_elements config option. However, ignoring invisible elements is a useful default.

...just barely wider than the container it should fit into, and it wraps a single word to a new line and it's not really pretty? Cry no more, for...

...in some browsers. When browsers encounter a text-wrapping element with text-wrap: balance style, they will try breaking to a new line sooner, if it balances out the width...

...tough challenge. To get more detailed insights consider using the rack-mini-profiler gem. Setup with Unpoly Add the following gems: group :development do gem 'memory_profiler' gem 'rack-mini...

If you have slow views (Haml/Partials can be slow), consider caching them. Remove code & sql-queries that are not needed to render the page. Calling to_a blindly on...

GoodJob and ActiveJob rescue exceptions internally, preventing exception_notification from triggering. This can cause silent job failures.To get notified, subscribe to ActiveJob events and configure GoodJob's on_thread_error...

...job failures, as they are handled internally by ActiveJob/GoodJob. ActiveSupport::Notifications.subscribe(/(enqueue_retry|retry_stopped|discard)\.active_job/) do |event_name, *, payload| exception = payload[:error] job = payload[:job]

Modern CSS offers the field-sizing property to allow elements to automatically adjust size (width and/or height) to fit their contents. The most common use case are textareas which start...

...fairly small (e.g. 2 or 3 rows tall) but grow when users enter longer text. Usage textarea { field-sizing: content; } That's it! At least in modern Chromium-based browsers...

makandracards.com

...bug) and want to use git bisect to find out when it was introduced? Smart kid. If you have a shell command ready to reveal if your current state is...

...other hand will use the return value of that call to decide if the state is good or bad. First, start bisecting git bisect start Then tell git which revisions...

If you want to switch to another ruby versions, you have several options, depending on what you want: Do you want to switch temporarily, per project, or globally?

Unlike RVM, rbenv does not offer a command like rvm use. By default, it respects your project's .ruby-version file. If you need to change manually...

...the commit which was deployed. If you want to know the currently deployed release, simply SSH to a server and view that file. $ cat /var/www/my-project/current/REVISION cf8734ece3938fc67262ad5e0d4336f820689307 Capistrano task

...application is deployed to multiple servers, you probably want to see a result for all of them. Here is a Capistrano task that checks all servers with the :app role...

developer.mozilla.org

You can do so much more than console.log(...)! See the attached link for a great breakdown of what the developer console can give you. Some of my favorites: console.log takes...

E.g. console.log("Current string:", string, "Current number:", 12) Your output can have hyperlinks to Javascript objects E.g. console.log("Check out the current %o, it's great", location)

github.com

Capybara-screenshot can automatically save screenshots and the HTML for failed Capybara tests in Cucumber, RSpec or Minitest. Requires Capybara-Webkit, Selenium or poltergeist for making screenshots. Screenshots are saved...

...into $APPLICATION_ROOT/tmp/capybara. Manually saving a page Additionally you can trigger the same behavior manually from the test using Capybara::Session#save_and_open_page and Capybara::Session#save_screenshot...

makandra dev

Geordi provides a pretty neat way to generate beautiful commit messages according to your stories in Linear: geordi commit Geordi reads from a .geordi.yml file inside your repo and connects...

...to Linear to list started and finished stories with their title. Choosing one of them generates a commit message including id and title from Linear app and a link to...

While it might seem trivial to implement an invoice that sums up items and shows net, gross and vat totals, it actually involves a lot of rules and caveats. It...

...examples in Ruby and MySQL, the concepts apply to all programming languages and data stores. When to round There are exactly two spots where your invoice logic should round money...

When your Rails application server raises error, Capybara will fail your test when it clears the session after the last step. The effect is a test that passes all steps...

...behavior will help you to detect and fix errors in your application code. However, sometimes your application will explode with an error outside your control. Two examples: A JavaScript library...

...want to be in there. In order to reduce the chance to accidentally commit something you didn't intend, review your changes before committing. My preferred way of doing this...

...paths (including new files), but not their contents git add -p Git will now show you all your changes in small chunks and ask you in an interactive mode whether...

stackoverflow.com

When you use method_missing to have an object return something on a method call, always make sure you also redefine respond_to_missing?. If you don't do it...

def method_missing(method_name, *args, &block) if method_name == :bark 'woof!' else super end end end This will allow you to say: Dog.new.bark => "woof!" But: Dog.new.respond_to? :bark...

makandra dev
rubydoc.info

CarrierWave comes with some RSpec matchers which will make testing more comfortable. Let's say you have an Uploader like this: class MyUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick

...different versions of your uploaded files: version :small do process resize_to_fill: [100, 100] end version :medium do process resize_to_fit: [200, nil] end version :large do

Since I use this a lot in my daily work and there were no scripts working properly for me, I made one myself. It's actually not bound to Xfce...

...t tried it, though). Installation If you don't yet have xdotool, install it: sudo apt-get install xdotool If you don't yet have wmctrl, install it:

makandra dev

...or ::1 (IPv6) can only be reached from your own PC: Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process tcp LISTEN...

...address 0.0.0.0 can be reached from other PCs on your network: Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process tcp LISTEN...

You can change which branches will be pushed when saying git push. Our recommendation is to set it to current. From the git-config documentation: push.default Defines the action git...

...branch, but forgot to setup tracking. If you can't currently push, use git branch --set-upstream-to=origin/$(git branch --show-current...

makandra dev

git shortlog -s -n [commit-range] -n, --numbered Sort output according to the number of commits per author -s, --summary Suppress commit descriptions, only provide commit count [commit-range]

...tagname.. for "everything after that tag" Example output for spreewald: 60 Tobias Kraze 12 Henning Koch 7 Dominik Schöler 6 Thomas Eisenbarth 5 Martin Straub 3 Minh Hemmer...

guides.rubyonrails.org

ActiveRecord offers an explain method similar to using EXPLAIN SQL statements on the database. However, this approach will explain all queries for the given scope which may include joins or...

Output will resemble your database's EXPLAIN style. For example, it looks like this on MySQL: User.where(id: 1).includes(:articles).explain EXPLAIN for: SELECT `users`.* FROM `users`  WHERE...

relishapp.com

In RSpec you can tag examples or example groups with any tags you like simply by saying describe ReportCreator, slow: true do # .. end describe ReportCreator do it 'generates reports', slow...

# ... end end You can then only run examples with these tags. rspec --tag slow rspec -t slow # Using the parallel_tests gem rake "parallel:spec[,,--tag slow]"

makandra dev

...an event handler, there are multiple methods to cancel event propagation, each with different semantics. event.preventDefault() Only prevents the default browser behavior for the click, i.e. going to a different...

...url or submitting a form. When invoked on a touchstart event, this also prevents mouse events like click to be triggered. event.stopPropagation() Prevents the event from bubbling up the DOM...

This is a small example on how you can check if your Postgres index can be used by a specific query in you Rails application. For more complex execution plans...

...it might still be a good idea to use the same path of proof. 1. Identify the query your application produces query = User.order(:last_name, :created_at).to_sql