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

# Close it page.driver.browser.switch_to.window(handle) page.driver.browser.close # Have the Selenium driver point to another window last_handle = page.driver.browser.window_handles.last page.driver.browser.switch_to.window(last_handle) Mind these: find_window returns a window handle, which...

Sometimes you need a file of some size (possibly for testing purposes). On Linux, you can use dd to create one. Let's say you want a 23 MB file...

dd if=/dev/zero of=test.file bs=1048576 count=23 The block size (bs) is set to 1 MB (1024^2 bytes) here, writing 23 such chunks makes...

makandra dev

...its tables and their data, under a new name. Make a dump of your source database: mysqldump -uroot -p my_project -r my_project.sql Or, if you only want to dump...

...the database's table structure (schema) without any contents: mysqldump -uroot -p my_project -r my_project.sql --no-data Open up a MySQL shell: mysql -uroot -p From the MySQL shell...

...css? matcher has a couple of options you might find useful. Check that a selector appears a given number of times Use the :count option like this: Then /^I should...

...see (\d+) users?$/ do |count| page.should have_css('ul#users li', :count => count.to_i) end Check that a selector has a given text content Use the :text option like this...

dev.opera.com

Since version 11.10 Opera provides support for linear gradients using -o-linear-gradient. The syntax is pretty similar to Mozilla's -moz-linear-gradient. This will create a vertical gradient...

...image: -o-linear-gradient(top, #ff0, #f00); The first parameter defines where the gradient starts and which direction it will go. \ You can use top/left/bottom/right (and combinations of those) but...

This snippet makes links that refer to an anchor (like "...

...") scroll softly to it.\ In this example we only do it for links that also own a data-animate attribute...

...var hash = $(this).attr('href'); var offset = $(hash).offset(); if (offset) { $('html, body').animate({ scrollTop: offset.top }, 'slow'); location.hash = hash; return false; } }); Note that this could basically work for any element...

Similar to our snippet that runs all Cucumber features matching a given string, the following will run all modified or new Cucumber features by looking at your git status:

...status --short | grep -v '^ D ' | grep '.feature' | sed 's/.. //' | tr '\n' ' ' | xargs geordi cucumber If you want to know what each of the above commands does, see explainshell.

...or if none given, by it's number: When /^(.*?) inside the (.*?). iframe$/ do |nested_step, frame_number| page.within_frame(frame_number.to_i) do step nested_step end end When /^(.*?) inside the...

...iframe:$/ do |nested_step, frame_number, table_or_string| page.within_frame(frame_number.to_i) do step("#{nested_step}:", table_or_string) end end Use it like this: Then the radio button...

...RubyMine I have recorded two macros for debugging and linked them to some keyboard shortcuts. Since I believe everyone could benefit from having those I wanted to share this.

...first one simply inserts binding.pry and the second one .tap { |object| binding.pry } for when you do not have a reference to the object you want to inspect.

Use the PDF toolkit: sudo apt-get install pdftk To rotate page 1 by 90 degrees clockwise: pdftk in.pdf cat 1E output out.pdf # old pdftk pdftk in.pdf cat 1east output...

...is meaningful if you want other rotations. From the man page: The page rotation setting can cause pdftk to rotate pages and documents. Each option sets the page rotation as...

Call with the server's hostname (and user if you have no SSH agent), e.g. install-gems-remotely my.server.com # or without agent: install-gems-remotely me@my.server.com When you call it...

...as the gemspecs of all vendored gems in to a temporary folder on the server and does a bundle install there. If you need to install gems from anothere Gemfile...

...are usually encoded using Quoted Printable. Here is how to decode or encode such strings. You probably know Quoted Printable from e-mail bodies appearing in Rails logs, where =s...

...become =3Ds in URLs, or where long lines are split up and trailed by = after each split. Decode Quoted Printable Decoding such strings is actually quite simple using plain Ruby...

You can use the content CSS attribute to set an element's content -- which is especially useful for the :before and :after pseudo elements: a:before { content: 'Click me: '; }

...of other attributes of the element. So, if your links have a helpful title set, you could do this: a:before { content: attr(title) ": "; } There also is a jsFiddle for...

...s no user interface to give an AWS IAM user read/write access to a selected list of S3 buckets. Instead you need to attach an IAM policy like the one...

...below to the user: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::bucket1", "arn:aws:s3:::bucket2" ] }, { "Effect": "Allow", "Action": [ "s3:DeleteObject", "s3:GetObject...

So you have multiple screens under Xfce and want to have one task bar on each screen, only showing applications on that screen. Here you go: Create one panel for...

...by going to Right click / Panel / Panel preferences... and uncheck "Lock panel". You now see a grip that you can use to drag one panel to the bottom of each...

...bar or bookmark). You will no longer get the website's favicon as a shortcut icon, but there are many great icons here: /usr/share/Icons/$YOUR_DESKTOP_THEME$/128/actions

makandra dev
github.com

Axlsx is an incredible gem to generate "Office Open XML" spreadsheet files (XLSX). Does not break on large spreadsheets and supports a ton of features like graphs. API looks mature...

...and existing code is easy to migrate when coming from the spreadsheet gem. The documentation of some methods is a bit out of date, but you'll find your way...

Sometimes you need to look at the filter chain in specs. You can do it like that on Rails 2: controller.class.filter_chain.map(&:method) Note that we need to look at the...

...controller's class since before_filter and after_filter stuff happens on the class level. Also mind that the above code will give you all filters, both those run before...

makandra dev

This describes how to migrate an existing cucumber test suite to Spreewald. Add the gem Include spreewald into your cucumber environment by putting require 'spreewald/web_steps' require 'spreewald/email_steps' # ... or just

...spreewald/all_steps' into your support/env.rb. Look through your step definitions for everything that might be included in Spreewald. Candidates are web_steps, shared_steps, table_steps, email_steps etc. Comment it...

.../var/swapfile]: Could not evaluate: Field 'device' is required Notice: Finished catalog run in 12.39 seconds it's possible there is a "problem" in your /etc/fstab. I could fix it with...

...I needed it to do drag'n'drop in a hierarchical tree. Let's say you have this $scope in your Angular controller: $scope.tasks = [ { 'text': 'Task 1' }, { 'text': 'Task...

...renders this HTML: Task 1 Task 2 If you'd like to access the scope bound to the second you can say this in jQuery: var li = $('li:eq...

The adjust-hue function of Sass allows you to change a color's hue, but only relative to its current hue. adjust-hue(#ffff00, 120) // => #00ffff

...to a hue of 120° which is a nice shiny green? Take this function: @function set-hue($color, $target-hue) $current-hue: hue($color) $degrees: $target-hue - $current-hue

Restangular can make use of $http's built-in response cache. # Cache response for single request Restangular.one('accounts', 123).withHttpConfig({ cache: true }).get(); # Cache responses for all requests (be careful...

...with that, you might work with stale data) RestangularProvider.setDefaultHttpFields({ cache: true }); To invalidate cached responses e.g. on a state change in UI Router, you can do @app.run ['$rootScope', '$cacheFactory', ($rootScope...

...for example through an Ubuntu release upgrade) you might notice that Thunderbird will not show any of your old e-mails or settings. This results from a different directory being...

...used for storing profiles and configuration. You can replace the blank profile with your old one like this: cd ~ mv .thunderbird .thunderbird-invalid cp -R .mozilla-thunderbird .thunderbird