Setting up a new mac…

3 months ago I started using OSX full time. Today I found myself setting up a new mac. I wished that I had a checklist of my personal must haves. This is that list.

XCode (from AppStore)
Firefox Aurora
Chrome dev channel
EnvyCodeR font
iTerm2 (and configure with EnvyCodeR font)
twitter (only in AppStore)
brew — /usr/bin/ruby -e “$(curl -fsSL”
copy my ssh keys and load them into my ssh-agent
copy my .vimrc and .vim dir
copy my .bash{rc,_profile}

Storyboard Custom Segue For Custom PushViewController Animation

While there are a lot of google hits when searching for custom pushViewController Animation, I found nothing regarding use of a Custom Segue to make it reusable and I also found a lot of misinformation like “it can’t be done with the default UINavigationController.” It can.

From your Button, View, Gesture Recognizer or whatever, instead of dragging from Push, drag from Custom.

Then select the Segue that is created and type in a class name the custom Segue.

Now we can create the FromTopReplaceSegue class. Use Add File or however you like to create new classes in XCode.


#import <UIKit/UIKit.h>
@interface FromTopReplaceSegue : UIStoryboardSegue


#import “FromTopReplaceSegue.h”
@implementation FromTopReplaceSegue
UIViewController *dst = [self destinationViewController];
UIViewController *src = [self sourceViewController];
[dst viewWillAppear:NO];
[dst viewDidAppear:NO];

[src retain];

[src.view addSubview:dst.view];

CGRect original = dst.view.frame;

dst.view.frame = CGRectMake(dst.view.frame.origin.x, 0-dst.view.frame.size.height, dst.view.frame.size.width, dst.view.frame.size.height);

[UIView beginAnimations:nil context:nil];
dst.view.frame = CGRectMake(original.origin.x, original.origin.y, original.size.height, original.size.width);
[UIView commitAnimations];

[self performSelector:@selector(animationDone:) withObject:dst afterDelay:0.2f];
- (void)animationDone:(id)vc{
UIViewController *dst = (UIViewController*)vc;
UINavigationController *nav = [[self sourceViewController] navigationController];
[nav popViewControllerAnimated:NO];
[nav pushViewController:dst animated:NO];
[[self sourceViewController] release];

In this CustomSegue not only are we doing custom animation from Top to Bottom (just like the default push navigation of Right to Left) but instead of pushing, we are replacing the top view controller.

In my current project I have a nearly identical FromButtomReplaceSegue that does the replace but animates from Button. I hope for a library of these with varying animation transitions and Push/Replace variants of each. Then anytime you want to use a different animation you can simply use a Custom Segue instead of writing a bunch of code in ViewDidLoad or wherever. Hurray Storyboard!


Scala 2.9.1 on Fedora 16

yum install scala on Fedora will grab all the dependencies, including a JVM, but its a pretty old scala.

Luckily it is pretty easy to install scala-2.9.1 by snagging it from rawhide, but just the RPMS only get you so far. Fedora seems to be changing their JAVA_HOME in 17. A little hack, and you are off and running.

  1. sudo yum install scala
  2. sudo curl -O
  3. sudo curl -O
  4. sudo yum install jline2-2.5-5.fc17.noarch.rpm scala-2.9.1-3.fc17.noarch.rpm
  5. rpm -ql scala | grep bin | xargs sudo perl -pi.orig -e ‘s@JAVA_HOME=/usr/lib/jvm/java-1.6.0/@JAVA_HOME=/usr/lib/jvm/jre-1.6.0/@’


Ubuntu testdrive networked to your LAN

testdrive uses the -net user feature of kvm by default, which is really cool because it becomes a lan client and magically gets internet via proxy. If you want to test server software, you probably want your testdrive VM directly on the same LAN as your host OS.

In my case I already had a bridge setup so it was as simple as changing the -net option on my kvm command line.

kvm -m 1024 -smp 2 -cdrom /home/jrwren/.cache/testdrive/iso/ubuntu_precise-desktop-amd64.iso -drive file=/home/jrwren/.cache/testdrive/img/testdrive-disk-43F4RO.img,if=virtio,cache=writeback,index=0,boot=on -usb -usbdevice tablet -net nic,model=virtio -net tap -soundhw es1370 -vga cirrus -vnc -k en-us


brctl will now show you the new tap device added to your bridge.

bridge name     bridge id               STP enabled     interfaces
br0             8000.001fd085d98b       no              eth0

The only drawback is that kvm has to be run as root. There is a way around that by specifying a network interface start script which would be suidroot, but for a personal system or testing development system, I find that overkill. I let her run as root.

Ubuntu testdrive as a base for a Fedora test

Ubuntu testdrive is AWESOME. In my words, testdrive lets you test the next version of ubuntu in a VM with a single command.

testdrive ultimately just creates a disk image and runs a virtual machine for you, lets you step through the install from the nightly CD, and then lets you continue to run that VM. I decided to use the exactly same disk image and vm command line to testdrive fedora.

  1. Download fedora cd image :
    curl -O
  2. copy a disk image : cp .cache/testdrive/img/testdrive-??????.img fedora16.img
  3. start the install : kvm -m 2048 -smp 2 -cdrom Fedora-16-x86_64-Live-Desktop.iso -drive file=fedora.img,if=virtio,cache=writeback,index=0,boot=on -usb -usbdevice tablet -net nic,model=virtio,macaddr=DE:AD:BE:EF:A8:CC -net user -soundhw es1370 -vga std -vnc -k en-us

Some details:

  • That copy a disk image step could probably be done much better by creating the qcow2 file yourself, but this worked for my immediate need.
  • The differences in the command line from a testdrive command line, on my system, are memory size (1024/2048) and -vga cirrus v. -vga std.

CodeMash 2012 Changed Me

Every CodeMash has changed me.

This CodeMash was no different.

I’ve attended every codemash. Each is unique and special. I have memories from each that I can point to and say “This is when I realized…” and it is something significant that changed who I am or what I am doing or how I approach code and life.

This year I feel the focus of change was definitely softer. It was not some deep technical conversation that I had at the attendee party with someone able to explain to me something in a way which I can see applicability for myself like it has been in most years past. This year I didn’t focus on the mash part of CodeMash.

CodeMash, to me, has always been about learning from outside your normal circles. If you are a .NET person, go learn something about the ruby world. If you are a Ruby person, go learn something about Java (assuming you’ve never lived in that world). If you are a Java person, find a PHP or Perl session (there weren’t too many this year). ‘Mash not bash’ has always been the underlying philosophy that CodeMash has taught me to adopt.

I’m done mashing for a while. I’ve been doing C# for day work for 7 yrs. Of course, to me, mashing that also meant making sure things would run on Mono. I’ve explored Ruby and Rails for at least 6 years now. I pay attention to the Ruby world. In fact, I have more Ruby podcasts in my subscription than I do .NET (or any other). I watch the Java world (to not do so as a .NET dev is foolish IMO). I long for Akka in .NET (although I think Stact and MassTransit might get me there). I long for… Heroku. I long for.. I mash… I long for… many things.

This year I didn’t mash at CodeMash, and I didn’t miss it. Ok, sure, I did a javascript precompiler where I felt like I finally understand JS as a language. I finally grasp the deceptive simplicity of prototypical inheritance. But beyond that, I went to C# and .NET sessions. I loved seeing Bill Wagner and John Skeet present some deep inside and outside C# async. I loved seeing PhatBoyG present Stact.

During his keynote, I believe I heard Barry Hawkins say “Depth trumps breadth”. Its not that I don’t feel some depth in some areas in which I play, but I want more. I feel like I have enough breadth.

So I leave CodeMash, like I do every year, with new direction and a new sense of purpose which I hope to utilize to become a new person. I want to be a different person than I wanted to be a year ago… again.

I cannot overstate one influencing factor which has had a profound effect on me coming to the above determination. Leon Gersing. I met Leon 4 or so years ago at a Columbus Day of Dot Net event. Of course even then I thought, “What a cool guy.” But if you have known Leon for that long (and I don’t know him very well) you know that Leon too has changed over the years. At the GANG 10 yr anniversary event, I got to listen to Leon give a talk on the topic of “You”. It was similar to the short and less serious topic he gave as Pecha Kucha on “Love”. I think a lot of the underlying message is the same and so I’m walking away with that on my mind.

CodeMash 2012 was huge win. It was also HUGE! I know that there were people there, who I know, who I did not see the whole time! Scott and Gary are a couple guys I didn’t see until the after party! So if I missed you, lets hope we run into each other next year. I’ll be the guy who is a little different than last year.

Thanks for the great conference, CodeMash!

OSX /private/var/vm disk usage

TL;DR see last paragraph.

I googled around for this answer and found nothing, so THEN I read the man page. This felt backward for OSX answers.
My Mac gave me warning that I was almost out of disk space recently. I ran du -kx / | sort -nr | less and noticed the biggest offender with nearly 10% of my disk space was /var/private/vm, so I started digging.
It turns out this is where OSX stores its swap files if it needs them.
OSX dynamically grows its swap files by adding new files, not by resizing an existing file. It starts off with very small files and as it needs a new one it creates a large one until it gets to 1GB file size and then it continues making 1GB swap files. The process dynamic_pager manages this.
In my case the 5GB of swap didn’t seem like that much until you consider that I have a 64GB MacBook Air. That is a large piece of the disk.
I told the dynamic_pager to clean up after itself, if it could, by running this command:

sudo dynamic_pager -L 1073741824

Build MVVM Applications in F#… or C#

Last month Chris Marinos had an article in MSDN Magazine titled “Build MVVM Applications in F#”

I liked it a lot. I jotted down some notes as I read it. My learning processed amused me as I went from WTF… to Hrm… to Oh I see… in a period of about 15 minutes or so.

It went something like this:

> My first thought on skimming the first 3 pages…
> Ok, no offense… but… Dude! Really?!?
> PM> Install-Package NotifyPropertyWeaver
> and my "viewmodel" can be class MovieVieModelCSharp { public string Name
> {get;set;} public string Genre { get;set;} public int Rating {get;set;}
> public MovieVieModelCSharp(Movie movie) { Name=movie.Name;
> Genre=movie.Genre; if(OptionModule.IsSome(movie.Rating)
> Rating=movie.Rating.Value; else Rating=0;} }
> But then I realize that isn’t the point of that part of the article.
> Everything looks cool. I’m wondering if NotifyPropertyWeaver would work
> with the Dummy F# view model in Figure 7.
> Then I see in Figure 9 you use the ViewModelBase. That is cool I guess,
> but I think NPW might allow for writing WAY less code.
> …
> OK… i spent some time exploring these idea and realized I’m clueless.
> F# has no concept of autoproperites (WART!) and its A LOT of code to
> write a mutable property (warts!). NPW sure isn’t going to work with
> non-autoproperties (it picks up on C#/VB autoproperty naming convention
> of the compiler IIRC).
> So all that said… I think your article is great.
> It challenged me to investigate some things. It shows me that F# really
> sucks for WPF. It makes me really appreciate C# autoproperties and NPW.
> Damn that is some ugly ass code in that last "all F#" section.


Now some interesting parts to this is that NotifyPropertyWeaver apparently DOES support weaving PropertyChanged into non-autoproperties. That is pretty cool, but even with that, I think that this is a case where C# is actually more appropriate than F#.

Where Windows Is Going

I’ve been stewing for about a day.

I did not go to Build Conference.

Once I figured out that WinRT is for Metro style apps and ONLY Metro style apps, and I tried to make a call from a .NET 4.5 app into a very simple “GetUserInfo” WinRT API and it threw an Access Denied Exception, I was upset.

Then I realized something.

This is not just a new way to program on Windows.

It is also not THE new way to program on Windows.

Microsoft is segregating their application types on purpose. Metro style apps and WinRT is not about “the next windows”. What was shown with the hybrid classic desktop and the new Metro UI is NOT the future vision that MSFT has for Windows. It is a transition.

Microsoft is posing Metro style and ONLY metro style to be the next development platform of a version of Windows that will not have the classic desktop. Some future version of Windows that won’t have Win32 and won’t have .NET. It will be WinRT on top of a Windows kernel and THAT IS ALL.

This is why that line between WinRT and .NET/Win32 has to stay thick and hard. There will be no hybrid apps. That ruins the vision.

win8-platform-and-tools Imagine a thick wall between the light blue and green.

Microsoft knows that it has to participate in a segregated market. They won’t be selling $100 Windows Professional licenses to OEMs of $300 tablet devices. The $10 license of Windows Started Edition is more like it. (I’m guessing at OEM costs.)

The operating system has to run fast on low power hardware. Any applications which run on it have to run on all the better and faster hardware, right on up to $5000 laptops. The Metro style along side classic desktop fits this mold.

I’m a little bit sad that they wouldn’t just come right out and say this. Come right out and say: “Hey! Our phones are going to run Windows 8! There will be 7”, 8”, 9”, 10”, 11”, 12” tablets all running Windows! But its not like any Windows that you’ve ever known!”


Talk about shaking things up! What if that were the first 3 sentences of the Build keynote?

I’m less angry about not being able to call WinRT from my .NET apps. But I’m a .NET developer. I’m not a Windows developer. I’m not a Silverlight developer. I’m not a WinRT developer.

I think in what I’m most disappointed is all that awesome stuff that WinRT makes easy, and out in .NET land, talking to a webcam for photos and video is still painful. Transcoding video is still painful. (Did you see how easy it is to transcode with WinRT? That is SWEET!)

babblings of a computer loving fool