makandra dev

Bundler allows you to specify the name of the Gemfile you want to bundle with the BUNDLE_GEMFILE environment variable. BUNDLE_GEMFILE=Gemfile.rails.7.2 bundle By default, bundler will look...

...have multiple Gemfiles in your project, which cannot all be named Gemfile. Let's say for example, you maintain a gem and want to run automated tests against multiple rails...

Native promises have no methods to inspect their state. You can use the promiseState function below to check whether a promise is fulfilled, rejected or still pending: promiseState(promise, function...

// `state` now either "pending", "fulfilled" or "rejected" }); Note that the callback passed to promiseState will be called asynchronously in the next microtask. Usage example: Tests Note Since this card...

makandra dev

This is for people recovering from Subversion. Get an existing from the server for the first time git clone git@example.com:repositoryname See what's changed git status Check in locally...

...git commit -m "good description" Push local commits to the server git push Get and merge updates from the server git pull Stage a file for the next local commit...

...multiple custom ways to format Dates or DateTimes. This often leads to duplicated format strings, wrong formats and unnecessary introduction of new formats. to_fs also supports to refer to...

...those formats by name e.g. to_formatted_s(:iso_8601) or to_formatted_s(:short). to_fs is an alias for to_formatted_s. Those names are defined in Time...

...to run JS tests. Given a Vue project that uses Jest (via vue-cli-service) with the following package.json: { "scripts": { "test": "vue-cli-service test:unit --testMatch='**/tests/**/*.test.js' --watch...

...allows us to run Jest tests with yarn test. The only downside of this setup is that debugger statements are ignored with the CLI approach - there are no Browser Devtools...

unpoly.com

Version 3.7.0 broke some things in complex forms. Sorry for that. Concurrent user input is hard. 3.7.1 This change fixes two regressions for form field watchers, introduced by 3.7.0:

...a validation for a fragment while a validation request for the same target is still loading. Validations no longer throw an error if a targeted fragment is destroyed while a...

...with additional margin towards their container. Starting with version 121, Chrome now also supports the spec-compliant properties scrollbar-width and scrollbar-color. These allow less styling. You may only...

...track and thumb colors, and a non-specific width like auto, thin, or none. .example { scrollbar-width: thin; scrollbar-color: blue lightblue; } Styling the -webkit-scrollbar-* pseudo elements is still...

JavaScript objects can have getter and setter functions that are called when a property is read from or written to. For example, if you'd like an object that has...

...person.firstName and person.lastName: var person = { firstName: 'Guybrush', lastName: 'Threepwood', get fullName() { return this.firstName + " " + this.lastName; }, set fullName(name) { var parts = name.split(" "); this.firstName = parts[0]; this.lastName = parts[1]; } }; The code below shows...

Ctrl + Alt + S > search "rubocop on save" Under "Inspections", check the highlighted box on rubocop -a Caveat: This adds a little time overhead to saving. When you're editing many...

...bodies with a maximum of 4096 characters. You can work around that limit by splitting the text into smaller fragments and stitch together the resulting mp3 files with a CLI...

...tool like mp3wrap or ffmpeg. Example Ruby Implementation Usage input_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...

In order to have monitoring for Sidekiq (like queue sizes, last run of Sidekiq) your application should have a monitoring route which returns a json looking like this: { "sidekiq": {

...queue_sizes": { "dead": 0, "retries": 0, "monitoring": 0, "low_priority": 0, "mails": 0, "default": 0, "elasticsearch": 0, "high_priority": 0, "file_upload": 0, "scheduled": 0 }, "active_workers": 0 }, "timestamps": {

When you need to store structured data (like Ruby hashes) in a single database column with ActiveRecord, a simple way is to use PostgreSQL's jsonb columns. ActiveRecord will automatically...

...serialize and deserialize your Hash to and from JSON, and you can index JSON paths for fast reads. As an alternative, ActiveRecord::Store offers a way to store hashes in...

Boot partitions from installations prior to the 16.04 era are terribly small. When you install updates and encounter errors due to a full /boot partition, consider risizing it.

...can't do the steps described below, ask someone experienced to help you out. This has worked 100% so far. 1 out of 1 tries. ;) Scenario A: There is unassigned...

Plot graphs in Ruby WebGraphviz renders in your browser via JavaScript (to store the rendered graph, extract the SVG using your browser's DOM inspector) GraphViz with DOT: Online...

...graphviz.christine.website/ or offline https://makandracards.com/makandra/1589-auto-generate-state_machine-graphs-as-png-images Balsamiq Draw.io Excalidraw Asciiflow Google Presentation Egon.io: Domain storytelling with replay functionality (good to visualize and present flows) Gnuplot Ruby Bindings: Especially for more...

makandra dev
github.com

If you want to build a small CLI application, that supports more advanced inputs than gets, I recommend using the cli-ui gem. It's a small dependency-free library...

...that provides basic building blocks, like an interactive prompt: require "cli/ui" CLI::UI::StdoutRouter.enable puts CLI::UI.fmt "a small {{red:demo}}" # supports h, j, k, l, arrows and even filtering...

In Rails 3.1+, instead of defining a separate up and down method you can define a single method change: class AddComparisonFieldsToReport < ActiveRecord::Migration def change add_column :reports, :compare, :boolean...

...update "UPDATE reports SET compare = #{quoted_false}" add_column :reports, :compare_start_date, :date add_column :reports, :compare_end_date, :date end end Migrating up works as expected:

Note: You won't need this for single lines of text. In this case it is better to just use the text-overflow property: Use CSS "text-overflow" to truncate...

...use -webkit-line-clamp in your CSS/SASS to natively render an ellipsis (...) after a specific amount of lines for a multi-line text in your HTML. Earlier, it was necessary...

...not possible to use variables in media queries with plain CSS. @media (max-width: var(--some-pixel-size)) {...

...} /* Does not work */ Postcss Plugin If you're using PostCSS to postprocess...

...your CSS, you can configure postcss-custom-media and add this feature: @custom-media --small-variable-name(max-width: 968px); @media (--small-variable-name) {...

Note The plugin does not...

A recent patch level Ruby update caused troubles to some of us as applications started to complain about incompatible gem versions. I'll try to explain how the faulty state...

...care of a few things: The new Ruby version is installed The Bundler version stated in the Gemfile.lock is installed Geordi is installed (for database dumps) The gems of the...

tenderlovemaking.com

...are usually believed to have worse performance than those defined via def. Hence, developers sometimes prefer using class_eval to define methods using def, like this: class_eval "def #{attribute...

...for_realsies?; do_things; end" You can benchmark methods defined like this and will see that those defined via def actually do perform better. Basically, it ranks like this:

...version understands? Did you double-check your @font-face declarations with all the hacky syntax that is required? Compare them with other declarations you find on the web.

...same name? This usually leads to trouble, but there are workarounds. Do IE's security settings prevent the download of webfonts? (see below) IE Security Settings can prevent font download...

When giving a presentation where you do some coding, the font size you usually use is probably a bit too small and makes code hard to read for users on...

...smaller screens or low-bandwidth connections when the image quality is lower. Here are two solutions. Presentation Mode RubyMine offers a "Presentation Mode" which you can use. Simply navigate to...

...a new callback to your model that (e.g.) caches some data when it is saved. Now you need to run that callback for the 10000 existing records in the production...

Write a clever migration, possibly by embedding the model into the migration script. Open the Rails console after deployment and re-save every single record. You should probably...

github.com

When internationalizing your Rails app, you'll be replacing strings like 'Please enter your name' with t('.name_prompt'). You will be adding keys to your config/locales/*.yml files over...

...the right place is a challenging task. The gem i18n-tasks has you covered. See its README for a list of things it will do for you. Note