Separate column in two columns Oracle and output as HTML

(Representation, business logic and data layer should really be separated! Because of this this statement sucks.)

http://www.sqlfiddle.com/#!4/d998f/8

CREATE TABLE YourTable
  (Column1 int, Column2 varchar(1))
;

INSERT INTO YourTable VALUES(1, 'a');
INSERT INTO YourTable VALUES(2, 'b');
INSERT INTO YourTable VALUES(3, 'c');
INSERT INTO YourTable VALUES(4, 'd');
INSERT INTO YourTable VALUES(5, 'e');
INSERT INTO YourTable VALUES(6, 'f');
INSERT INTO YourTable VALUES(7, 'g');
INSERT INTO YourTable VALUES(8, 'h');
INSERT INTO YourTable VALUES(9, 'i');
INSERT INTO YourTable VALUES(10, 'j');

SELECT '' || listagg(htmlRow) within group (order by null) || ''
FROM
(
  SELECT '' || MAX(CASE WHEN mcol = 0 THEN legendcell END) || '' || MAX(CASE WHEN mcol = 1 THEN legendcell END) || '' AS htmlRow
  FROM 
  (
    SELECT 
      (CASE WHEN t1cRowNumber>t2cDivider then t1cRowNumber-t2cDivider else t1cRowNumber end) as mrow, 
      (CASE WHEN t1cRowNumber>t2cDivider then 1 else 0 end) as mcol, legendCell 
    FROM 
    ( 
      SELECT 
        t1cRowNumber, 
        TRUNC(t1cRowCount / 2) + mod(t1cRowCount, 2) as t2cDivider, 
        legendCell 
      FROM  
      ( 
        SELECT 
          ROWNUM AS t1cRowNumber, 
          COUNT(*) OVER () as t1cRowCount, 
          legendCell 
        FROM 
        ( 
          SELECT 
            (Column1 || '' || Column2) as legendCell 
          FROM 
            YourTable 
          WHERE 
            Column2 IS NOT NULL ORDER BY Column2
        ) legend 
      ) t1c
    ) 
  )  
  GROUP BY mRow  
  ORDER BY mRow 
)

Recursively ping server until it is back online

@setlocal enableextensions enabledelayedexpansion
@echo off

set ipaddr=localhost
:: The next variable refers to the Windows version "language" for example en->Received or de->Empfangen
set receivedAlias=Received

:loop
for /f "tokens=5,7" %%a in ('ping -n 1 !ipaddr!') do (
if "%%a"=="!receivedAlias!" if "%%b"=="1," goto :end
)
clear
echo Still down.
goto :loop

:end
mshta javascript:alert("Back online!");close();

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")
                                .List<object[]>()
                                .ToLookup(
                                    values => values[0].ToString(),
                                    values => values[1].ToString(),
                                    StringComparer.OrdinalIgnoreCase
                                );

                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...
            }
            else
            {
                if (convert) code = MyMappingLookup.Value.First();
            }

            return code;
        }

.NET: Microsoft Unity – Strange error message

Having this error?

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

German:
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

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

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

Solution:

// 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); 
}