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

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).

...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)

...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...

...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...

...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...

...you may encounter this error: Copying required WAL segments. EXCEPTION: {'ret': 2, 'err': '/bin/sh: 1: cannot open /var/lib/barman/foopostgres/wals/00000007.history: No such file\n', 'out': ''} The reason is that the barman backups...

...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)

...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...

...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

...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...

...running) since Wed 2022-11-23 09:25:09 CET; 7min ago Main PID: 18344 (openssl) Tasks: 1 (limit: 4915) CGroup: /system.slice/run-benchmark.service └─18344 /usr/bin/openssl speed # Get the logs $ sudo journalctl...

...u run-benchmark.service -- Logs begin at Mon 2022-03-07 13:45:18 CET, end at Wed 2022-11-23 09:31:33 CET. -- Nov 23 09:25:09 server systemd...

...Ruby 2.7 introduced a method for this exact purpose: filter_map. So instead of >> [1, 2, 3, 4, 5, 6].map { |i| i * 2 if i.even? }.compact

>> [1, 2, 3, 4, 5, 6].select(&:even?).map { |i| i * 2 } => [4, 8, 12] you can just do >> [1, 2, 3, 4, 5, 6].filter_map { |i| i...

uri = URI.parse(path) if allow_fuzzy_expiry expires_at = expires_at.end_of_hour + 1 end timestamp = expires_at.localtime.strftime('%Y%m%d%H%M%S') # this is similar to an hmac...

stackoverflow.com

...Explicit conversion Explicit conversion happens when requesting it, e.g. with the splat operator: args = [1,2,3] some_method(*args) # Ruby calls args.to_a here Implicit conversion Implicit conversion happens...

makandra dev

...log --oneline | fzf --prompt 'Select the first commit you want to move' | awk '{print $1}') branch=$(git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/ | fzf --prompt 'Select the...

...branch to rebase onto' | awk '{print $1}') test_command="git rebase -i --onto $branch $commit~" read -p "Execute command '$test_command' (Y/n)? " choice case "$choice" in n|N ) echo "aborted...

manpages.ubuntu.com

...run-this-one is exactly like run-one, except that it will use pgrep(1) and kill(1) to find and kill any running processes owned by the user

Cookies without an expiration timestamp are called "session cookies". [1] They should only be kept until the end of the browsing session. However, when Chrome or Firefox are configured to...

...for quite a while now and it seems they won't change their mind. [1] We are not talking about the the Rails session cookie here, though it often is...

...a dependency of cucumber-rails), which will break all your tests. The fix Bundler >= 1.14 has a --conservative flag. Using the conservative flag allows bundle update GEM to update the...

The options below might be relevant if you're stuck with Bundler < 1.14: Option 1 This will work if all dependencies for the update are already satisfied.

...xargs grep -cE "^inotify" | column -t -s: You will get a list like: /proc/3753/fdinfo/7 1 /proc/3774/fdinfo/7 1 /proc/4034/fdinfo/12 14 /proc/4839/fdinfo/11 7 /proc/4871/fdinfo/12 98 /proc/50565/fdinfo/10 3 /proc/50565/fdinfo/14 266 /proc/50565/fdinfo/25 186 /proc/50620/fdinfo/19...

/proc/5192/fdinfo/3 47697 /proc/5225/fdinfo/63 4 /proc/5274/fdinfo/23 3 /proc/6121/fdinfo/7 38 (...) The number between /proc/ and /fdinfo/ is the PID of the process and the last number is the number of inotify...

developer.mozilla.org

...seems to be Baseline for all browsers since 2022). const fadeIn = [{ opacity: 0 }, { opacity: 1 }] // this is a keyframe example const container = document.querySelector('.animate-me') const animation = container.animate(fadeIn...

...SSLCertificateNotVerified errors, or when using plain Net::HTTP: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed Here is how to...

...certificate can not be verified. >> RestClient.get('https://self-signed.badssl.com/') RestClient::SSLCertificateNotVerified: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed Self-signed certificates are...