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

This card needs to be updated for Rails 3+. Since there is no --debugger flag you need to run:

When working with feature branches, stale branches pile up over time. It's best to remove them right after merge, locally and on the remote, but it is a little...

if [[ "$merged_branch_name" =~ ^(master|main|production|Fast-forward)$ ]]; then exit 0 fi # Begin output echo " " echo "> You have just merged the branch \"$merged_branch_name\" into \"$branch_name...

...ms have passed!') }, function(reason) { console.error('Something went wrong: %o', reason) } ) This will become more important when we talk about async/await later. Exceptions are converted within then() handlers function fetchUsers...

} If f1() and f2() have an async API, our control flow must become async: function f1() { return Promise.resolve(2) } function f2(x) { return Promise.resolve(x * x) }

...instead of downloading and bundling font files yourself. (See below for a list of benefits.) Usage Go to fontsource.org and search for the font you want to add (or a...

...s Fontsource details page for available settings. Why? Using an NPM package has some benefits over placing fonts into your repo: All font weights and glyphs are included.

...notification service: Use @Input() id: number with component input binding; Update notification.service.ts: Define notification$: BehaviorSubject: Store the last fetched notification; Update notification$ when a new notification is fetched; Using Efficient...

...keywords in your prompts. LLMs excel at pattern recognition, and specific terminology reduces ambiguity. Beyond that giving examples for high level APIs of your imagened class design or using an...

TL;DR When using Cache-Control on a Rails application, make sure the Vary: Accept header is set.

Ubuntu might create several keyrings for you. Note that keyring passwords are initially set to the user password but do...

...users". The red area corresponds to the records in the resulting scope. # NAND: Default behavior for Hash with multiple attributes # Excludes only users who are BOTH admins AND trashed. User.where.not...

...points to an Array of values, Rails applies standard SQL NOT IN logic. This behaves effectively as a NOR condition relative to the values in the array (neither A nor...