IRB 1.2 (shipped with Ruby 2.7, but works on 2.5+) brings pretty syntax highlighting and multiline cursor navigation. However, pasting longer contents is incredibly slow. You can fix that by...

...disabling said features. [1] Ruby 3.0.0-pre2 solved the issue (however, the fix does not appear to be included in IRB 1.2.6, it must be Ruby itself). Option 1:

accepts_nested_attributes_for :invoice_items, :allow_destroy => true # the critical code 1/2 before_save :calculate_and_store_amount # the critical code 2/2 private def calculate_and_store...

accepts_nested_attributes_for :invoice_items, :allow_destroy => true # the critical code 1/2 before_save :calculate_and_store_amount # the critical code 2/2 private def calculate_and_store...

...and times incomparisons, mind to not compare datetimes with date ranges in MySQL. Visualisation 1. ------- ------- AAA AAA BBB BBB ------- ------- 2. ------- AAA B ------- 3. ------- A BBB ------- 4. ------- AAA BBB ------- 5. -------

As mentioned above, the esbuild_error_development.txt file must exist for Guard to watch it. [1] Sadly, Git does not offer a way to add a file and ignore further changes...

...esbuild, and break stuff. You should see error messages be delivered by your application. [1] Side note: Our implementation of the controller module also expects the file to exist. If...

...the application again. How can we invalidate old session cookies on logout with Devise? 1) Reset password The only option provided per default by Devise is to change the password...

...the commit I want to fixup: alias fixup='git log --oneline | fzf | awk '\''{print $1}'\'' | xargs -I '\''{}'\'' git commit --fixup {}' After you have used fixup you still will have run...

github.com

...Add this line to your application's Gemfile: gem 'capistrano', '~> 3.0' gem 'capistrano-maintenance', '~> 1.0' Add this line to you application's Capfile: require 'capistrano/maintenance' Enable task Present a maintenance...

...specifying the REASON and UNTIL environment variables: cap maintenance:enable REASON="hardware upgrade" UNTIL="12pm Central Time" You can use a different template for the maintenance page by setting the...

makandra dev

There are multiple ways to redirect URLs to a different URL in Rails, and they differ in small but important...

index = 0 User.find_each do |user| printf("Progress: %.2f%%\r", index.to_f / count * 100) user.update!(role: 'member') index += 1 end

stackoverflow.com

...newIndex > -1 && newIndex < array.length) { // Remove the element from the array const removedElement = array.splice(index, 1)[0] // At "newIndex", remove 0 elements and insert the removed element array.splice(newIndex, 0, removedElement...

...negative to move towards the beginning): const list = [object1, object2, object3] moveArrayElement(list, object2, 1) // list => [object1, object3, object2] moveArrayElement(list, object2, -2) // list => [object2, object1, object3]

...Power.new(build(:user)) Power.with_power(power) do expect(power).to receive(:buildings).at_least(1).time.and_return [building, other_building] expect(build(:unit)).to allow_association_values(building, other_building...

...assignable_values generates: ... Power.with_power(power) do expect(power).to receive(:buildings).at_least(1).time.and_return [building, other_building] unit = build(:unit) expect(unit.assignable_buildings).to contain_exactly(building...

makandra dev

...have a reference to their parent uploader class DemoUploader < CarrierWave::Uploader::Base process :resize # 1 before :cache, :do_something # 3 version :thumb do # 2 process :crop end private

...with Selenium and Capybara despite these issues. Both have different advantages and drawbacks. Method 1: Inspecting the file without navigation There are ways to download and inspect a file without...

features/support/download_helpers.rb # This is an adapted approach from # https://collectiveidea.com/blog/archives/2012/01/27/testing-file-downloads-with-capybara-and-chromedriver module DownloadHelpers TIMEOUT = 10 module_function def download_path download_path = Rails.root.join("tmp/test_downloads#{ENV['TEST_ENV_NUMBER']}") FileUtils.mkdir_p...

...you will only synchronize changes from hour 6-29, but forget changes from hour 1-4. Instead your cronjob should remember the last time a sync was performed successfully, and...

Ubuntu 18.04 uses systemd to manage services. There are basically two commands for listing all services and manipulating the state of a certain service: service and systemctl: service manages System...

...overrides LSB defaults (2 3 4 5). insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `bluetooth' overrides LSB defaults (0 1 6).

...mx), but set config.not_rfc_mx_lookup_flow = true. Validation methods explained Regex validation (1) is pretty straight-forward and basically "free" since you're not making and network connections...

...all known emails from a production application with a very "typo-heavy" user base (108k+ emails with 5.2k+ unique domains) and found no false positives. So I suggest you...

...hello', 'universe'].each_with_index do |value, index| puts "#{index}: #{value}" end # 0: hello # 1: universe This also works on hashes. However, mind the required syntax: { hello: 'universe', foo: 'bar...

...with_index do |(key, value), index| puts "#{index}: #{key} => #{value}" end # 0: hello => universe # 1: foo => bar The reason is that each_with_index yields 2 elements to the block...

...the mocked property is a simple value, it will not work: const x = { foo: 1 } console.log(x.foo) // 1 spyOnProperty(x, 'foo').and.returnValue(2) // Throws: Error: : Property foo does not have...

...can be mocked with Jasmine. You can use it like this: const x = { foo: 1 } console.log(x.foo) // 1 spyOnValueProperty(x, 'foo').and.returnValue(2) expect(x.foo).toBe(2)

...Enumerator for chaining with other methods: Person.find_each.with_index do |person, index| person.award_trophy(index + 1) end Ruby's map with index Similarly, you may need an index when using other...

...Here is an example for map: people.map.with_index do |person, index| person.at_rank(index + 1)

...something like: Unable to find visible checkbox "Some label" that is not disabled Solution 1 Use the keyword argument allow_label_click: true within the method call.

...environment. Depending on your CSS framework you also need to adjust the z-index: 1. [data-environment=test] input

...effect that you can not configure Psych#dump to only write safe data. Pitfall 1: Psych::DisallowedClass Psych#safe_load only whitelists the following classes: TrueClass, FalseClass, NilClass, Numeric, String...

...optimize the result. time = Time.now data = {foo: time, bar: time}.to_yaml => => "---\n:foo: &1 2019-11-08 11:28:34.834180510 +01:00\n:bar: *1\n" ::YAML.safe_load(data...

...might want to validate the MIME type in addition to the name extension. Solution 1 The solution you will see most often is that the model that has a Carrierwave...

makandra dev

...Advanced configuration It is helpful to set the global git config git config status.submodulesummary 1. This will add a short summary of the commits in the git submodules. Example:

...config status.submodulesummary 1 $ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add ..." to update what will be committed...

raise ArgumentError, "Unknown type #{type}" end end end pretty_print_redis(Redis.new(host: "10.0.1.1", port: 6380, db: 15...