Salvage a VirtualBox machine you forgot to export
If you copy the data files of a VirtualBox machine to another PC without exporting it as an .ova
appliance first, it's painful to get it into another VirtualBox installation. Thankfully there is a workaround:
- Create a new machine
- Copy the
.vdi
drive data into the new machine folder - In the machine settings, add that
.vdi
as a hard drive, and remove the dummy.vdi
you created when creating that machine.
Move Window Buttons Back to the Right in Ubuntu 10.04 / 10.10
One of the more controversial changes in the Ubuntu 10.04 beta is the Mac OS-inspired change to have window buttons on the left side. We’ll show you how to move the buttons back to the right.
Or run this via console:
gconftool-2 --set /apps/metacity/general/button_layout \
--type string "menu:minimize,maximize,close"
Script to create and copy a production dump to your project root
Soon after having written our shell-for script, we wanted to easily get dumps of our productions machines, too. This is how we do it:
dump-for staging [-s]
It will copy the dump to your project's tmp
directory and name it according to the capistrano stage you're calling for, here: staging.dump
. When you pass the optional -s
option, the dump will automatically been sourced into your local development database.
This script ...
Releasing geordi
After having written useful scripts into makandra notes for a long time, we’ve now tied them into a powerful new gem: geordi.
It gives you the power to
- get a dump from your production database with
dump-for production
- install your local gems to the production machine with
install-gems-remotely
- execute rake tasks to several environments at the same time with
power-rake db:migrate
- and much more
IE7 not properly redrawing elements with position: relative
If you manipulate the DOM with JavaScript and your page contains nested elements with position: relative
, chances are Internet Explorer 7 will not properly move to the right position.
I have not found a fool-proof workaround, but these are options that have worked for me:
- Try to lose some
position: relative
attributes, so they do not nest. This is often impossible, though. - Force the correct redrawing of the elements using JavaScript. Adding a bogus class (
$(element).addClass('touch')
) seems to suffice. - Try to give the off...
Faker is now I18n aware, ships with unicorns
Recent versions of the Faker gem retrieve their strings from your locale file (e.g. config/locale/de.yml
). This leads to awesome errors like this:
undefined method `shuffle' for "translation missing: de.faker.lorem.words":ActiveSupport::SafeBuffer
To fix this, copy the contents of a Faker locale file into your config/locale/de.yml
.
This is stupid.
Updating a gem created with Bundler
Since May 2011 we are cutting new gems using Bundler, which is less painful than cutting gems using Jeweler. You know a gem was cut using Bundler if you see the word Bundler
in a gem project's Rakefile
.
This is how to update a gem that was cut using Bundler:
- Say
git pull
or check out a repository from Github likegit clone git@github.com:makandra/geordi.git
- Update the gem version in `lib/project...
ActiveSupport::StringInquirer
Wrapping a string in this class gives you a prettier way to test for equality.
Test that a number or money amount is shown with Cucumber
This is an awful way to test whether a number is shown on the screen:
Then I should see "5"
It is awful because the step above is green for 5, 5123 and -51.
This step definition below makes sure this doesn't happen. You can use it like this:
Then I should see the number 5
The step also works if you you'd like to test that the number is followed by a unit:
Then I should see the amount 5 €
The separator between the number and its unit is allowed to be either a space or a [nbsp](https://makandracards.com/makandra/838-generate...
Setting up FreeBSD as Virtual Machine in VMware
Install FreeBSD
- Download a suitable image from this site
- Select
File > New…
to and follow the instructions, choose the.iso
file you downloaded as image file - Start the new virtual machine and follow the instructions
- formatting is a little complicated, so let freebsd.org help you
Install VMware Tools
Choose Virtual Machine > Install VMware Tools
from the VMware menu, then as root
:
^
# install required packages
pkg_add...
Don't call #node on a Capybara element
Capybara allows you to select DOM elements, e.g. by using field
, find_field(...)
or field_labeled(...)
:
role_select = field_labeled('Role')
In the example above, role_select
is now a Capybara::Driver::Node
. You can call a number of methods on such a node, e. g. in order to click it or to make a selection on its descendants. These methods should be the same regardless of the driver Capybara is using (drivers are e.g. the headless Rack::Test or Selenium).
It i...
Rails 3.1: Release candidate
Asset pipeline, HTTP streaming, jQuery as default framework, auto-reversable migrations, identity map for ActiveRecord.
Ruby 1.8.x support will be dropped with or after Rails 4.
Automatically build the Passenger Apache module, without interactively asking for user input.
passenger-install-apache2-module --auto
Sudo a gem executable does not work on Ubuntu
Today I needed to execute a ruby gem executable with sudo
. But, surprisingly, bash would tell me command not found
for the gem that ran lovely without sudo
.
Gem bin
s are installed to /var/lib/gems/1.8/bin
, which is not in sudo’s PATH
. Unfortunately, you can’t change the path, since sudo
for Ubuntu is compiled with the --with-secure-path
option.
#Solution A: symlink the gems (if you need only some few gems)
- for each gem you need for
sudo
, run `ln -s /var/lib/gems/1.8/bin/gem_for_sudo /usr/local/bin/gem_for_sudo
#Soluti...
Getting started with Chef
Before installing chef, make sure curl
is installed and sudo
finds your gems
- setup
chef-client
: follow this guide - setup
chef-server
: follow this guide
#Important
- execute all commands from within your
chef-repo
directory, else you'll be missing out on configuration files
Fix randomly failing PDF cucumber tests
Sometimes PDF cucumber tests fail at the first test run and succeed at the second run. You can fix this with this step:
When PDF generation is ready
And I follow "Save as PDF"
# Checks for PDF contents go here
Here is the step definition:
When /^PDF generation is ready$/ do
Then 'I should see ""'
end
Remove carriage returns from DOS-formatted text files using Vim
If you need to strip carriage return characters from a text file, you can use Vim:
vim file.txt
:set ff=unix
:wq
Script to open an SSH shell to a Capistrano deployment target
We regularly need to connect to the server in order to e.g. access the production console. Guessing the Capistrano deploy user and then again guessing the right directory on the server is awkward, so we wrote a script that parses config/deploy and gives you the handy command shell-for
.
Run it from any project directory like this, passing a Capistrano multistage deployment target:
shell-for staging
Now it also supports commands to be remotely executed before loading the bash. Use --no-bash
to only execute the command and load no ba...
Protect your Mac
If you’re a Mac user and want to increase the security of your data, check out the attached paper.
Encrypt your drive with PGP Whole Disk Encryption.
Encrypt your Time Machine backup like this.
Conditional comments for Internet Explorer with Haml
Internet Explorer 5+ is aware of conditional comments that let you target HTML for selected versions of IE. For example the HTML below would ask users of IE 6 and IE 7 to install Firefox:
<!--[if lt IE 8]>
<a href='http://www.mozilla.com/en-US/firefox/'>Get a real browser</a>
<![endif]-->
You might wonder how to express such a conditional comment in your favorite templating language, Haml. You might even have converted a template back to ERB just for this ...
Getting started with Puppet
When you simply want to get to know Puppet, follow puppetlabs’ Learning Puppet Docs. They give you a handy introduction inside a virtual machine they provide. You can watch the talk by Garrett Honeycutt 'Expanded Introduction to Puppet'.
Do not miss their cheatsheat and their [learn-puppet virtual machine](http://info.puppetl...
Matching line feeds with regular expressions works differently in every language
Although regular expression syntax is 99% interchangeable between languages, keep this in mind:
- By default, the dot character (
"."
) does not match a line feed (newline, line break,"\n"
) in any language. - Some languages allow you to modify the behavior of a regular expression by appending a modifier to the pattern expression. E.g.
/foo/i
makes the pattern case-insensitive in many languages. Note however that some of these modifiers may not exist or mean entirely different things in different languages. - Some languages have a m...
Putting static content on Cloudfront
We recently decided to put static content for HouseTrip.com to Amazon Cloudfront for a faster user experience. This happens fully automatically on deploy and is transparent in development. Together with a heavy use of sprites this sped up page load time quite nicely.
These are a couple of the problems you need to solve in order to do this:
- There is no good way to invalidate Cloudfront cached assets, and Cloudfront will ignor...