Normalize range of values

Normalize range of values

double scaleMin = 0; //the normalized minimum desired
double scaleMax = this.ActualHeight; //the normalized maximum desired

double valueMax = data.Max();
double valueMin = data.Min();
double valueRange = valueMax - valueMin;
double scaleRange = scaleMax - scaleMin;

var normalized =
    data.Select(i =>
        ((scaleRange * (i - valueMin))
            / valueRange)
        + scaleMin).ToArray();

Posted on Wednesday, November 18, 2015 7:19 AM

TAB pressed on WinForm

To determine if the TAB key was pressed on a WinForm, over ride the ProcessCmdKey event.

I created a custom control of NumericUpDown and added a check when lost focus if IsTabPressed

public bool IsTabPressed { get; set; }

protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, Keys keyData)
    IsTabPressed = (keyData == Keys.Tab);
    return base.ProcessCmdKey(ref msg, keyData);

Posted on Wednesday, November 11, 2015 7:45 AM

Find computer from command line

net view | find /i "partial name"

Posted on Friday, October 23, 2015 7:16 AM

Dynamically get/set property

Dynamically get/set property

// GET
var x = this.Model.GetType().GetProperty("PropertyName").GetValue(this.Model, null);
// SET
this.Model.GetType().GetProperty("PropertyName").SetValue(this.Model, newValue);

Posted on Wednesday, October 21, 2015 9:08 AM

Eye Tracking Sensor

Creating an eye tracking app using a BlueGain EOG Biosignal Amplifier to wirelessly connect to a computer and using a Matlab script reading the EOG data. Integrating with .Net.

Posted on Friday, October 02, 2015 8:20 AM

Tour de Tonka 2015

Riding Tour de Tonka 8/1/2015 100 mile route with Kelly Fitz. Rose volunteered with Annette Barrett to direct people at corner of CR6 & 92.

Posted on Saturday, August 01, 2015 12:00 AM

VS2013 Developer Command Line

Using Windows Explorer, navigate to:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2013

In that folder, you'll see a shortcut named Visual Studio Tools that maps to (assuming default installation):
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts

Double-click the shortcut (or go to the folder above).

From that folder, copy the shortcut named Developer Command Prompt for VS2013 (and any others you find useful) to the first directory (for the Start Menu). You'll likely be prompted for administrative access (do so).

Once you've done that, you'll now have an icon available for the 2013 command prompt.

Posted on Tuesday, July 14, 2015 10:48 AM

Linq - query distinct using object

Code to get distinct on objects

var params = values.Where(w => w.something == "something").DistinctBy(d =>;

public static IEnumerable<TSource> DistinctBy<TSource, TKey>
    (this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    HashSet<TKey> seenKeys = new HashSet<TKey>();
    foreach (TSource element in source)
        if (seenKeys.Add(keySelector(element)))
            yield return element;

Posted on Tuesday, April 21, 2015 6:15 AM

Adaptive Object Model

Working on software that is using Adaptive Object Model.

Architectures that can dynamically adapt to changing requirement are sometimes called reflective or meta-architectures. We call a particular kind of reflective architecture an Adaptive Object-Model (AOM). An Adaptive Object-Model is a system that represents classes, attributes, relationships, and behavior as metadata. It is a model based on instances rather than classes. Users change the metadata (object model) to reflect changes to the domain model. AOM stores its Object-Model in XML files or in a database and interprets it. Consequently, the object model is adaptive; when the descriptive information for the object model is changed, the system immediately reflects those changes.

Posted on Saturday, April 04, 2015 5:48 AM

File path problems - Visual Studio - FileListAbsolute.txt

FileListAbsolute.txt are generated or updated when build. Get latest from source control and copied the project(s) to different folders to work on 'new' version. The FileListAbsolute.txt still has the paths to the other folders. Even though my reference is to the dll I want, I noticed that the actual file being referenced is to the FileListAbsolute.txt pathed version. Delete the FileListAbsolute.txt files and they are regenerated when rebuild all.

Posted on Monday, February 16, 2015 7:58 AM