Lazy Lookup mapping

Can be used to cache values from database

     private static Lazy<Lookup<string, string>> MyMappingLookup = new Lazy<Lookup<string, string>>(() =>
            using (var session = SessionFactory.GetSession())
                var result = session
                                .CreateSQLQuery("select foo, bar from whatever where bananas")
                                    values => values[0].ToString(),
                                    values => values[1].ToString(),

                return (Lookup<string, string>)result;

        private static string CheckOrConvertBanana(bool convert = false)
            var code = "red_pyjamas";

            if (string.IsNullOrEmpty(code) || !MyMappingLookup.Value.Contains(code))
                // not found, warning...
                if (convert) code = MyMappingLookup.Value.First();

            return code;

.NET: Microsoft Unity – Strange error message

Having this error?

The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.Resolve(System.Type, string, params Microsoft.Practices.Unity.ResolverOverride[])' cannot be used with type arguments

Methode 'Microsoft.Practices.Unity.IUnityContainer.Resolve(System.Type, string, params Microsoft.Practices.Unity.ResolverOverride[])' ist nicht generisch und kann daher nicht mit Typargumenten verwendet werden.)

Try adding “on top”:
using Microsoft.Practices.Unity;

.NET: Easy asynchronous method and callback

Ok so you have a user interface with a button. The button should trigger a really slow function, which takes for example a minute.

If you put the function in an action listener like “Button_Click_1″, your application will hang up for a minute.


// 1/4
public delegate void SlowTaskDelegate(string bananaDescription);

// 2/4
public void SlowTask(string bananaDescription)
    for (var i = 0; i < 1000; i++)
        Logging.AddDebug(bananaDescription + i.ToString());

// 3/4
public void SlowTaskCompleted(IAsyncResult result)
    AsyncResult asyncResult = (AsyncResult) result;
    MessageBox.Show((string) asyncResult.AsyncState + " has finished.");

// 4/4
private void Button_Click_1(object sender, RoutedEventArgs e)
    var task = new SlowTaskDelegate(SlowTask);
    IAsyncResult result = task.BeginInvoke(banana.Text, 
                                           new AsyncCallback(SlowTaskCompleted), 
                                           "Hello, the item " + banana.Text); 

Linux Mint: Restore / Reset ignored notifications

So you accidentally hit the big “Don’t show this message again” button in Lnux Mint? There is a way to restore the dismissed notification in Linux Mint:

Depending on which version you’re running:


AFAIK for versions lower than Linux Mint 13 you have to:

  1. Go to Menu and search for Software Manager
  2. Install gconf-editor
  3. Go to Menu and search gconf-editor
  4. Scroll to / ▸ apps ▸ nm-applet and uncheck messages you want to appear again


AFAIK for Linux Mint 13 (and perhaps above) you have to:

  1. Go to Menu and search for Software Manager
  2. Install dconf-tools
  3. Go to Menu and search dconf-editor
  4. Go to org ▸ gnome ▸ nm-applet and uncheck messages you want to appear again

This question on AskUbuntu has some explanatory pictures.