It’s a great day to be a .Net developer

What more is there to say?  Microsoft opensourced Roslyn (.NET Compiler Platform), source is avaiable on CodePlex!!!

It’s fantastic news, to quote Eric Lippert

What astonished me was that its not just a “reference” license, but a full on liberal Apache 2.0 license. And then to have Miguel announce that Xamarin had already got Roslyn working on linux was gobsmacking.

It’s a huge step, and something I hope Microsoft does more of.  I can’t wait to find some time to dig into this code, and see how it all works.

Getting Started with Android Development

Last fall I purchased a Nexus 7 (2013) and have really enjoyed the pure Android experience.  I’ll be retiring my S3 and buying a Nexus phone to replace it in the near future.  Anyhow, one thing that’s always lacking is a way to develop on the tablet…or so I thought!  Enter AIDE, an Android IDE that allows you to develop and run applications right from your tablet!


It comes with the code for  Tetris, a Clock Widget, and a Hello World app.  I started hacking together my first native app.  And tried to run it.  Of course, it crashed. So, Google, and I download a few logcat readers.  None seem to work. I do some more research and learn that as of the Jelly Bean update, apps can no longer read each others logs. This was added for security reasons, as some applications (facebook) were logging passwords in the log file, meaning, a maliscous app could easily read your facebook password from it’s logfile. Which now means, you need to connect your tablet to a pc to read the logs, and determine why your application is crashing.  At first, this annoyed me.  It took a while to get that work, and I’ll show you how. But if you plan to deploy your app, you’re going to want to have log files sent to you anyway. After showing you how to read logcat from your PC, I’ll show you how to write your first app in AIDE, that will email (or change it to write to a file you can open) it’s logcat after it crashes. It will allow you to develop, without the need for a PC.

First, you need to enable developer mode on your tablet. It used to just be in the settings, but now it’s more complicated.  Open your settings and scroll down to “About tablet” (phone, or whatever).  Scroll down to the Build number, and click it 7 times.

about tablet

You’ll see a message that developer mode is now enabled. Success. Back in the Settings screen you’ll now see Developer Options.

dev options

In there, turn on USB Debugging

USB Debugging

Next we need to install drivers, you can get the latest Google USB Driver from Unzip them to a location your machine, I chose c:\Android Tools\Usb_Driver. Now, open Device Manager, and find your device under “Other devices”

Update Nexus 7 Driver

Choose “Browse my computer…” and navigate to the folder you extracted the drivers into. Make sure “Include Subfolders” is checked. And install them, you should now see the device installed correctly.


So, now that the drivers are installed, let’s get adb installed, you can download r19.0.1 for windows here which is currently the latest version. Just extract the files onto your computer, I stored them at “C:\Android Tools\platform-tools” on mine.

Open a command prompt, go to the directory you just extracted adb.exe into, and try issuing the command “adb devices“, you should see a result listing the attached device.

C:\Android Tools\platform-tools>adb devices
List of devices attached
06e96062 device

If nothing is attached, you many need to change the Connection type with your computer, on your Android device, go to Settings -> Storage, and click the elipses in the top right, you’ll come to this screen, try changing between the two modes, one should work. On mine it was Camera, others have reported differently.

USB Computer Connection

If all is working correctly, you should be able to dump the logcat contents with the command

adb logcat

Or to a file

adb logcat -d > logcat.txt

This logcat grows quickly, if you want to clear the logcat of your device, issue the command

adb logcat -c

And that’s all for now. My next article should be a walkthrough of using AIDE to get a simple app up and running, with logging, so you can do do your development without needing adb to view logs, and thus, remove the tether to your computer.

Now, back to coding!

TIL: How to use adb to take a screenshot from Android

I was writing up another article and needed screen grabs from my device, and wanted a simple way to grab them, well, adb to the rescue!

adb shell /system/bin/screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png screenshot.png

It’s that easy.

The first line saves the screenshot on the device, the second pulls a file from the device to the local machine.

All of this assumes you have adb working and the drivers setup for your device. Which I will be showing how to do in a future post.

TIL: How easy it is to hack Windows.

Found this on a friends site (which I recommend you read as he posts some great sys admin tips and tricks!)

We watched it, then tried it out, and it worked. It takes about 2 minutes to change the password on an account and gain access to any windows computer.

The basic steps:

  1. When your computer is booting, reset it during the splash screen
  2. The prompt to repair appears, durin gthe repair there is an option to show the details in Notepad.exe
  3. You can use it’s Open/Save dialog to rename your sethc.exe (sticky keys) and replace it with a copy of cmd.exe
  4. Reboot
  5. On the login, hit shift 5 times, and get a cmd.exe window
  6. Use the ‘net’ commands to reset a local admin password
  7. Login and profit.

It’s way way way too easy.  Looks like the only way to secure your machine is to encrypt the entire drive so a password is required just to start the boot process.

TIL: The subtle difference between Keypress and Keydown (aside from the obvious)

The other day at work, an innocuous question was posed…

So, in javascript ‘ (apostrophe) and right arrow have the same event key code. What am I supposed to do with that?

This did not seem right to me, but, sure enough, a js fiddle showed this to be true…almost (go to result tab, and hit different keyboard keys, it will show the character code).

What appeared to be the same code (if you hit apostrophe then an arrow) was actually just that the arrow didn’t register as a keypress, and you were still seeing the last keys code. However, this was only true in some browsers, IE and Chrome, Firefox I believe worked as one would expect.

Changing to a keydown event works, and shows the right arrow as 39, like it should.

Quirksmode clears up a bit of the confusion, and has a nice little tester at the bottom of the page.

Attention Conference Organizers…we’re not all novices!

Over the past few years I’ve been focusing on my professional development (PD). I left a company where I was gaining nothing but stress, to a great company that actively promotes PD. They provide every employee with their own PD budget, they sponsor events, and some of their employees speak and organize conferences.

However, most conferences have one flaw. They focus on exposing people to new technologies, but most sessions stop there. Exposing me to something new is wonderful, it’s great… “but maybe” we can do better. I recently attended a conference in Las Vegas, it had an all star line up of speakers. But sessions were quite short, and the technical talks were so introductory that they were basically useless. They equated to ten minutes of tutorials on the web. If you had never seen or heard of the topic, they at least exposed you to it and gave you a new search term to learn more, but they were incapable of going further.

There was a lot of Twitter praise for the conference…but having been there, I know a large portion of the people there were novices or senior people who no longer actively develop and thus, were effectively novices. The few of us who are actively developing were underwhelmed and dissapointed, and while our company sent 6 people to this conference, I don’t see any planning to attend the next one.

I did however find a lot of value in the full day workshop before the conference. It was able to deliver an intermediate level of complexity. You learned a bit about what could and couldn’t be done with the tech. And had enough information to make a preliminary decision about using the tech in upcoming projects without a bunch more self learning.

I think conferences need longer sessions, and to try and provide more value to intermediate and expert skilled attendees. I have been talking with an organizer of an upcoming local conference. And the plan is longer sessions, more workshops, more value to the non-novice. That’s not to say intro level sessions won’t exist. They will, and they are needed, but they will happen prior to any advanced talks, and the session notes will point out the correlation between the talks. That attendance to the advanced talk should be proceeded by the intro if you have no prior exposure, etc.

Hopefully things go well for the organizer of this conference, as I’m excited for the new format. I’ve always found this conference worth attending, but one of the goals of it has been keeping it low cost. Had I spent the same money I did to travel across the continent, I don’t know that I would have felt the same way.

I’m hoping to find conferences that can truly provide some educational value beyond exposure. Maybe I’m just asking for too much.

Better technology doesn’t matter if the experience is worse.

I’ve been complaining a lot on Twitter today about the cable company.

About ten years ago I had cable, it was SD, but I could push it to all the TVs in my house. Then I discovered home brew pvr systems like MythTV, and was able to record all my shows, watch live tv, stream music, from any device in the house. And I had a guide I could access from the web, and pick, and reshchedule my recordings, all was well.

Then the cable companies started switching to digital. Which meant you needed a digital box. This is where it started going down hill. The technology was better, I got HD, and the ability to pause and record with the Cable Company’s PVR. But it was limited to two tuners. And they lock down firewire and any other useful way to get content off the device in HD, aside from the HDMI cable.

So for the past several years I have been tied to one TV. I can watch BluRays in other rooms. But for regular TV viewing the other TVs collect dust. I don’t want to spend money on more hardware, so I can PVR shows around the house. Then try and figure out which TV the show is recorded on, and be tethered to watch it there. And whenever a Hockey game comes on, I end up having to sacrifice a recording or two, because again, I’m limited in the number of shows I can tune into at a time. And does the Cable Companies box have nice features that let you know, hey, we’re not recording Breaking Bad at 8 because you want to watch this show live, but we see it’s on again at 2am, we’ll just record it then. My old setup did. It was FANTASTIC at rescheduling recordings so conflicts were eliminated.

The ideal solution would be to have the Cable Companies unlock the boxes so I can use a computer to push the videos to other TVs in the house. But that will never happen. So why waste the words… then they came out with their networked pvrs, allowing you to record more shows (3-6) at a time, watch anywhere in the house (that you buy another box for) and I’m thinking, great! Sign me up. Take my money. It’s not the best solution, but it’s pretty good, almost as good an experience as I had 10 years ago.

…except, despite the shows already being IN MY HOUSE, I can’t get this system without network upgrades in my area??? What…that makes no sense. The show is already saved on a hard drive IN MY HOUSE, what do the lines outside matter? Is it so I can record six shows at a time…fine…leave that ability until you upgrade the lines outside…but wait, that doesn’t make sense either, as if I buy more boxes, I can record more anyhow. So it’s not a bandwidth limitation. It’s a bad business decision. Rather than getting hardware that can share what we already have coming to the house, they picked something that while potentially superior, is limited. Thus limiting subscribers and pushing people away, giving them a poorer experience.

So, before I found out I couldn’t get this new system where I live (so remote, 20k from Winnipeg in a town with 5000 people that have money…), anyhow, before I found out, I spent 40 minutes on hold last week, and another 90 minutes this week (during which I contacted the on Twitter) before giving up and leaving a DM with my number to call me. Which begs the questions; Why doesn’t your hold system hint at the wait time? And why do I need to resort to calling out a company on Social Media to get a response? Anyhow, the DMs consisting of excuses for the delay answering the phones. Apparently there is an internet service outage they are trying to fix, so customers are calling in and complaining. Which, in my mind, isn’t an excuse, it’s a cause of another failure. Why doesn’t your network have better failover handling and redundancy? And it also doesn’t explain why I waited 40 minutes last week.

Anyhow, the offer I’ve been given is a second pvr box, so I can watch tv on two televisions. However, the experience is still awful. As outlined above, I have to decide where to record shows so that I can watch them where I want to, since I can’t change it. And if two things are recording on a tv where I want to watch live tv…to bad. I have to relocate, or go to the other tv, duplicate a recording there, and stop the one in the other room. Meaning, I now have one recording, split into pieces in different rooms. That will sure be an enjoyable experience when half way through watching the show I have to get up and go to another room to finish watching it.

Ten years, and the experience gets worse every year. Netflix is looking promising…if only I wasn’t tied to the cable company for my internet…

Netflix (or something similar) is going to dominate TV in the near future. Networks are fighting what could be their greatest ally, so they can continue to fight their current foe, limited time in prime time. You only have a few hours each night… which is funny, since very few people watch TV live anymore. I may watch the same day it’s recorded, but the only thing I watch live is sports.

Netflix is the ultimate PVR, with so many advantages it’s mind boggling; it’s cheaper; there’s no lock in to their hardware; I don’t need to setup recording schedules, the content is just there when I want it; no need to worry about storage space; I can watch it on my phone, computer, tablet, etc. It’s only drawbacks are that it doesn’t have new shows fast enough, and it doesn’t do live events…yet. When that day comes, it, or something similar wins. Networks can try and make their own Netflix clones, but they’re all tied to a network. People aren’t going to spend money with dozens of different companies and run a bunch of different applications to get their television. They want one bill, one service.

I may stick with cable (and Netflix) for a little while longer, but it won’t be too much longer. I can get hockey through a Centre Ice package that will be cheaper than cable…and that solves one of my concerns. Now to find a permanent solution to the other.

ps. This was written in one pass, no editing, so I’m sure it’s random and has no structure…sorry.

Do your job…take my money!

So, my girlfriend is trying to buy a new car. Upgrade her aging civic for a small SUV. After a few test drives, a Honda CRV is top of her list.

So we head to the one dealer because she wants me to test drive one (she already has). What transpired was the single worst job of sales I have ever witnessed.

We enter and a few salesmen are chatting. One walks over. We get through the introductions, and he asks what we’re looking for. “I’m looking to upgrade to a CRV EX or EXL”. He leads us to his desk and looks to see what they have in stock. They have one, so far so good, and he heads off to find it.

Comes back, “sorry, it’s sold” … silence.

“Can you check the other dealers in your group? Do they have any”, my girlfriend asks.

“I don’t think so, they are pretty much all sold out, making room for the 2014s” he mumbles, but finally leaves to check after we insist he does.

While he’s gone we’re reading what they have in stock, since it’s up on the computer screen. They have a bunch of touring edition, one has been in stock for over 250 days. I think, perfect, if they are making room for the 2014s, maybe they’ll deal on one of these that’s just sitting there taking up space.

He comes back and tells us there are only two left in the province. Which I know is crap, we’ve called around, and we walked a bunch of lots on the long weekend when they were closed. But he tells us we could write up a deal on one…but he can’t guarantee it…because they have to do a dealer trade. It’s difficult, bla bla bla…

So, “What about the touring edition? What’s your best price on one of them?” He pulls out his calculator…basically adds the taxes and fees on. “$43000”

“Seriously? Sticker price, you can’t do better?”, “What’s the best you can do?”, etc, nothing, he finally comes down a grand. But won’t go to his manager and see if he can do better. Shit, pretend to talk to your manager. Anything. Make it look like you’re trying to make a sale. I’m frustrated and say “let’s go to a different dealer”. We leave, he still makes no effort to make a sale.

So we head to Ford to check out an Escape. I’m still annoyed, so call the Honda dealer and ask for the sales manager. I relay the story and explain it was the worst experience I have ever had buying a vehicle and if I was the manager, I’d want to know if my employees were that useless…you probably think you know what happens now, but you’re wrong.

The sales manager just says “That doesn’t sound like him, I’ll talk to him. Thanks.”

And that’s it…you’re the Sales Manager, a customer left, angry, with a horrible experience, you’re supposed to say “I’m sorry that happened, come back, asks for me, my name’s whatever, I’ll deal with you personally, and we’ll try and work something out”

So now I’m thinking of calling the General Manager, not because I think she should buy a car from there, but because two levels of your employees have made no effort whatsoever to make a sale. I’d want to know. Your salesman didn’t show us a vehicle, didn’t ask if we wanted to test drive one…seriously? That’s how you sell?

I’d prefer the in your face stereotypical salesperson, at least they are trying to do their job. That I could deal with.


Visual Studio Tip #1: Ignoring Whitespace when Comparing

When comparing files, it’s frustrating when the default compare, doesn’t ignore whitespace, and many differences are caused by spaces vs tabs.

Solve it, by adjusting the parameters DiffMerge uses.

In Visual Studio:

  1. Tools->Options
  2. Source Control->Visual Studio Team Foundation Server
  3. Click the Configure User Tools button.

Now add an item with the following settings.

  • Extension : .*
  • Operation : Compare
  • Command : C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\diffmerge.exe
  • Or: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\diffmerge.exe
  • Arguments : %1 %2 %6 %7 %5 /ignorespace

Entity Framework Tip #1: Loading Grandchildren

When calling .FindById(), it’s a relatively simple task, to have it include child properties explicitly. Simply add a lambda expression.

	myRepository.FindById(1, x=>x.ChildList);

This will ensure that the ChildListis populated and not null.

But what if you need to ensure a GrandChildren entity is populated as well? Writing this won’t work because ChildList is a collection.

	myRepository.FindById(1, x=>x.ChildList.GrandChildren);

What you need to do, is use .Select()


Simple…albeit non-intuitive.