At work, I have use a MacBook Air and run Windows 7 in a VirtualBox VM.  I use (and love) the Mac Terminal heavily and have almost an entire monitor dedicated to it.  Since we use Git, I wanted to be able to use the Mac Terminal to interact with files on my Windows 7 VM since I do a good deal of development on the Windows box itself.  I installed cygwin with the sshd and Git packages, configured it and was able to successfully ssh in to the Windows box from my Mac OSX terminal.  (By the way, the reason I went with cygwin is because I was able to install sshd as a Windows Service; msysGit does not provide sshd).  After some tinkering with settings and ssh keys, everything was working fairly well.  However, over time I began to notice (more and more) Git on cygwin running slow when doing pull, merge, status, etc. on a particularly large repo.  It got really frustrating!  I tried the same commands in msysGit and things were much snappier, possibly because msysGit was running Git 1.9.4 and the latest version (available) of Git in cygwin was 1.7.x.  Anyway, I decided I would try to run msysGit from within cygwin to see if could get the best of both worlds.  It wasn’t the easiest thing to get working but I finally did get them playing nicely with each other and am very happy.  Here are the steps I took:

  • Install cygwin with the latest Git package. (My install path is C:\cygwin64)
  • Install the latest version of msysGit. (My install path is C:\Program Files (x86)\Git)
  • Rename C:\cygwin64\bin\git.exe to C:\cygwin64\bin\git_cygwin64.exe (to back it up)
  • Copy C:\Program Files (x86)\Git\bin\git.exe to C:\cygwin64\bin\
  • Copy the folder C:\Program Files (x86)\Git\libexec to C:\cygwin64\
  • From within cygwin environment, run git config –global color.ui always

The only issue I’m still having is when doing a git log command, the paging is not working.  If I run git log | less the paging works fine so I am just using this syntax for now.

Mount SD card in VirtualBox from Mac OS X Host

Somehow (some way) I forgot the password to one of my Raspberry Pi boxes and needed to reset it.  The only way I know how to do this is to mount the root partition from the context of another machine and then edit the /etc/shadow file.  Since I own a MacBook Air and it can’t read ext3 natively (not that I know of at least) I thought I would just just spin up a virtual machine in VirtualBox, mount the SD card from the Raspberry Pi, make the change and be done.  It wasn’t as easy as I thought because, for some reason, getting VirtualBox to pass the SD card reader to a virtual machine as a virtual device is not quite easy.  Below are the steps I had to take to get it working.

First, insert the SD card into the reader, open a terminal window and type mount.

Screen Shot 2014-07-20 at 3.10.34 PM copy

Take note of the SD card device that shows up.  In my case, it was /dev/disk1s1 (NO NAME matches the title that showed up in Finder when I inserted the card so this is a hint as to which one is the one I am looking for) listed at the bottom of the mount command.  You don’t want to get this wrong so make sure it’s right!  For a sanity check you could always run mount before inserting the card and then after, to see the difference.

Next, open up Disk Utility, click on the the mounted partition from the card (NO NAME in my case), and then click the Unmount button at the top.  Do not click the eject button, just the Unmount button.

Screen Shot 2014-07-20 at 3.08.37 PM

Now, you need to create a VirtualBox vmdk file that points to the SD card so that you can mount it as a device in a virtual machine.  You need to run sudo VBoxManage internalcommands createrawvmdk -filename ./sd-card.vmdk -rawdisk /dev/disk1.  Note, when I ran the mount command above, my device name was /dev/disk1s1 but in this command I did not include the trailing s1 portion.  The reason for this is that the s1 portion of the device name denotes a partition but I want to create a pointer to the entire device (mine has 2 partitions).  So, just take the first portion of your device name and use it for the -rawdisk parameter.

Screen Shot 2014-07-20 at 3.25.23 PM

Now that you have a vmdk file pointing to your raw SD card device, you need to set permisisons on the vmdk file and /dev/disk1 device.  Run sudo chmod 777 /dev/disk1 and sudo chmod 777 ./sd-card.vmdk.  This will ensure you are able to access and mount the vmdk file in VirtualBox.

Screen Shot 2014-07-20 at 3.26.04 PM

The last step, is to add a SATA device in the virtual machine Storage configuration.  Click “Add Hard Drive” on the SATA controller.

Screen Shot 2014-07-20 at 3.14.08 PM

You will be given the option to “Choose existing disk”.  Choose this option and then select the vmdk file you created earlier.

Screen Shot 2014-07-20 at 3.47.50 PM

Now, all you need to do is start your virtual machine with VirtualBox and your SD card should be accessible from your virtual machine.  If you get an error about the device being busy when trying to start the machine, open the Disk Utility and ensure all partitions of the SD card are still Unmounted.  For some reason I had to do this because OS X remounted my card somewhere along the way.

If you’re lucky like me, SD partitions will automatically be mounted.  In my case, I was running Linux Mint and both partitions of my SD card were mounted automatically!

Complex Types in Entity Framework (Code First)

Last week I gave a tech talk on Entity Framework. One of the questions that was asked at the end of the talk was how to handle “complex types”.   That is, how to get Entity Framework to map data into a container “child object” correctly.  A couple of reasons you might want to do this are: to organize your model classes in a cleaner way and also to isolate data for serialization.  For example, if you have a database table called Person that includes address related fields, you might want to create an Address class and have EF map just the address fields in this type.  This gives you flexibility so that, for example, you could serialize the address info to JSON without having to ‘ignore’ a bunch of other fields you don’t want serialized.

I had to dig around a bit to figure out how to get it to work but it is definitely possible.  You just need to:

  • Define the complex type class
  • Decorate the type with [ComplexType]
  • Add a member of this type to the container type (i.e. add Address property to Person class)
  • Make sure the type is always instantiated (either at declaration or in constructor).  This seems a bit odd but if you don’t do this EF will throw an exception at runtime.

The article Associations in EF Code First CTP5: Part 1 – Complex Types was definitely helpful with understanding this.

Here is a gist demonstrating what it looks like.

Entity Framework Tech Talk

Today I gave a “tech talk” at work on Entity Framework.  The audience was a mix of .NET, Ruby/Rails, and C++ developers so I tried to keep the content balanced between high-level information (for those unfamiliar) and lower-level details to keep those that work with EF interested and (hopefully) learning something new.  A few questions came up at the end that I didn’t know the answers to so I went and found out and this proved to be a good learning process.  I learned a few things about EF today that I think are helpful.  Anyway, it was a good experience to freshen up on my overall knowledge of Entity Framework and to get more practice presenting in front of technical peers.  Below is the slide deck I used.

By the way, I used (based on the freaking awesome reveal.js framework) for the presentation.  I was nothing but impressed and will be back next time I need to throw some slides together.

Foot Pedal Facet

About a year ago I was visiting a friend, Greg, at his home and went to wash my hands in his kitchen sink.  The facet was already on and I couldn’t figure out why the water wasn’t coming out.  He laughed and said “push the pedal with your foot”.  Sure enough, there was a foot pedal on the floor and pressing it down made the water come out.  Cool!  Besides being interesting and geeky, he pointed out that it actually helps save water when doing dishes because you can push the pedal down to wash a dish and then easily release temporarily before doing the next dish.  I spent the next 20 minutes asking questions about how he got it working and Greg was more than happy to give me the details and take me on a tour under his sink.  It was a pretty neat setup, complete with a manual bypass and switch override, but the heart of the system was a couple of electric solenoids.  Solenoids are water valves that are normally closed but open when given some direct current electricity.

A few months later, for my birthday, my parents and wife got me the parts needed to make my own foot pedal sink.  I called up Greg and get some details on the setup and he walked me through what I would need do.  I installed it a few weeks later and have had it working for months.


Parts List



The installation at first glance seems a bit complex but it is fairly straightforward.  You need to:

  1. Connect the A/C side of the AC/DC supply to your dishwasher 110 A/C power source.  For me, the access was pretty easy and required a simple drill hole through my sink cabinet partition.
  2. Connect the negative D/C side of the supply directly to both the hot/cold side solenoids.  You will do a “Y” wiring configuration so both solenoids are getting the same negative D/C wire connection.
  3. Send positive D/C through both the bypass light-switch and foot pedal and then join the output from both back before doing a “Y” connection to both the hot/cold solenoid sides.  This allows either the bypass switch or the foot pedal to close the circuit and provide positive D/C current to the solenoids.

Foot Pedal Facet








Not Found

Sorry, no posts matched your criteria.