rescue RestClient::ResourceNotFound => error @retries ||= 0 if @retries < @max_retries @retries += 1 retry else raise error end end response end This snippet tries to re-send the...
...that Jasmine syntax has changed with Jasmine 2, so if you're using Jasmine 1.x you might instead want to use an older cheat sheet. Expectations # RSpec
# Only return nodes that are either elements or non-empty text nodes @nodeType == 1 || (@nodeType == 3 && _.strip(@nodeValue) != '') ).last() if $lastContent.get(0) == $lastChild.get(0) findLastLeaf($lastChild) else $container
...states = Array.wrap(state_or_states).map(&:to_s) state_or_states = state_or_states.first if state_or_states.size == 1 { :conditions => { :state => state_or_states...
...the blank form on top with the following snippet: actors = movie.actors actors.build actors.unshift(actors.pop(1)) # won't work with Rails 4+ Because build_for_form creates new objects and appends...
If you use Angular 1.4+ together with Angular Animate, all ng-show, ng-hide, ng-class etc. are animated on default. If you want only some elements to be animated...
...enable animations globally and add a certain class if no animation is wanted. Option 1: Enable animations only for html elements with class 'animate' @app.config ['$animateProvider', ($animateProvider) -> $animateProvider.classNameFilter(/\banimate\b...
...using in_groups_of and writing multiple column sets of your data (i.e. split 1 block of 3 columns and 100000 rows into 4 blocks of 3 (12 in total...
...use jasmine.any(Klass): describe('plus()', function() { it ('returns a number', function() { let result = plus(1, 2) expect(result).toEqual(jasmine.any(Number)) }) }) Also see Expecting objects as method invocation arguments...
...ID and title of the Pivotal Tracker story you're working on. For example: [#12345] Add Google Maps to user profiles Optional further commit messages in the body
...install the last supported version of Bundler for Ruby < 2.3: gem install bundler -v '~>1' You will also see an error if your RubyGems version is...
After my update from MacOS X 10.6 Snow Leopard to 10.7 Lion the search function in Apple Mail stopped working. There were no or too little search results, when I...
...After the rebuild you should get the right search results again. Proceed with Step 1-2 for all your mailboxes (also for every top-level folder that is stored under...
...enable this, add an initializer config/initializers/array_paginate.rb: require 'will_paginate/array' You can now say: > numbers = (1..1000).to_a > page = numbers.paginate(:page => 2, :per_page => 10) => [11, 12, 13, 14, 15...
...16, 17, 18, 19, 20] > page.total_entries
Assuming you're wanting to undo the effects of git rm or rm followed by git add -A or something...
...that were modified in the last 24 hours you can do this: find . -mtime 1 You can also refer to another file's timestamp like this: find . -cnewer other_file...
...for a control to respond to touch commands. This is true for both iPad 1 and iPad 2 models. While certain CSS styles can lead to performance issues, removing those...
...upgrade RVM it has a hardcoded notion which patch level it considers to be "1.9.3". This can give you errors like "ruby-1.9.3-p392 is not installed" even if you...
...have another Ruby 1.9.3 that will do. The solution is to define an alias: rvm alias create 1.9.3 ruby-1.9.3-p385 Fuzzy matching Another solution is to use rvm with...
...a fixed number. #!/usr/bin/env bash interface=eth0 dumpdir=/tmp/ packet_threshold=5000 log_packets=100000 while /bin/true; do pkt_old=`grep $interface: /proc/net/dev | cut -d : -f2 | awk '{ print $2 }'`
pkt_new=`grep $interface: /proc/net/dev | cut -d : -f2 | awk '{ print $2 }'` pkt=$(( $pkt_new - $pkt_old )) echo -ne "\r$pkt packets/s\033[0K" if [ $pkt -gt $packet_threshold ]; then...
While RSpec 1 and 2 decided that specs inside spec/model are model specs, and those inside spec/features are feature specs (and so on), RSpec 3 will no longer do that...
...main() in -lc... yes creating Makefile ... cc1: all warnings being treated as errors Makefile:150: recipe for target 'gherkin_lexer_ar.o' failed make: *** [gherkin_lexer_ar.o] Error 1 ...
In Ruby 1.9, instance_eval calls the block the with receiver as the first argument: In Ruby 1.8, receiver.instance_eval(&block) calls block.call() In Ruby 1.9, receiver.instance_eval(&block) calls...
...block.call(receiver) This will blow up in your face in Ruby 1.9, where a lambda crashes when it is called with a different number of arguments: wrong number of arguments...
...cast strings into their respective types like this: Note.columns_hash['user_id'].type_cast('123') # => 123 Note.columns_hash['deleted'].type_cast('1') # => true Note.columns_hash['deleted'].type_cast('0') # => false
From Ubuntu 17, rbenv fails to install Ruby below 2.4 because of a mismatching OpenSSL dependency: it needs libssl1.0-dev for the installation process, but recent Ubuntus come with libssl-dev...
...instead of the current upstream version (which is 7). Install Ruby like this: # Ruby 1.8.7 apt install libssl1.0-dev # This will remove libssl-dev CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline --with...
...Button Sound”; the “Power Save Audio” entry is usually grayed out, so this is 1 beep less than from above.) Right Down Tick Do it this way or your colleagues...
...will stand at your desk after the 12th beep, ready to smack you...
Follow the instructions here. PRs at makandra/rubocop-config are welcome. Also check the issue tracker. RubyMine Since version 2017-1 RubyMine...