Open a page in the default browser
Use the Launchy Show archive.org snapshot gem:
Launchy.open('http://www.ruby-lang.org/')
Related cards:
"Show me the page" fails to open a browser window
If you get an error like this:
Unable to launch /home/bruce/Projects/myproject/tmp/capybara/capybara-201110311210111407691101.html
... update your launchy
gem. It failed for us in version 0.4.x. We could fix the issue by upgrading to 2.0.5.
Linux: Open a file with the default application
If you are on a Linux shell and want to open a file with whatever default application is configured for that type, this often works:
xdg-open Quote.odt
xdg-open invoice.pdf
xdg-open index.html
Pro Tip
Make an alias so you ...
AngularJS: How to hook to the end of a digest cycle (before the browser redraws)
When you run code inside a $watch
expression that forces a repaint (e.g. by computing an element's width, or running something like...
Open a new tab with the current directory on a mac
I found a nice script on crazylittlehacks and modified it slightly. Put the attachment to /usr/local/bin
, chmod +x
and run it like this:
tab
You m...
Files open with an error "the location is not a folder" after installing XFCE
When using gnome-open
(i.e. double-clicking a file, telling to browser to open a download, etc.) on Ubuntu you may get this error:
The location is not a folder.
It's due to the exo-utils
package which [does not play nice with gnome-open
]...
How to get the hostname of the current machine in Rails or a Ruby script
Use Socket.gethostname
. So for a machine whose hostname is "happycat", it will look like this:
>> Socket.gethostname
=> "happycat"
That should work right away for your Rails application. For plain Ruby, you first need to do:
requi...
How to ask a (mobile) browser about the true visual viewport
The Visual Viewport API enables developers to access the actually visible area of the page. This differs from the normal viewport if:
- the user has pinch-zoomed
- the on-screen ...
Navigating through the browser history in a cucumber feature using selenium
In order to navigate through the browser history. you can manipulate the window.history object via javascript like follows:
When /^I go back in the browser history$/ do
page.evaluate_script('window.history.back()')
end
For further...
The Exciter - Why You Should Deploy Your Next Application on Ruby 1.9 and a Rant in General
The rubyforge gems model may not be perfect, but damnit people, when there’s a gem update I know that it has actually been tested somewhat and it’s not just whatever random point HEAD happens to be at, at that point in time, by some random Joe who...
Xfce: How to change the default program for a file extension
This is super stupid:
- In the Thunar file manager, select the file
- Go to File / Properties / Open With (WTF!)
- Select the preferred application from the list and hit "Set default"
This setting will apply to all files with that extension.