Aug 08 2018

The proper way to use HttpClient

Most people are mostly using .net HttpClient the wrong way.  This is because HttpClient implements IDisposable which makes people think they should wrap it in a using statement.  Also, most code example on the interwebs show that usage including a lot of documentation from Microsoft.

Wrong. Wrong. Wrong.

Here is a great Code Project article on it.  It takes a “recipes” approach which makes it even better…

https://www.codeproject.com/Articles/1194406/Using-HttpClient-as-it-was-intended-because-you-re

Seth

May 25 2018

Comment by Seth Spearman on Search Sublime Text 3 for files that doesn’t contain a specific string

Amazing. Great answer. Worked perfectly.
May 25 2018

Comment by Seth Spearman on Search Sublime Text 3 for files that doesn’t contain a specific string

Amazing. Great answer. Worked perfectly.
Oct 27 2017

To map each bit in a single byte to individual bools do this (using c#)

Implemented as two extension methods in this example. Using an enum to get the bit your looking for.

public enum Weekday
{
    Sunday=7,
    Monday=6,
    Tuesday=5,
    Wednesday=4,
    Thursday=3,
    Friday=2,
    Saturday=1
}

public static bool GetBitwiseBool(this byte bits, Weekday weekday)
{
	return (bits & (1 << (int)weekday - 1)) != 0; 
} 

public static bool GetBitwiseBool(this string bits, Weekday weekday) 
{ 
    if (!bits.All(c=>"01".Contains(c)))
	{
		bits = "11111111";
	}
	
	//8 character or less
	if (bits.Length>8)
	{
		bits = bits.PadLeft(8,'0');
	}

	var myByte = Convert.ToByte(bits, 2);
	return myByte.GetBitwiseBool(weekday);
}

Aug 30 2017

Comment by Seth Spearman on Understanding the recursive CTE termination check

I'll have to check out that dense_rank() function. But thanks...awesome solution.
Aug 30 2017

Comment by Seth Spearman on Understanding the recursive CTE termination check

I'll have to check out that dense_rank() function. But thanks...awesome solution.
Aug 30 2017

Comment by Seth Spearman on Understanding the recursive CTE termination check

sorry I was looking for a fiddle. The one in the comments above was not from you which I didn't notice...but sure enough your code does work. Here it is in a fiddle... sqlfiddle.com/#!6/b6587/36
Aug 30 2017

Comment by Seth Spearman on Understanding the recursive CTE termination check

sorry I was looking for a fiddle. The one in the comments above was not from you which I didn't notice...but sure enough your code does work. Here it is in a fiddle... sqlfiddle.com/#!6/b6587/36
Aug 30 2017

Comment by Seth Spearman on Understanding the recursive CTE termination check

,looking at my sqlfiddle, can you get sql fiddle to return in the order I am requesting? Your union would return all "headers" and then all "details". the ORDER is really the imortant thing in this question...header/details ... header/details. I thought recursion "might" solve this problem.
Aug 30 2017

Comment by Seth Spearman on Understanding the recursive CTE termination check

,looking at my sqlfiddle, can you get sql fiddle to return in the order I am requesting? Your union would return all "headers" and then all "details". the ORDER is really the imortant thing in this question...header/details ... header/details. I thought recursion "might" solve this problem.