Once Rails knows a given string is html_safe, it will never escape it. However, there may be times when...

makandra dev
gist.github.com

...byebug commands, it comes in handy with it's features for many use cases beyond that to make your life easier. For this cheatsheat I tried to structure the most...

...instance_methods(false). method -- The same as running .methods. Commands to change (or add) behavior at breakpoints display / undisplay [ ] - display or undisplays an expression at stopped breakpoint enable / disable [id...

This card existed before, but was outdated due to browser implementation changes. The information below is validated for the current...

...if .second-item could be rendered smaller without problems or has because you defined behavior for it. +---------+--------------------------------------+ | | - 1000 characters looooooooooooong | | +---------+--------------------------------------+ Try it on CodePen. There are two ways to fix...

...may just set overflow: hidden or maybe on .second-item and/or add some overflow behavior and you're done. In some cases, this might not be the solution because the...

...tells rails how to build the path correctly is a single slash at the beginning of the path: <%= javascript_include_tag('ckeditor/config') %> # for assets/ckeditor/config.js <%= javascript_include_tag('/ckeditor/ckeditor') %> # for public/ckeditor/ckeditor.js...

github.com

For Sidekiq to be able to retry your jobs it has to be able to catch errors that occur while...

stackoverflow.com

From Rails 3.0.9, there is a method Hash#to_query that will turn a Hash into a query string:

...Rails code is doing the delivery you can do your usual authentication and authorization beforehand. There are few exceptions where you want to store confidential files in the public folder...

blog.jayfields.com

Deprecated ways to execute shell code in Ruby This is just a reference for legacy code. For new code, always...

Lets say you need to make a change to a commit OLD_COMMIT, but this is not the most recent...

...with power comes responsibility. Code comments can go wrong in many ways: they may become outdated, silently move away from the code they're referring to, restate the obvious, or...

...a comment, prefer improving the code: use descriptive variable/method names, extract more variables/methods to better describe what is happening, have a simple structure. However, there are things code cannot express...

makandra dev

# Step 1: Native VIPS find_trim for the tightest bounding box begin content_left, content_top, content_width, content_height = image.find_trim(threshold:) rescue Vips::Error return # Blank...

...trimmed_image.crop(0, content_start_y, content_width, content_end_y - content_start_y + 1) begin # Run a second pass of find_trim to tighten up any newly exposed whitespace inner...

...The bash functions above are only an iteration from my previous bash alias. It became quite unreadable over time and and copies the raw XML to the clipboard (not files...

...confident about upgrading Rails, have a look at Rails LTS. How many update steps? Besides the Rails upgrade itself, you might also want to upgrade your other gems and upgrade...

...many cases updating to the highest subversion of the specific rails version is the best choice (e.g. when updating to rails 5 you would update to 5.2.8.12), since the most...

When Paperclip attachments should only be downloadable for selected users, there are three ways to go. The same applies to...

You can chain multiple Capybara matchers on the page or any element: expect(page) .to have_content('Example Course')

In order to navigate through the browser history. you can manipulate the window.history object via javascript like follows:

In a JavaScript console, type this: > 9112347935156469760 9112347935156470000 Ooops. And that's not a float! This occurs because JavaScript uses...

...would hand you UTC objects whose to_s(:db) may not convert properly. Legacy behavior in Rails 2.3 It's been briefly mentioned in the random list of ActiveSupport goodies...

blog.bigbinary.com

...joined tables or multiple queries? If you don't like the cleverness of this behavior, you can explicitely tell ActiveRecord how to preload associations with either JOINs or separate queries...

...includes usually works nicely, but Rails will apply some magic, as mentioned at the beginning of this card. This is subject to issues with polymorphic associations, too...

Setting the colorbox opacity by hash parameter when initializing doesn't work the way like the documentation tells you.

pdfposter.origo.ethz.ch

Pdfposter is a Python script that allows to convert large PDFs into a PDF with multiple pages that can be...

...hard to understand, the helpers available differ for different versions of Rails and the behavior is subtly different. Make sure you read and understand the API before using these...

...Haml maintainer, this negatively impacted rendering performance. So in Haml 6, they kept this behavior only for a few attributes, which they called "boolean". All other attributes will just render...

...their value as it is given. Behavior of "boolean attributes" remains unchanged No Haml value => no HTML value Boolean Haml value => attribute is rendered depending on that value