3750 cards

How to migrate CoffeeScript files from Sprockets to Webpack(er)

If you migrate a Rails application from Sprockets to Webpack(er), you can either transpile your CoffeeScript files to JavaScript or integrate a CoffeeScript compiler to your new process. This checklist can be used to achieve the latter.

  1. If you need to continue exposing your CoffeeScript classes to the global namespace, define them on window directly:
-class @User
+class window.User
  1. Replace Sprocket's require statement with Webpacker's import statement to load dependencies.
-#= require ./person
+import './perso...

Whenever: Using the runner command with Rails 2

Recent versions of whenever are basically compatible with Rails 2. However, the runner job type expects a rails runner command and out-of-the-box fails on Rails 2.

every :day, at: '00:05 am' do
  runner 'Util.perform!

To get this working on Rails 2, you need to redefine the runner job type by putting this line to the top of config/schedule.rb:

job_type :runner, 'cd :path && :environment_variable=:environment bundle exec script/runner ":task"'
Linked content

The State of Ruby 3 Typing | Square Corner Blog

We're pleased to announce Ruby 3’s new language for type signatures, RBS. One of the long-stated goals for Ruby 3 has been to add type checking tooling. After much discussion with Matz and the Ruby committer team, we decided to take the incremental step of adding a foundational type signature language called “RBS,” which will ship with Ruby 3 along with signatures for the stdlib. RBS command line tooling will also ship with Ruby 3, so you can generate signatures for your own Ruby code.

Ruby 3 is coming, and it will have optional type sign...

Geordi 4 released

4.0.0 2020-07-30

Compatible changes

  • Improved documentation; README now includes command options.
  • Improvement #90: geordi console, geordi deploy, geordi rake and geordi shell now work correctly if the project hasn't been bundled before

Breaking changes

  • Removed deprecated executables

sentry.io: Filter events by environment

For projects that do not have a separate account for separate environments you can simply filter the events for your current environment in the search bar by typing environment:production. IMHO it's better to have a separate project per ENV in order not to have to filter all the time.

Linked contentRepeats

Ag: Very fast grep replacement

Ag (aka "the silver searcher") is a very fast replacement for grep.

It will parse your .gitignore for additional speedup. To ignore even more files (node_modules, *.min.js etc), add an .agignore with syntax identical to .gitignore.

On Ubuntu 14.04, don't install via apt-get, but build from source to get a current version.

See Faster Grepping in Vim for hints about vim integration.

Linked contentRepeats

Verifying doubles in RSpec 3

RSpec 3 has verifying doubles. This breed of mock objects check that any methods being stubbed are present on an instance of a given class. They also check methods aren't called with the wrong number of arguments.

This dual approach allows you to move very quickly and test components in isolation, while
giving you confidence that your doubles are not a complete fiction.

You should always prefer using a verifying double to using an old-...

Linked contentAuto-destruct in 59 days

ActiveType 1.4.0 released

Extended records now use their own I18n namespace when looking up translations for models or attributes. If the extended record's namespace does not contain a translation, the lookup will fall back to the base record's namespace.

For instance, given the following class hierarchy:

class User < ActiveRecord::Base

class User::Form < ActiveType::Record[User]

The call ExtendedParent.human_attribute_name(:foo) would first look up the key in activerecord.attributes.user/form first, then falls back to `activerecord.attributes...

Linked content

Introducing GoodJob 1.0, a new Postgres-based, multithreaded, ActiveJob backend for Ruby on Rails

GoodJob is a new background worker gem. It's compatible with ActiveJob.

We're huge fans of Sidekiq for its stability and features. One advantage of GoodJob over Sidekiq is that GoodJob doesn't require Redis. So in cases where you don't have Redis or don't want to pay for a Redis HA quorum node, this might be an alternative worth checking out.

Linked content

Fixing wall of warnings: already initialized constant Etc::PC_SYMLINK_MAX

These warnings are printed when the etc Gem is installed, while etc is also included in Ruby. Fix with:

gem uninstall etc

How to create giant memory leaks in AngularJS (and other client-side JavaScript)

This guide shows how to create an AngularJS application that consumes more and more memory until, eventually, the browser process crashes on your users.

Although this guide has been written for Angular 1 originally, most of the advice is relevant for all client-side JavaScript code.

How to observe memory consumption

To inspect the amount of memory consumed by your Javascripts in Chrome:

  • Open an incognito window
  • Open the page you want to inspect
  • Press Shift + ESC to see a list of Chrome processes...

Concurrency issues with find-as-you-type boxes

Find-as-you-type boxes are usually built by observing changes in a text field, and querying the server via AJAX for search results or suggestions when the field has changed.

A common problem with this implementation is that there is no guarantee that AJAX responses are evaluated in the same order as the original requests. The effect for the user is that the search results are flashing back and forth while the user is typing the query, and when the user has stopped typing the last results don't always match the final query.

You won't notice...


MySQL: CONCAT with NULL fields


CONCAT('foo', 'bar', NULL) = NULL

the NULL always wins in MySQL.

If you would rather treat NULL as an empty string, use CONCAT_WS (concatenation with separator) instead:

CONCAT_WS('', 'foo', 'bar', NULL) = 'foobar'


In PostgreSQL the NULL is not viral in CONCAT:

CONCAT('foo', 'bar', NULL) = 'foobar'

Sentry: Different ways of deferring notifications for an issue

We use Sentry to be informed about different kinds of issues. One of the key features is that you are not getting spammed if many errors of the same kind occur in a small timespan.
If an issue pops up the usual workflow is to fix the code and mark the issue as "resolved" in Sentry. Only new or resolved issues trigger another email notification when they are proxied through Sentry.

This workflow does not fit well for issues we cannot fix, e.g. when consuming an external API that is sometimes down. In such cases you ...

Auto-destruct in 41 days

Geordi 3.2.0 released

Compatible changes

  • Improvement #43: --select-server option on geordi shell and geordi console can take the number of the server to connect to it directly and to skip the menu. Example: geordi con production -s4
  • Unified Geordi configuration:
    • Add a .geordi.yml file to change multiple settings in the project and ~/.config/geordi/global.yml for global settings.
    • Deprecated the .pt_project_id file in favor of .geordi.yml.
    • Deprecated the ~/.gitpt file in favor of ~/.config/geordi/global.yml.
  • Add #91: Now there is an op...

HTML forms with multiple submit buttons

Most forms have a single submit button that will save the record when pressed.

Sometimes a form needs additional submit buttons like "accept" or "reject". Such buttons usually attempt a state transition while updating the record.

To process a form with multiple buttons, your server-side code will need to know which button was pressed. To do so you can give each submit button a different [formaction] attribute. This will override the ...

Git: Merge a single commit from another branch

This is called "cherry-picking".

git cherry-pick commit-sha1

Note that since branches are nothing but commit pointers, cherry-picking the latest commit of a branch is as simple as

git cherry-pick my-feature-branch

Be aware that cherry-picking will make a copy of the picked commit, with its own hash. If you merge the branch later, the commit will appear in a history a second time (probably without a diff since there was nothing left to do).

Also see our advice for [cherry picking to production branches](https://makandraca...


Automatically validating dependency licenses with LicenseFinder

Open-source software (OSS) is great. Anyone can use virtually any open-source code in their projects.

Well, it depends. Licenses can make things difficult, especially when you are developing closed-source software. Since some OSS licenses even require the employing application to be open-sourced as well (looking at you, GPL), you cannot use such software in a closed-source project.

To be sure on this, we have developed a project-level integration of Pivotal's excellent [license_finder](https://g...

This website uses short-lived cookies to improve usability.
Accept or learn more