...works only at the beginning of the matched string, looks for a number (\d+ [1]) and also captures that. Sweet. However, mind that your input will not be magically escaped...
...the string. Simply pass them as a second argument: new RegExp('foo', 'i'); # => /foo/i [1] Note that we need to say "\\d" in our string when we want our string...
...the same every time: expect(object).to receive(:foo).with('argument').and_return('response 1', 'response 2') If the argument list differs between invocations: expect(object).to receive(:foo).with...
...argument 1').ordered.and_return('response 1') expect(object).to receive(:foo).with('argument 2').ordered.and_return('response...
...class @NestedHash @read: (objekt, keys...) -> if objekt and keys.length @read objekt[keys[0]], keys[1...]... else objekt @write: (objekt, keys..., value) -> objekt ?= {} if keys.length key = keys[0] objekt[key] = @write...
...objekt[key], keys[1...]..., value) objekt else objekt = value Jasmine-Spec describe 'NestedHash', -> describe '.write()', -> it 'writes nested values to a hash', -> hash = {} NestedHash.write hash, 'level1', 'level2', 'value' expect(hash...
...thus keeping any extra attributes: var index = element.indexOf(subElement); if (index > -1) element.splice(index, 1...
...interaction was still possible. This apparently happens to all IntelliJ IDEs, especially on Ubuntu 14.04. I've managed to fix it by having a shell script that exports XMODIFIERS="" when...
...alternate solution suggested on the Jetbrains issue tracker is setting IBUS_ENABLE_SYNC_MODE=1. #!/bin/sh IBUS_ENABLE_SYNC_MODE=1 /home/arne/rubymine/bin/rubymine.sh This seems fix issues on RubyMine 8.
...ObjectInUse: ERROR: database "foo_development" is being accessed by other users DETAIL: There is 1 other session using the database. This could be the rails server, rubymine and many more...
...session connection manually you can also find out the pid and kill the process. 1. rails db 2. SELECT * FROM pg_stat_activity; datid | 98359 datname | foo_development
lines = [] File.open(cucumber_paths, 'r').each do |line| lines << line.slice(/\s+when /^?([^$]*)$?/[im]?$/, 1) # @param 1: return first matched group end paths = lines.compact.sort TextMate::UI.complete(paths, :extra_chars => " ")
If you're experiencing problems with your Google Chrome installation after an update, it might help downgrading Chrome to check...
...and place your service definitions at the root of the file to use version 1. For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/ $ cat ./docker-compose.yml
...remove docker-compose. Check your docker-compose version $ docker-compose --version docker-compose version 1.17.1, build unknown $ docker-compose version docker-compose version 1.17.1, build unknown docker-py version...
...Sidekiq is running @reboot start_sidekiq 23 8 * * * baz 30 * * * * plop 5 8 * * * bar 1 0 * * * foo # End Whenever generated tasks for: project100 While you can human-parse this one...
Output for the example above will be: @reboot start_sidekiq 30 * * * * plop 1 0 * * * foo 5 8 * * * bar 23 8 * * * baz If you want to sort by day...
...That means the following code in routes.rb … resources :users do resource :profile, controller: 'users/profiles' #[1] end … makes Rails expect the following directory structure: app/ controllers/ users/ profiles_controller.rb users_controller.rb ... views/
show.html.haml index.html.haml ... Note: the user profiles controller must be named Users::ProfilesController [1] specifying the controller as 'user/...' would make Rails expect views in view/user/... (singular) The better approache...
Note that you cannot currently use Ruby 1.9.2 with Rails 2 applications that use RSpec, so don't upgrade if that is your setup. The rspec-rails gem has a...
...x, which only supports Rails 3. There is no fix for the rspec-rails-1.3.x series of the gem which supports Rails 2. Anyway, here are upgrade instructions if...
...see any changes in your debugged gem. Howto Disable spring with export DISABLE_SPRING=1 in your terminal. That will keep Spring at bay in that terminal session.
# Spring leads to all kinds of unexpected behavior in tests. ENV['DISABLE_SPRING'] = '1' block.call end
...that undoes the old changes. Imagine the following commit history: * commit_sha3 [Story-ID 1] Fixup for my feature * commit_sha2 [Story-ID 5] Other feature * commit_sha1 [Story-ID...
You can revert a single commit using the following syntax: git revert commit_sha2 To revert changes that are split across multiple commits, use the --no-commit...
SSHKit 1.9.0 might fail with the following error, when trying to deploy a Rail application. Upgrading the gem to version 1.21.0 fixed the issue. Traceback (most recent call last):
...from /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.9.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' 16: from /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.9.0/lib/sshkit/backends/abstract.rb:29:in `run' 15: from /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.9.0/lib/sshkit/backends/abstract.rb:29:in `instance_exec' 14: from /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/capistrano-3.14.1/lib/capistrano/tasks/deploy.rake:89:in `block (4 levels...
If you open a pop-up window [1] in your Selenium tests and you want to close it, you can do this: # Find our target window handle = page.driver.find_window("My...
...any subsequent steps will break when you are not pointing to a correct window. [1] as in: a real browser window, maybe via window.open in JavaScript
...file called test.file. You would then run this: dd if=/dev/zero of=test.file bs=1048576 count=23 The block size (bs) is set to 1 MB (1024^2 bytes) here...
mb = 23 mb_string, _error_str, _status = Open3.capture3('dd if=/dev/zero bs=1048576 count=1') tempfile = Tempfile.open('some_file.txt') do |file| mb.times { file.write(mb_string) } file end
...record a h264 encoded video. record command when using ffmpeg (for e.g. with ubuntu 12.04) cat some_acces.log | logstalgia --sync -1920x1080 --output-ppm-stream - | ffmpeg -y -r 60 -f image2pipe...
...vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 logstalgia.mp4 record command when using avconv(for e.g. with ubuntu 14.04) cat some_acces.log | logstalgia...
...to pass the desired format as a String, not a Symbol: get :show, :id => 1, :format => 'pdf' # works get :show, :id => 1, :format => :pdf # does not work
it 'does something' do pending end it 'does something else' do pending expect(1).to eq(1) end The first case may be unexpected, if you just wanted to...
...code with Bundler versions < 2.0.2. It just looks like the task is frozen: Workaround 1: Just type your OTP code and hit enter, your gem is released afterwards.
If you need to release a gem with a legacy Ruby version like 1.8.7, the workarounds above won't work for you. In this case, switch to a modern...
...it properly or you will "randomly" get errors like these: wrong number of arguments (1 for 0) (ArgumentError) wrong number of arguments (0 for 1) (ArgumentError) Take a look at...
...Here are two options by example on how to achieve this in Rails. Option 1 Time.use_zone('UTC') { Time.zone.parse('2020-08-09 00:00') } => Sun, 09 Aug...
def tp(objects, *method_names) terminal_width = `tput cols`.to_i cols = objects.count + 1 # Label column col_width = (terminal_width / cols) - 1 # Column spacing Array(method_names).map do...
...cells.map{ |cell| cell.to_s.ljust(col_width) }.join ' ' end nil end Usage examples: tp Video.where(key: '123'), :created_at, :updated_at, :published tp [album1, album2], :title, :image_count