Marius Gheorghe

Building software : make it work, make it good, make it fast

Darksiders : The Abomination Vault



Pretty good read. Expands the Darksiders universe in a interesting way (although the this story "happens" before the first Darksiders game) and fleshes out the characters of Death and War a bit more. Too bad Strife and Fury don't get more "screentime".

Saving a synchronization context switch with await

If you're not interested in using the result of a async method on a UI thread (which happends implcitely when awaiting a method from the UI thread), you can save a synchronization context switch by using :

await DoMyStuffAsync().ConfigureAwait(false);

Passing false to ConfigureAwait will prevent the switch to UI thread.

Rumored Surface pricing

So today possible Surface (the "cheap" version of Surface) prices were leaked152 directly on microsoftstore.com153

If those prices are real, that's a shame. It basically means Microsoft is not really in a position to take on Android right now. Windows 8 it's a great OS (from my point of view if the best Microsoft OS to date) but it sure will need some help to gain some traction. And the hardware pricing doesn't seem to help.

I guess we'll see more in the following days when the Surface price will be confirmed.


Update : Prices are real. Available for preorder here154

Async wrongly named

I was thinking that await keyword has to be one of most "wrongly" named keyword (volatile being the other contender) from the language. I noticed that most people when learn about async + await have the impression that the current thread "stops" when encounters the await keyword (obviously not the case).

Maybe "concurrent" or even "parallel" would have been better.

Fixing the “Unable to activate Windows store app” problem

I had a nasty problem today with Windows 8 dev license and packaging an app for Windows Store. Basically after i have created a package for Windows Store, my Windows dev license expired. I dutifully updated the license and then lo and behold....everytime i wanted to run/debug the solution from Visual Studio i got this :

"Unable to activate Windows Store app. The activation request failed with error 'The application cannot be started. Try reinstalling the application to fix the problem."


Looking at the Event Log i found out that the app cannot be started because it's in state "17". Brilliant.

Googled for this problem and found some stuff here150151. Unfotunately none of those stuff worked for me.
The working fix for me was to create a new Windows Store project , move the files from older one (without Package.appxmanifest, Package.StoreAssociation.xml, *.pfx ) and voila....it runs fine now.

Speeding Windows startup with Autohotkey

 

It's kind of painful to watch my HDD led indicator when Windows starts. Blinks like crazy trying to launch all my startup apps. And i hate it because i have no control about the order. I want Autohotkey launched first because i use hotkeys to launch other apps and i usually have to wait until pidgin, skype etc start up (skype especially, with its 17 mb exe, starts especially slow)

So i basically decied to optiomize this by only starting Autohotkey automatically and have hot key to launch all other useful startup apps. Here's how it looks :

;run at startup
#+a::
{
   if(work_computer = true)
   {
        Run c:\dropbox\utilities\mouseemu\mousemu.exe
        Run c:\Program Files\clcl\clcl.exe
        Run c:\dropbox\utilities\virtuawin\virtuawin.exe
        Run c:\Program Files (x86)\winsplit revolution\winsplit.exe
        Run c:\Program Files (x86)\pidgin\pidgin.exe
   }   
   else
   {
        Run e:\dropbox\dropbox\utilities\mouseemu\mousemu.exe
        Run c:\Program Files (x86)\clcl\clcl.exe
        Run e:\dropbox\dropbox\utilities\virtuawin\virtuawin.exe
        Run c:\Program Files (x86)\winsplit revolution\winsplit.exe
        Run c:\Program Files (x86)\pidgin\pidgin.exe
        Run c:\Program Files (x86)\utorrent\utorrent.exe
   }

   return
}

I use the work_computer var because im using this script on multiple computers and paths are different. And, yeah, i keep some portable apps in dropbox.....easiest way to keep app settings in sync.

 

 

Resharper 7 XAML member navigation

 

Resharper 7 member navigation (Cltr + F12 for old school R# users) breaks in XAML if you have a resource dictionary which doesn't inherit directly from ResourceDictionary. The inheritance chain is something like MyDictionary  : DictionaryBase : ResourceDictionary.

 

ExeLauncher - fix PATH var on Windows

For me one of the most annoying thing under Windows is that the PATH entries are not recursive. Install and app and you can't launch from command line because the PATH var hasn't been updated with new path. This quickly becomes annoying. My attempt to fix this is building a command line app which scans a few predefined folders and launches the app.

Here's how it is in action

 

Grab it from Codeplex153

Setting up SublimeText 2 with Mingw

 

 

Here's how you can set up ST2 to work with Mingw:

- add the Mingw bin path to system Path env variable;

- rename ming's mingw32-make.exe to make.exe

- create a file called "makefile" (no extension) in the project's folder and update it accordingly to your project.

- in ST2 make sure the build system is "Automatic"

- press Cltr +B and it should work

 

 

Later edit : the final version of Sublime Text 2 changed some stuff to the build process, so it's easier to create a new build (tools/Buil System/Create New Build) and just paste

{
    "cmd": ["mingw32-make.exe"]
}

This is basically inovke mingw32-make in the same folder as the currently opened file. If you have a valid makefile there it should work fine.

TortoiseSVN and SSH

 

This is basically the easiest way to enable SSH with TortoiseSVN (and most importantly WITHOUT using putty)

- open the TrortoiseSVN settings and click Edit for SVN config file.

- find the ssh line under [tunnels] section

- edit the line to include the path to tortoiseplink.exe. Here is a sample :

"ssh = C:\\Program Files\\TortoiseSVN\\bin\\tortoiseplink.exe -i c:\\private.ppk -l marius"

The first path is to tortoiseplink, the second is the path to your private key and the l parameter is for your user name (if your private key is protected with a password you must also inlcude this). Save and exit.

 

Async brainteaser

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
class Program
{
    static void Main(string[] args)
   {
      (new A()).Run();
      Console.WriteLine("end main");
      Console.ReadLine();
   }

}

public class A
{
    public async void Run()
    {
      await Task.Run(() =>
     {
       X();
       Console.WriteLine("end x ");
     });

        Console.WriteLine("end run"); }

     public void X()
     {
       for (int i = 0; i < 500; i++)
       {
         long f = 12345 * 12;
       }
     }
  
  }

}

 


Run this code (requires async ctp or vs 11 ) and try to guess the order of items written at console. Also run it multiple times and study the results...

Reminescing about the past. Part I

Don't know exactly why but i thought i should write about some of my "computing" experiences from my childhood. My first "computer" was a CIP 03.


cip03

This bad boy was produced by the romanian company Electonica and it was basically a ZX Spectrum156 clone (not sure if legal or not).

I have to say that unlike other people i basically become interested in computers because of games (a passion/hobby which i still have +25 years later). To get my parents to buy me a CIP 03, i kind of tricked them into thinking that one would help me a lot in school (for math) and that i would learn programming (not really interested in that back then).


And what fun times i had with this little machine. Playing the entire Dizzy collection157 (Spellbound was the best), Midnight Resistance, Operation Wolf, River Raid and all the other great games were one of the happiest moments of my childhood. Heck i remember even now the sound the game was doing when it was loading off the cassette tape (beep, beeep, beeeeep, brrrrrrr :)
Incidentally, my first contact with reading/writing code was because, sometimes, i wanted to cheat in games (infinite lives FTW). On same games, after loading for 7-8 seconds, you could temporarely stop the loading process and modify the values of some variables by writing a few lines of BASIC code.


That was basically it....writing a few lines of code to cheat in a game was the spark that ignited the passion for programming and discovering how that machine works.

My Visual Studio

Here are my Visual Studio 2010 settings & customizations. I'm using a black theme made by me (i call it MoonSorrow) . Here is how it looks in action :

If you want to try it here are the files :


- This is the VS Color Theme Editor156. Make sure you have the VS Color Theme editor installed to use it.

- my complete Vs settings file157 (be very careful with this and make a backup of your settings before importing this one).

- and finally my Resharper settings file 158 which includes the custom code formatter. Obviously back up your R# settings before trying out this one.

 

That' all. Happy Visual Studio customization :)

Versioning often deployed web apps

1

 

 

Sometimes i deploy Shopkeeper 2-3 times a day. Bringing value to the customer one little step at the time. In this case, obvioulsy, the classic versioning scheme doesn't really works. So, for a deployed version of Shopkeeper, the version is the Mercurial revision id from which it was built.
Here is how this works in practice :


- when i do a deployment build i also generate a file with data about the current revision

- the output is

- and finally displaying the version in the actual customer website:

My trip to London

So, i've been to London last week. Very interesting trip. I've been away on a business related problem but still managed to have some fun. London, as a city is very interesting and, obviously, there's a lot to see there (my favorite was the British Museum. Holy crap there are A LOT of interesting stuff to see there). One thing i wasn't such a big fan of was the brits pronunciation. I remember that in the first day there i, basically, was asking everyone to repeat what they were saying because i just couldn't understand what the heck they were saying. Awkward.

Been staying at a old friend (hi Gary) and had a lot of fun. Went to a few pubs (beer is great by the way,seems to me is a bit stronger than the stuff back home) with Gary. Also i played around with a Zenbook (liked the machine itself but hated the keyboard). One thing that almost blew me away was the speed of the internet connection. Gary had O2 broadband and the speed was incredible for me (i guess it's not really a secret that internet connections in eastern europe kind of suck. The speed is just "good enough" i guess). One test i have done was the Gmail test (back home while Gmail is loading i can see while that progress bar is loading). On Gary's connection the progress bar was at 100% percent and then the page just appeared. Good stuff.

Also attended (along with Gary obviously) to a local web design meeting group. Has a few interesting discussions with a few people about CSS3 and how the media queries will take over the world :)

Overall it was a great trip and i had a few , well deserved i might add, free days.