Wednesday, January 21, 2015

Unidentified network after moving/copying a virtual

1. Start a cmd prompt as admin
2. execute: set devmgr_show_nonpresent_devices=1
3. execute start devmgmt.msc
4. View > Show hidden devices
5. Expand network adapters
6. Click on adapters that appear to be disabled > right click > Uninstall

Sunday, January 11, 2015

You are wrong, not the library code

I was just reading through an algorithms book about quicksort, and stepping through the code, tracing through how it would sort "easyquestion". I ran into an infinite loop problem, and rechecked my steps several times. I assumed the algorithm in this book was wrong, and decided to implement it and run it to prove that it wasn't working. To my surprise it was working! I put a debugging condition in the spot where i was running into the infinite loop on paper, and realized my mistake. I mistakenly thought a break statement was breaking out of the outer loop, not one of the inner loops, resulting in bad index pointers, causing infinite recursion.

My mistake was quite stupid, and I was reading the code slightly wrong. This is the opposite of a typo. The underlying mistake though was that I assumed the book was wrong. Always assume your code is wrong, not the other guy's, until you have exhaustively checked and rechecked every possibility in your own code. 

Wednesday, January 7, 2015

How to use images with transparent backgrounds in Dynamics GP

I have PNG images that have transparent backgrounds, and when I paste them into Dexterity Picture / Native Pictures they lose their transparency.

1. Fill in your image's transparent background with this color:

2. Now copy&paste the image into Picture / Native Image in Dexterity

3. Now you can control the background of the image with the BackColor control!

How i figured this out

I figured this out by looking at other GP images and observing their behavior. I was looking at the Purchasing Que image on the SOP Entry window.
Purchasing Que image

I moved this to a different part of the form and noticed the background color was still the same. This button appears to have a transparent background though. So i changed the Back Color to something else, and it changed!

I haven't found anything about this in the documentation, but it seems to work for some reason.

Tuesday, January 6, 2015


Recursively sort the left and right side of the array, and then merge the results by looping through and picking the smallest element remaining during each iteration.

This is a divide and conquer algorithm. It breaks the problem down into many smaller, easier problems. 

Sort(array, left, right)
   If right <= left return

   mid = left + (right - left)/2 

    Sort(array, left, mid)
    Sort(array, mid+1, right)
    Merge(array, left, mid, right)


Merge(array, left, mid, right)
    Copy array to auxiliary array from left to right

    LeftPtr = left
    RightPtr = mid+1

    Loop through the auxiliary array from left to right
        Compare auxiliary[leftPtr] with auxiliary[rightPtr]
        Whichever one is bigger, or if there are none left on one side, put it in the array[loopIndex]
        Increment LeftPtr/rightPtr depending on which side got taken 


how to upgrade windows server 2012 evaluation version

1. Open a cmd prompt as administrator

2. Execute DISM /online /Set-Edition:<Your Edition ID Here> /ProductKey:<Your Product Key Here> /AcceptEula

Note: Standard edition ID is ServerStandard

3. Restart the server



Sunday, January 4, 2015

Shell sort

N = array.length
H = 1
While H < N/3 
     H = H * 3 + 1

While H => 1
    For I = H to N
       For J = I until J < H or array[J] < array[J-H]; J -= H
              Swap(J, J-H)

     H = H/3

Notice that when H=1 this becomes full blown insertion sort. Before the final pass what it's doing is partially sorting the array by moving out of order elements far distances, resulting in fewer costly inner loops in the final pass. For example, let's say H = 13 and array[13] < array[0]. They would be swapped. In the final pass (during full blown insertion) this potentially saves 13 inner loop swaps. 

Saturday, January 3, 2015

Insertion sort

For i = 1 to N
      For j = i until j is 0 or array[j] > array[j-1]; j--
            Swap j with j - 1

The array is already sorted from 0 to i - 1, so for the ith element we need to keep swapping it to the left until it's greater than its neighbor.

Selection sort


For i = 0 to N
     int min = i
     For j = i to N
           if array[j] < array[min]
              min = j
     Swap min with i

For each position in the array, find the smallest item to the right and swap it into the position. After each pass the array will be partially sorted to the left of the position.