Found some great freeware for cleaning up cookies, temp files, and even the registry. It's called Crap Cleaner and is available here:
http://www.ccleaner.com/
Sunday, July 22, 2007
Thursday, May 17, 2007
Quick Uncompression in Linux
Some common commands for uncompressing files in most Linux environments. For complete listing and options check the man pages.
.bz2
bzip -d
.tar
tar -xf
.gz
gzip -d
.bz2
bzip -d
.tar
tar -xf
.gz
gzip -d
Saturday, March 31, 2007
Simple MDI Application in C#
Multiple Document Interface (MDI) allow programmers to create multiple sub-windows within one main window. The following C# snippets show how to accomplish this.
First, set the main or parent window by adding the following code to the InitializeComponent method of that form:
this.IsMdiContainer = true;
Next, create and add the child form. The following code was added to a button_click function:
Form1 fm1 = new Form1();
fm1.MdiParent = this;
fm1.Show();
First, set the main or parent window by adding the following code to the InitializeComponent method of that form:
this.IsMdiContainer = true;
Next, create and add the child form. The following code was added to a button_click function:
Form1 fm1 = new Form1();
fm1.MdiParent = this;
fm1.Show();
Tuesday, March 20, 2007
Insertion Sort in C#
Insertion sort begins at the left side of an array, actually one from the left, and moves down the list keeping the left side sorted as it moves down the list. Because the first element is a list of one and therefore already sorted, the first element checked is the element to the right of that element (first element + 1). In this case we will assume the first element is at index 0 so the element one to the right of that is at index 1.
for (int i = 1; i < unsortedList.Length; i++)
The element currently selected element is then assigned to a temporary, local variable so that it can be moved and it's place can be overwritten as the elements to the left are traversed and shifted to the right.
int val = unsortedList[i];
A second local variable, "j" in this case, is created and assigned for traversing the list right to left from the current index being inserted ("i" here) in the left side. Since the temp value to be inserted is at i and the traversal is right to left in the inner loop, the temp variable, "j", is assigned as i -1.
int j = i-1;
From i it will check the temp value, "val" in this case, against i - 1, i - 2, etc.. As long the decrementing index, "j", is not 0 and the current value is less than the element on the left, it will move that element into it's place, "j+1", and then decrement j. Once the condition has been met that breaks out of the while loop, it is assumed that the element is as far left as it should go and put into that that slot which is j+1.
while (j >= 0 && unsortedList[j] > val)
{
unsortedList[j+1] = unsortedList[j];
j--;
}
unsortedList[j + 1] = val;
The full method as described above is below as written in C#. There are other versions that include other parameters and implementation options, this one just takes an existing array and sorts it.
public void insertionSort(int[] unsortedList)
{
for (int i = 1; i < unsortedList.Length; i++)
{
int val = unsortedList[i];
int j = i-1;
while (j >= 0 && unsortedList[j] > val)
{
unsortedList[j+1] = unsortedList[j];
j--;
}//end while
unsortedList[j + 1] = val;
}//end for
}//end insertionSort
for (int i = 1; i < unsortedList.Length; i++)
The element currently selected element is then assigned to a temporary, local variable so that it can be moved and it's place can be overwritten as the elements to the left are traversed and shifted to the right.
int val = unsortedList[i];
A second local variable, "j" in this case, is created and assigned for traversing the list right to left from the current index being inserted ("i" here) in the left side. Since the temp value to be inserted is at i and the traversal is right to left in the inner loop, the temp variable, "j", is assigned as i -1.
int j = i-1;
From i it will check the temp value, "val" in this case, against i - 1, i - 2, etc.. As long the decrementing index, "j", is not 0 and the current value is less than the element on the left, it will move that element into it's place, "j+1", and then decrement j. Once the condition has been met that breaks out of the while loop, it is assumed that the element is as far left as it should go and put into that that slot which is j+1.
while (j >= 0 && unsortedList[j] > val)
{
unsortedList[j+1] = unsortedList[j];
j--;
}
unsortedList[j + 1] = val;
The full method as described above is below as written in C#. There are other versions that include other parameters and implementation options, this one just takes an existing array and sorts it.
public void insertionSort(int[] unsortedList)
{
for (int i = 1; i < unsortedList.Length; i++)
{
int val = unsortedList[i];
int j = i-1;
while (j >= 0 && unsortedList[j] > val)
{
unsortedList[j+1] = unsortedList[j];
j--;
}//end while
unsortedList[j + 1] = val;
}//end for
}//end insertionSort
Subscribe to:
Posts (Atom)