Programmer Procrastination

Is when you have to do a quick fix, decide to do it, but refactor something unrelated, then read an article which mentions about Erlang; install the shell, try it, remember about the goroutines and channels concepts in Go; read the wiki for a quick refresh... check the clock, it's 5:00 pm and you don't know how the time passed in the last 3 hours. Let's hope is just a quick fix

(of course I also read the news, saw some random youtube videos, lurked on reddit, but that doesn't sound good, isn't it :) )
The Grape exists and I regret I didn't go there today. Had a great time in the past three weeks.

pseudo brainfuck with the help of C# operator overloading

Linq To Objects Extension: Full Outer Join

I need a report which shows a comparison of the sales of each service with the previous year. Some services might be new and they don't appear in the previous year, others might be put off and so there are no sales for them in the current year. There can be services sold in both periods.

SelectMany - projecting the index of the result

There are 4 overloads of the SelectMany method. Two of them project the index of each source element, for example:

string[] sentenceSequences = new string[] {"The quick brown", "fox jumped over","the lazy dog."};
// index - the position of the sequence in the sentenceSequences array
(sequence, index) =>
// check if index is on odd position and if so call ToUpper()
// ... put the sequence in other array, as the result
index % 2 == 0 ? new [] {sequence.ToUpper()} : new [] { sequence }

But there is no overload for projecting the index of the result also (the index of the element in the result sequence). So here an implementation of it:

public static IEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(this IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, int, TResult> resultSelector)

Inside job or when your developer decides to make public your sa password


TakeFive - what an extension

public static class LinqExtensions
public public static IQueryable<T> TakeFive(this IQueryable<T> query)
return query.Take(5);

Extract currency values from text with T-SQL

CREATE FUNCTION dbo.fnGetAmounts(@str nvarchar(max))
-- generate all possible starting positions ( 1 to len(@str))
WITH StartingPositions AS
SELECT 1 AS Position
SELECT Position+1
FROM StartingPositions
WHERE Position <= LEN(@str)
-- generate all possible lengths
, Lengths AS
SELECT 1 AS [Length]
SELECT [Length]+1
FROM Lengths
WHERE [Length] <= 15
-- a Cartesian product between StartingPositions and Lengths
-- if the substring is numeric then get it
,PossibleCombinations AS

WHEN ISNUMERIC(substring(@str,sp.Position,l.Length)) = 1
THEN substring(@str,sp.Position,l.Length)
ELSE null END as Number
FROM StartingPositions sp, Lengths l
WHERE sp.Pos…