Screencast - Creating Linked Clones With VMWare Fusion

This is a short 11 minute video that walks you through the process of creating linked clones using VMWare Fusion.

VMWare Fusion fully supports linked clones;unlike VMWare Workstation it does not yet have a UI to create and manage them.

This video covers the main points:

  • How I organize and separate my vms from the vmdks.
  • Creating linked clones

Shamless Plug - Aside from the first click, no other mouse usage occured during the course of this video, courtesy of keymando.

Develop With Passion®

Fixing Header File Missing Warnings on OSX With Native Gem Compilation

Wiped away my install of XCode this evening to install the new version of Xcode (which I installed straight to /Applications!).

Prior to doing this I also completely deleted the /Developer folder.

Upon successfully reinstalling RVM and homebrew using the devtools, I cd’d into a rvm managed folder and did the standard bundle install, upon which time I eventually received this error:

Error - error.sh
1
: fatal error: 'stdio.h' file not found

I had installed the Command Line Tools for Xcode, but I had not yet switched where it should resolve those tools. Running the following command fixed the issue:

Fix the missing header issue - fix.sh
1
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Develop With Passion®

Installing RVM With Cygwin on Windows

A couple of people have asked me how to get rvm working successfully on windows with cygwin.

I’ll write another post later about how I use devtools to successfully run msys and cygwin side by side from the same set of dotfiles (customized per environment)!

I started with a brand new vm image with the software installed according to the post here.

If you don’t wish to read that previous post just know I installed cygwin to C:\utils\cygwin (for the purpose of this post it you are following along, I would suggest installing to that path also). I also included the following packages (some of these are not necessary for ruby compilation, but they have become my base for a cygwin install):

  • Archive
    • unzip - Unzipping zip files
  • Net
    • openssl - bin and sources
    • openssh - Only if you are not going to compile openssh yourself
    • curl - download internet resources
  • Devl
    • colorgcc
    • gcc
    • gcc-core - compiler
    • git
    • git-completion
    • git-gui
    • git-svn
    • gitk
    • libtool - Shared library generation tool. You’ll need it when trying to compile rubies
    • libncurses-devel - Used when compiling several other tools I use
    • make
    • mercurial
    • openssl-devel - Required for compiling openssh (not necessarily required for rvm, but I always install it to compile openssh myself)
    • readline
  • Libs
    • zlib
    • zlib-devel
  • Utils
    • ncurses - Enabling better handling of terminal
    • patch - Apply a diff file to an original. Again, you’ll need it when rvm is trying to patch the ruby installs

Once the cygwin install completes we can continue.

Setting Up

  • Open up a new cygwin session (C:\utils\cygwin\cygwin.bat).

  • Issue the following commands in the cygwin session:

Get The devtools - devtools.sh
1
2
3
4
5
6
mkdir repositories
cd repositories
mkdir developwithpassion
cd developwithpassion
git clone git://github.com/developwithpassion/devtools
cd devtools

The results should look as follows:

  • You should now be sitting in the devtools folder so you can now run the kick_off_script:
Prep - kick_off.sh
1
./osx_or_cygwin_kick_off
  • Repeat the above step(the first time you run it, it creates a settings file for your user that can be edited further if you are going to make further use of devtools later on)

    For the curious, the script is here

    The script does the following:

    • kicks off an rvm installation script
    • updates to the latest rvm
    • installs a couple of rubies and sets 1.9.3 as the default ruby

The last step takes a little time to complete, but the end result is definitely worth it!!:

Develop With Passion®

Webinar - Devtools - an Walkthrough of My Devtools Setup

Today I will be hosting a 1 hour webinar showing you how to get started with my devtools utilities.

Here is the information for the webinar:

Reserve your Webinar seat now at:

This webinar will be an opportunity for people to get an understanding of how I structure my devtools folder and how it is leveraged to facilitate working effectively between osx and windows.

Title: Develop With Passion® - devtools Date: Wednesday, March 28, 2012 Time: 12:00 PM - 1:00 PM MDT

After registering you will receive a confirmation email containing information about joining the Webinar.

System Requirements * PC-based attendees * Required: Windows® 7, Vista, XP or 2003 Server * Macintosh®-based attendees * Required: Mac OS® X 10.5 or newer

Develop With Passion®

April Brussels Course: Rescheduled

I am sorry to announce that next month’s .Net Software Craftmanship BootCamp in Brussels, has been rescheduled until the week of September 17th.

Being our first time in Brussels, we are hoping that pushing back the date will provide more people with an opportunity to convince their bosses that the course is a good investment!

I apologize for any inconvienience this may cause.

God Bless You.

Develop With Passion®

April UK Course Rescheduled Until the Week of September 10th

I am sorry to announce that next month’s .Net Software Craftmanship BootCamp in the UK, has been rescheduled until the week of September 10th.

Since we only come to the UK once a year, we are hoping that pushing back the date will provide more people with an opportunity to convince their bosses that the course is a good investment!

I apologize for any inconvienience this may cause.

God Bless You.

Develop With Passion®

New Feature: Fakes-rspec - Multiple Args Sets Captured on Ignored/unexpected Methods

Just added a new feature to fakes-rspec to handle a scenario I ran into. The following test will hopefully explain it:

Interrogating Multiple Argument Sets on the same ignored method - ignored.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
context "when expanding all of the items" do
  let(:folder){"item"}
  let(:target){"blah"}
  let(:sources){[]}
  let(:args){:sources => sources,:shell => fake} #this syntax is incorrect, but the formatting was getting garbled
  subject{Copy.new(target,args)}

  before (:each) do
    %w[1 2 3].each{|item| sources << item}
  end

  before (:each) do
    subject.expand_all_items
  end

  it "should copy each of the sources to the target" do
    sources.each do|source|
      item = "cp -rf #{source} #{target}"
      shell.should have_received(:run,item)
    end
  end
end

The following line:

Verifying a Call - verify.rb
1
shell.should have_received(:run,item)

I am testing to see whether the run method (which was never set up to get explicitly called), was actually called 3 different times, and am also verifying that each time it was called it was called with a specific set of arguments.

In the test above I am verifying that for each “source”, a call was made to do a recursive, forced copy, to the “target” location.

Not needing to specify the call while also being able to verify each of the argument sets on each of the 3 invocations of the same method is handy, and introduced solely so I could support this feature that I was working on.

Develop With Passion®

Introducing: Fakes-rspec

This is a library to aid in the usage of fakes when using RSpec. It adds a bunch of convienience methods and matchers to aid in the usage of the heavily AAA style isolation library.

Installation

Installing - install.sh
1
gem install fakes-rspec

Or (preferably using bundler), in your gemfile:

Bundler - gemfile.rb
1
2
source "http://rubygems.org"
gem 'fakes-rspec'

When you install the gem it will install the rspec gem also, so you will immediately ready to go.

Usage

Creating a fake

Using a let block

Let Initialization - let.rb
1
2
3
describe "Some Feature" do
  let(:my_fake){fake}
end

Inline

Inline Initialization - inline.rb
1
2
3
4
5
describe "Some Feature" do
  it "should be able to create a fake" do
    item = fake
  end
end

Configuring a fake with return values for calls

Irrespective of arguments:

Faking Return Values Regardless Of Arguments - code.rb
1
2
3
4
5
6
7
it "should be able to setup a fakes return values" do
  the_fake = fake
  fake.stub(:hello).and_return("World")

  fake.hello.should == "World"
  fake.hello("There").should == "World"
end

Caring about arguments:

Faking Return Values With Specific Sets Of Arguments - specific_arguments.rb
1
2
3
4
5
6
7
8
9
10
11
it "should be able to setup a fakes return values" do
  the_fake = fake
  fake.stub(:hello).with("There").and_return("World")
  fake.stub(:hello).with("You").and_return("Again")

  fake.stub(:hello).and_return("Does Not Matter") # when you use the catch_all, make sure that it is the last step used for a particular method (as above)

  fake.hello("There").should == "World"
  fake.hello("You").should == "Again"
  fake.hello.should == "Does Not Matter"
end

Determining whether a call was made

One of the big strengths of this library compared to some of the other ruby isolation libraries is the ability to let you make assertions against the fake after the [subject] has run its code. The following examples demonstrate some typical usage scenarios:

Irrespective of arguments:

Verifying Call Made Ignoring Arguments - call_verify_ignoring_arguments.rb
1
2
3
4
5
6
it "should be able to determine if a call was made on a fake" do
  the_fake = fake
  fake.hello("World")

  fake.should have_received(:hello) #true
end

With a specific set of arguments:

Verifying Calls Made With Specific Arguments - verifying_calls_made_with_specific_arguments.rb
1
2
3
4
5
6
7
it "should be able to determine if a call was made on a fake" do
  the_fake = fake
  fake.hello("World")

  fake.should have_received(:hello,"World") #true
  fake.should have_received(:hello,"Other") #false
end

Remember, that because it is just a matcher, to negate the matcher you can use the should_not qualifier to do the opposite:

Determine whether a call was not made with a specific set of arguments:

Verifying A Call Was Not Made With A Specific Set Of Arguments - not_made_with_specific_arguments.rb
1
2
3
4
5
6
it "should be able to determine if a call was not made on a fake" do
  the_fake = fake
  fake.hello("World")

  fake.should_not have_received(:hello,"Other") #true
end

Determining that a call was made a certain number of times

Irrespective of arguments:

Verifying Occurences Of A Call Ignoring Arguments - verifying_occurences_ignoring_arguments.rb
1
2
3
4
5
6
it "should be able to determine if a call was made on a fake" do
  the_fake = fake
  fake.hello("World")

  fake.should have_received(:hello).once #true
end

Caring about arguments:

Verifying Occurences Of A Call Including Arguments - verifying_occurences_including_arguments.rb
1
2
3
4
5
6
7
it "should be able to determine if a call was made on a fake" do
  the_fake = fake
  fake.hello("World")

  fake.should have_received(:hello,"World").once #true
  fake.should have_received(:hello,"Earth").once #false
end

Remember, that because it is just a matcher, to negate the matcher you can use the should_not qualifier to do the opposite:

Determine whether a call was not made a specific number of times with a specific set of arguments:

1
2
3
4
5
6
7
it "should be able to determine if a call was made on a fake" do
  the_fake = fake
  fake.hello("World")

  fake.should_not have_received(:hello,"World").twice #true
  fake.should_not have_received(:hello).twice #true
end

After calling have_received, you can specify occurences using one of the following methods:

  • once
  • twice
  • at_least_once
  • at_least_twice
  • at_most_once
  • at_most_twice
  • at_least(times)
  • at_most(times)
  • exactly(times)
  • occurs(match_block) - Where match_block is a proc/lambda that matches the signature lambda{|number| bool}

An example of using the occurs method would be as follows:

Determine whether a call was not made between a certain number of times

Verifying Calls Using Occurs - occurs.rb
1
2
3
4
5
6
7
it "should be able to determine if a call was made on a fake" do
  the_fake = fake
  fake.hello("World")
  fake.hello("Again")

  fake.should have_received(:hello).occurs(lambda{|number| (1..3) === number}) #true
end

Contributing

Feel free to fork this codebase and submit any pull requests you think would be useful.

Develop With Passion®

Screencast: Freeing Up System Memory on OSX

In this quick video I show you how to use the purge command to quickly free up virtual memory on your machine.

Because I run a fair amount of vms on my machine, at any point in the day I can look at my memory usage and realize that I have almost no memory availabe.

For those that don’t want to watch the video (it’s only 2 minutes), I start the video having almost 6.81GB inactive and only 284.7GB available (and this is a 16GB machine.)

The long and short is I run the following command:

Free Up Your Memory - purge_memory.sh
1
purge

After the command finished running, I had only 138.6MB of inactive memory and 9.56GB of free memory!!

Here is the video:

Develop With Passion®

Repaving a New Windows 7 VM

On Thurday my windows vm image died along with my backup of it!!

I thought this was a good opportunity to repave a brand new vm that I can also create linked clones from to quickly scaffold new vm’s moving forward.

This post is mostly to help me remember the install process and the base tools that I install on a fresh windows 7 vm, as this is not something I do very often!! I included screenshots of most of the install steps, just so I can both remind myself what my defaults are, as well as for your benefit if you wish to copy this setup.

Base Tools Install

  1. Vista Switcher
  2. Ruby
  3. MinGW
  4. Autohotkey
  5. Copy the contents of /to_backup/new_windows_install/startup_software/utils to /c/utils. This folder contains:
    • sysinternals
    • myuninstaller
  6. Beyond Compare
  7. Executor
  8. Unlocker
  9. msysgit
  10. gvim
  11. cygwin Install the following packages:

    • Archive
      • unzip - Unzipping zip files
    • Net
      • openssl - bin and sources
      • openssh - Only if you are not going to compile openssh yourself
      • curl - download internet resources
    • Devl
      • colorgcc
      • gcc
      • gcc-core - compiler
      • git
      • git-completion
      • git-gui
      • git-svn
      • gitk
      • libtool - Shared library generation tool. You’ll need it when trying to compile rubies
      • libncurses-devel - Used when compiling several other tools I use
      • make
      • mercurial
      • openssl-devel - Required for compiling openssh (not necessarily required for rvm, but I always install it to compile openssh myself)
      • readline
    • Utils
      • ncurses - Enabling better handling of terminal
      • patch - Apply a diff file to an original. Again, you’ll need it when rvm is trying to patch the ruby installs

Along with the tools outlined above I also manually compiled the following:

Well that’s it for the base tool install!! There are a couple of other steps I do to configure msys and cygwin to play nice together, but that’s another post!! Outside of that, this is what constitutes my bare minimum for a usable windows vm. From this base image, I can create linked clones that allow me to create project specific vm’s that have further tools installed (such as vs, vs.net etc) specific to the contract/project I am working on.

Still To Come

In a follow up post I’ll detail a set of tools, scripts and code that allows me to configure this entire toolset, so that I can have a seamless environment that supports :

  • Vim with a host of my favourite plugins
  • An organized eaash environment with well partitioned dotfiles etc
  • Simple, plugin style automation tasks

Most importantly, the bash/vim/automation setup I have allows me to share all of the important scripts such as:

  • dotfiles
  • automation scripts

On all three of the main environments I work in :

  • OSX
  • Ubuntu
  • Windows (cygwin and mingw)

Until next time!!

Develop With Passion®