The methods to calculate mean, variance, and standard deviation of a vector of values. These are put here for easy reference, so that I do not need to rewrite them again.
The following method is a utility method for creating the K divisions upon which one is going to perform the K-fold cross validation operation. The input of the method is the length of the training data, and the number K. The output says which indices of the training-data is to be put in each division.
I needed a piece of code to manage list-view controllers. I needed to use
ListView controls in the details mode, which automatically sort its contents when I click on the header, and also pastes the content in a tabular format when I press Ctrl+C or Ctrl+Insert on it. So I created the following classes. It is necessary to note that the code that carries out the sorting stuff when the header is clicked is taken from the following MSDN article:
So these are the contributions of these pieces of code: 1) Sorting
ListView items automatically when the header is clicked, 2) Pasting the contents of the
ListView control to the clipboard in a tabular format, and 3) Providing an easy to use API to append data to a
The following gist contains the code to accomplish this. It consists of 3 files. The
ListViewColumnSorter.cs file is responsible for the sorting stuff. The
ListViewUtils.cs file provides the utility methods for a
ListView control. The main methods that perform the job are located in the
ListViewUtils class. The two needed methods are
AppendToListView. And finally the
Usage.cs file provides a small sample demo of the utility methods.
The following method trims the given string of both white-space characters and control characters, and its rather fast!
The following pieces of code help you figure out how two intervals overlap, and provides tools to represent them in a way that is useful for debugging purposes. This job is quite easy to accomplish, but since it is written too frequently each time from scratch, I have put them in this gist.
IntervalOverlapKinds.cs file defines the
IntervalOverlapKinds enumeration. The interval detection is carried out in the static methods of the
This piece of code is useful if you intend to work on a string processing algorithm. There are times, that you need to see the real content of a string while showing them in a windows form, console, and so on. This little method may help:
Suppose that you intend to find a string or a token (i.e., whole word, instead of a substring) and change their color in some
RichTextBox. The following code snippets will help. The
FindStringAndSetColor method looks for instances of an arbitrary string in the contents of the
RichTextBox, while the
FindTokenAndSetColor method looks for whole words (tokens).