Jun 24, 2013

Use an optical cable to get surround from your HTPC

I've been running my Ubuntu based XBMC HTPC for over a year now, and problems have been few and far between. But recently I started having issues with the sound of a show I'm watching. I only got the message "failed to initialize audio device" - which made a few bells go off. I have had the same issues previously, but just used a different file (ahem) and got sound from that.

So, it turns out, these last files were AAC-encoded, as opposed to for example, mp3. After some googling, I  finally realized the main thing everybody were saying was you can't have AAC over HDMI. You have to use SPDIF output for that (like an optical cable). That's fine, I have an optical port on my receiver, and on my HTPC.

So to get this to work (specific to my Ubuntu/XBMC setup) I had to:
1) Enable HD Audio output to SPDIF in my BIOS settings. They were default set to HDMI.
2) Connect the optical cable to the HTPC and the AV receiver.
3) Change XBMC's audio settings to output "Digital/Optical", tick the boxes for AC3 enabled and DTS enabled receiver, and finally play around with the bypass and audio devices - what worked for me was iec859 device 1, but you have to try the different ones available to you.

You can see the different devices using the command aplay -l, it's output looks like this:
Output of aplay -l
So according to this, choose the "device 1 iec859" option in XBMC - do not choose device 1 hdmi, for instance, that's just XBMC being a little ignorant.

Now I have no problems playing any files, and I get surround sound whenever it's available!


Apr 24, 2013

Get an MVC web site up and running on Azure in 15 minutes

Updated November 9, 2016 to reflect the changes to Visual Studio, Team Services and Azure.
If you want to set up an MVC web site, this is possibly the easiest way.

I was really impressed after setting up a site this way the other day, and it's completely free (at the time of writing, anyway, and not including domain name registrations or your time). Microsoft are really getting the hang of it this time.

So here are the necessary steps:

  • If not installed, download and install Visual Studio. The community version is fully featured and free for students, open-source and individual developers.
  • Register a free project at Visual Studio Team Services (it's free up to 5 devs). Choose between TFS and GIT as the version control system.
  • Create a new MVC project, and check the box for "add solution to source control". Now paste the URL you got from the last step, to link it to your Team Services account.
  • Add a windows azure web site to your azure account (it's free to create a trial ). Notice that you don't have to specify the kind of web site, Team Services automatically figures that out and configures it from your MVC project.
  • Link it to your project by clicking on "Integrate source control" and select Team Services, then the URL you created when signing up.
  • Create site, check in - and bam! It builds and deploys your web site to the cloud.  

I don't know 'bout you, but I think that's pretty nifty. You can now view your web site in the address you specified for the web site, it should be on the form "myawesomewebsitename.azurewebsites.com".

Optional steps:

Have fun!

Apr 10, 2013

Windows Phone 8 - My Experience

After a long two and a half months of waiting, I finally got my Windows Phone. My previous phone was a Samsung Galaxy S2, before that, a Sony Ericsson W715. And before that, I was a Windows Mobile user with HTC S30 and the Qtek 9100. Those two phones really put me off the thought of  a phone with Windows on it.

But after attending MSDN Live in Oslo 2012, I was intrigued by Windows Phone 8 as well as the hardware from Nokia. I guess the fact that I work as a Microsoft .NET developer didn't hurt, either.

As you can see, the start screen on my phone is quite appealing (at least I think so) - and without a single widget or a grid of stylized iCons.


Windows Phone 8 - Start screen



When I got the phone, my first impressions were all good. I didn't have to charge it before using it for the first time, I didn't have to read any manual, and I already had my Microsoft account, SkyDrive, Office365, and what not. The menus were fast, animations subtle and cool, nothing felt like it was slow or not  working. Integration with Skype and Office products were smooth as expected. Even different social networks and e-mail were supported out of the box. Nice going! (I did run into a small problem with getting my gmail contacts over to Microsoft, but that turned out to be my own fault)

Then, I visited the Windows Phone Store. And, well, I wasn't psyched by what I found. While using Android, I've grown accustomed to some apps and services that I wanted to bring with me to my new device. Particularly, Instagram and Dropbox. Neither are available (officially) on WP8. There are some limited third-party apps that bring some of the functionality, but not the official app. I found the facebook app to be weak compared to the (last) Android version as well, with my feed not being filtered properly any more, and finding people was surprisingly difficult.

Two apps that really deserve praise are Wimp and Skydrive. Skydrive is my new dropbox, and it works much in the same way, except I have much more space there. Pictures and music automagically synced, and the OneNote app is great instead of Wunderlist and Evernote, that I used on Android.

Internet Explorer works fine, though I do wonder if a better solution to tabbed browsing can be made available, and there are some sites that don't play nice (a Norwegian newspaper is all white - http://m.db.no ).

I should mention I also enjoy the Twitter app, but I'm pretty new to Twitter so I don't know the Android version.

However, there are some things that could be improved. Even Skydrive has a big drawback. For instance, I preordered a new album from Steven Wilson, and got a digital copy as well. Downloaded the .zip, sent it to Skydrive, and there it was. But even though my phone recognized it, and even had a zip icon, it was not possible for me to download the file or extract it on my device. I understand, now, that there's no getting access to the file system. No file manager, either. What about File Explorer for Windows Phone? Why can't we have that?

When resuming any app, it takes ages to restore the state. I guess some processing must take place, but in the event that the screen switches off when I'm reading, it's annoying to watch the "resuming..." animation for two seconds.

Connectivity settings (Wifi, GPS, Bluetooth) are well hidden, and you have to go into the settings menu to change them. There should be a way to pin on/off as a tile to the start screen! I know there are apps for this too, but it would be simpler.

The same is true for the sound options, you have to go through the settings menu and turn off vibrate and sound to go in silent mode. Huh?

I've had the phone reboot on several occasions, though it hasn't happened for the last week or so. At one point I was sure it was related to sending MMS to several contacts at once, but that wore off as well. It may in fact be a hardware issue, of course.

I suspect the 4G module to be a little unstable as well, since after turning that off, I have a lot more battery capacity and a lot less reboots.

Some things are rather undocumented features, such as the screenshot (start + power) and the reboot (volume down + power for 10 secs!), while others have gone away  - I used to enjoy that the Lumia would jump straight from lock screen to camera when I clicked the camera button, but that was removed in an update :(

All in all I'm quite happy with Windows Phone 8 as a mobile operating system. Once I got the hang of it, and tuned it to my liking, I'm happily using it every day. I would like to see the minor issues that I've mentioned resolved, especially the "resuming..." is very annoying, and a step back from where I was on my Samsung Galaxy S2.

I wouldn't go back just yet, though, and lately the Windows Phone store has been releasing new and promising apps.


Mar 4, 2013

How to get Android contacts to your WP8 phone

I just got my Nokia Lumia 920. Wee! I've been waiting since November last year, so... yeah.

The first thing I needed to do when I got it, was getting my contacts over. Last time I checked, it was just to add my google account, tell it to sync e-mail, contacts and calendar - and there you are. But not so much in my case.

I though it may have something to do with Google removing support for the ActiveSync protocol, but that apparently has been postponed until July 2013. Still, I think it's better to be prepared and do it the right way, right now - so you don't wake up in August wondering where your contacts have gone.

First, go to your Android device and check that you are syncing your contacts to google. Oh, you are? That's what I thought. Now check the last time they were synced... that was the real issue, on my device. Apparently, when I switched jobs and moved all my exchange contacts over to google, it did just that. But only locally... and for over a year, I was thinking my contacts were safe! Anyway, click the little symbol to sync now, and wait for your contacts to appear over in gmail contacts.
Choose to add Google contacts here

Google contacts added successfully!

When they are synced, go to outlook.com and the "people" hub and select Google contacts from the menu, like in the screenshot. then you should see the import guide to the right, with facebook, linkedin and gmail. If you don't see gmail in there, you have already set that up, and can relax. You should be able to see the google logo to the right on the screen, like in the second screenshot.

Now the last step is of course to log in using the same account as in the last step on your Windows Phone and sync contacs.

I'm sure I'll have some more blog entries when I've been using my phone a little, so stay tuned if you're curious about Windows Phone 8.

Jan 3, 2013

Keeping data safe - Part three

The previous part was about partitioning, and this part is about mirroring. As it turns out, not having to restore from a backup at all, is the most efficient way of avoiding data loss.

One way of ensuring your data is to mirror it continuously, usually by mirroring the whole disk. A drawback of data mirroring is cost - you need at least two disks, which means the price doubles. That is where partitioning steps up and says hey, you don't need to mirror everything - just put the important bits on the mirrored drive.  You usually don't have more than a 256 GB disk of personal data (I know many who have less  - a few have a lot more), which means you can have a small-ish set of drives for mirroring.

It actually makes sense not just because of the price tag, but because of the time it takes to rebuild the drive.

The benefit of this setup is quite easy to see, because recovering data from a hard drive failure can be very expensive, and always takes a certain amount of time. And even if you have a backup, you risk data loss because when did you perform a backup the last time? Even if it's a few hours ago, it doesn't help much if the work you did after, is gone.


How to set up mirroring

Strictly speaking, there are two ways of mirroring, one is by hardware, which you set up in your computer's BIOS, the other one is software based and can be done from the operating system.


In either case, you'll just see it as a regular hard drive on your system, but behind the scenes there are two drives, and every write action is performed on both disks. If one fails, the system automatically fails over to the working one. Hopefully you'll also get a message about the failure, but this depends on the software.

I'll just quickly go through the built-in feature in Windows 7. Go to Disk management (either click through Control Panel, Administrative tools, Computer Management , Storage and hit Disk Management - or just write disk management and click on "Create and format hard disk partitions" or from the run dialog, write diskmgmt.msc). Right click the disk you want to mirror, and select "Add mirror..."  This option is only available if a suitable disk exists. You can also remove mirrors the same way.

Windows 8 has a new feature called "Storage Spaces" that provides the option to mirror or distribute data over several disks. You'll find a nice review of this feature at howtogeek.com.



Things Takes Time

A word of caution here, (re)building an array of disks takes time. I have two 2 TB disks mirrored, and whenever I hit blue screen or reboot or system crash of any type (last time, way back in 2012) I couldn't really exhale until some 6 hours later... because meanwhile, the status of the array was "rebuilding". It basically means going through every bit on the one drive and replicating it on the other. And if the working drive fails during that time, you are in a hard place. (So if you're really really paranoid about losing anything, you might want to keep a spare drive handy, or even go for a heavier RAID setup, like RAID 5, which involves more hardware, but has a higher fault tolerance)



Windows does not do a good job in telling you if something's wrong with the mirror (it does hint something with a shout-out just after booting, but you have to sit there to notice it), so you need separate software. Or, you can go to Disk management, where you'll see the status of the array (I've highlighted the relevant bits). You see the two red disks, "disk 0" and "disk 2", they are both assigned to G: - if I go to Explorer, I'll just see one instance of G:.  You'll also see it reports a 50% overhead, which is correct. I have 2x 2TB = 4TB disk space, but only 2 TB is available. 50% is lost, because it's mirrored.



Next part will be about continuous backup, or using services that let's you forget about backup. Stay tuned.