Posts

Showing posts from 2016

Massive bug in DataRow in .NET Framework

Image
If the actual value of the timestamp column is 7080, notice how the datarow value gets flipped the other way when it is read into a DataSet! Wow! Massive bug in the .NET Framework.

How do I create access control rules from code for an azure cloud service?

Nobody had a solution, so I did it myself: http://stackoverflow.com/questions/40727003/how-do-i-create-access-control-rules-from-code-for-an-azure-cloud-service

How to reinstall all nuget packages if there are issues after moving folders

Update-Package –reinstall Querying the table storage by a timstamp column filter: Timestamp ge datetime'2008-07-10T00:00:00Z' - The month and the date have to contain two digits.

Migrating to Azure redis cache?

They are deprecating the inrole cache starting 2.9 SDK. It was trouble migrating it. I recommend you first install the session state provider for the redis cache and then use the strong named redis dll which comes with it for all other assemblies. If you first install the regular dll via nuget and then install the session state provider, it gets messed up.

Binary Search Algorithm in C# (min, max, middle position)

class BinarySearch     {         public static int Find(List<int> list, int searched)         {             // First sort input             BucketSort.Execute(list, ShellSort.Execute);             // Find min position             int min = 0 ;             // Find max position             int max = list.Count - 1 ;             int loops = 0;             do             {                 // Find middle position                 int middle = (min + max) / 2 ;                 if ( searched < list[middle] )                 {                     // Bring down max so we half the search span the next time.                     max = middle - 1 ;                 }                 else if ( searched > list[middle] )                 {                     // Bring up min so we can half the search span the next time.                     min = middle + 1 ;                 }                 else                 {                     Console.WriteLine($"Lo

Shell Sort Algorithm in C# (Insertion with middle position split)

class ShellSort     {         public static List<int> Execute(List<int> list)         {             // Start position is at the middle of the list.             var position = list.Count / 2 ;             // Iterate as long as we don't reach the "bottom"             while ( position > 0 )             {                 // Go through the entire list                 for (int i=0;i<list.Count;i++)                 {                     // Get current index                     var index = i;                     // Get current item                     var current = list[i];                     while ( index >= position &&                 // As long as we have not reached this position AND                             list[index - position] > current )    // Item at a more previous index greater than current                     {                         // Swap (travel more than one position)                         list[ind

Insertion Sort Algorithm in C# (Simple)

class InsertionSort     {         public static List<int> Execute(List<int> list)         {             // Iterate through entire list starting from 1             for (int i=1 ;i<list.Count;i++)             {                 var index = i ;                 // Get current item from list.                 var current = list[i] ;                 // While previous is greater than current                 while ( index > 0 && list[index - 1] > current )                 {                     // Swap                     list[index] = list[index - 1];                     // Go back                     index-- ;                 }                 // The current item is stored at the right position in the list.                 list[index] = current ;             }             return list;         }     }

MergeSort Algorithm in C# (middle)

class MergeSort     {         public static List<int> Execute(List<int> list)         {             if ( list.Count <= 1 ) { return list; }             // Find the middle point             int middle = list.Count / 2 ;             var left = new List<int>();             var right = new List<int>();             // Divide the list from the middle             for (int i=0;i<middle;i++)             {                 left.Add(list[i]);             }             for (int i=middle;i<list.Count;i++)             {                 right.Add(list[i]);             }             // Recursion to keep dividing and sorting.             left = Execute (left);             right = Execute (right);             // This indicates that sorting is done.             if ( left[left.Count-1] < right[0] )             {                 left.AddRange(right);                 return left;             }             // If sorting is not done... Mer

QuickSort Algorithm in C# (Pivot)

This is an interesting and relatively easy sort algorithm which is built around the creative use of recursion and a pivot point.     //A kind of exchange sort.     public class QuickSort     {         public static List<int> Execute(List<int> list)         {             // Return if nothing to sort             if ( list.Count <= 1 ) { return list ; }             // Find a random pivot point             var random = new Random();             var pivotIndex = random.Next(list.Count);             // Take out the pivot             var pivot = list[pivotIndex];             list.RemoveAt(pivotIndex);             // Lesser - Greater Lists             var lesser = new List<int>();             var greater = new List<int>();             // Sort around the pivot             foreach (var item in list)             {                 if ( item <= pivot )                 {                     lesser.Add(item);                 }              

Sort Algorithm in C# - Bubble Sort Explained

I did not like any of the examples of sorting algorithms in C# online. So, I decided to write it by myself with some good code, and not something which looks like it was written by people who have never done commercial software development before. Good code is readable and maintainable. You can quickly understand what the code does. This is the easiest sort algorithm. There are three variations of this algorithm: (1) The first one uses a while loop to go through the entire list as many times as even a single instance of unsorted items were found: public static void Type1 (List<int> list)         {             Console.WriteLine("Bubble Sorting");             var unsortedFound = false;             do             {                 unsortedFound = false;                 for (int i = 0; i < list.Count - 1; i++)                 {                     if ( list[i] > list[i + 1] )                     {                         var temp = list[i + 1];

Upgraded to SSD and got a feeling your PC is still too slow OR Optimizing Dell Precision T3610 for Performance

Change the SATA controller mode in the BIOS to AHCI mode. You can switch modes without affecting windows: 1) Switch to boot in safe mode using msconfig (boot options) 2) Restart 3) Enter BIOS, switch mode 4) Enter Safe Mode, login 5) Enter msconfig and switch back to regular boot 6) Restart Voila! It is 50% faster now!! Switch from Legacy to True UEFI BIOS You can switch this easily in the BIOS and not have to reinstall your OS if you keep the legacy ROM option. However, it is better to go to pure UEFI mode for storage controller as well. To be able to do this, before you switch over completely, use Rufus to generate a UEFI only Windows Install USB drive. On newer motherboards, the USB drive with UEFI/ Legacy option will work. For this Dell, for some reason, it will only recognize the UEFI only mode USB drive. Then install the OS and speed is good. If using GTX 960 or larger Video card Use the supplied adapter to connect two 12V rails to the video card. Th

Driving two Dell 4K monitors with the EVGA GEForce GTX 960 SSC

This is a monster card with 4GB RAM and more than enough horsepower for a DEV box. It was showing artifacts and the card would just stop the output of video to the monitors. I did contact EVGA who replied promptly to uninstall using a special utility all the display drivers and reinstall. That was the only way to get rid of the artifacts. To make the card not blow on me, I install EVGA Precision and I noticed my card was running at a high temperature of 63 C by default. I clicked the FAN CURVE button and changed the fan settings to aggressive. After that, the fan runs pretty fast and the GPU temperature is around 40 C. It seems to be stable now. I think this will work fine.

Assembling a PC from Microcenter parts

Firstly, I got an AMD CPU because even though Intel CPUs are better, unlike Intel, Intel does not change the socket design for CPUs in each generation as frequently as AMD. Because of this, when my CPU gets slow after a few years, I can go back and get the best CPU for that socket available at the time. This saves a lot of money. I used to have an old 1.8 GHz Opteron in my server. After 5 years, when it got too slow, I replaced it with the fastest CPU supported by the motherboard which was 2.8 GHz. I was able to use the PC as long as the motherboard did not die. So, it lasted for three more years (a very long time). I selected the FX 8350 over the FX 8370 because there is not much difference in performance compared to the price difference. http://www.microcenter.com/product/401795/FX_8350_4GHz_AM3_Black_Edition_Boxed_Processor Note that this CPU does not have 8 cores. It has 4 physical cores and something like hyper threading to make 8 processors show up in Windows. I got a b

Multi-threaded debugging with Visual Studio

Only F11 on one thread: http://stackoverflow.com/questions/13498810/visual-studio-f11-only-stepping-interested-in-what-a-particular-thread-is-doin "In Visual Studio, show the "Threads" window, available from the Debug->Windows menu. Then, while you are tracing using F11, if the debugger breaks in the thread you are not interested in, find this thread in the threads window, right-click it and choose the "Freeze" option in the context menu. Now when you continue to trace using F10 or F11, you will never hit breakpoints in the frozen thread. Note that the frozen thread will not be executing at all, so if you do need it to do some work while you are debugging, you may need to unfreeze and freeze it again from time to time." How to use the parallel watch window: https://msdn.microsoft.com/en-us/library/hh418499.aspx Debug Threads and Processes https://msdn.microsoft.com/en-us/library/ms164739.aspx

How to upgrade Sharepoint Internal Databases to 2013 on a Windows Server 2012 R2 box

You do this because you end up seeing messages in the health analyzer about databases not upgraded (you open it because your site stopped working): "The following databases have versions that are older than the current SharePoint software, but are within the backwards compatible range: User Profile Service Application_SocialDB_c364a011f36f4e9ba210bed78f964665, Search_Service_Application_AnalyticsReportingStoreDB_89dd14f5835d4d368b8912cb2ff2d17e, Bdc_Service_DB_29ef5f7ce1d14088bfbd5d63223872a2, SharePoint_Config_f82eb164-7374-435a-b987-c1766e914af3, AppMng_Service_DB_556cc2d02a9140e7887ed67db619001f, SharePoint_AdminContent_51fce7bf-6f79-45db-9682-fd7a104839ad, WSS_Content_318a3672-b982-4b1e-bc54-4181dfd3f8c0, Search_Service_Application_DB_cd636bd8e1d149f19dfcfba6b27937ae, User Profile Service Application_ProfileDB_cdd94abe9d66468685df50e618f0564f, WSS_Logging_4b6ad66f-2b8c-4e6f-9264-acba62dcc35b, Search_Service_Application_LinksStoreDB_b48f5e42753d4600a0ec6eb62e1602a9