Dream, not what is, but what can be.

CSV with data containing comma

using Microsoft.VisualBasic.FileIO; //Microsoft.VisualBasic.dll
using (var csvReader = new TextFieldParser(fileName))
    csvReader.SetDelimiters(new string[] { "," });
    csvReader.HasFieldsEnclosedInQuotes = true;

    while (!csvReader.EndOfData)
         string[] row = csvReader.ReadFields();

Posted on Friday, June 17, 2016 12:20 PM

Azure Internet of Things (IoT)

Putting together an IoT concept app using Azure IoTHub, Service Bus, Event Hubs, Streaming Analytics, and Power BI using my MSDN credits. Good stuff. Next I will hook it up to a mobile app for an end to end demo.

Posted on Friday, April 22, 2016 6:40 AM

Azure Event Hub

Putting a ; at the end of an Azure Event Hub connection string causes an Invalid Token Error. Wow, frustrating.

Posted on Friday, April 22, 2016 6:39 AM

Clear IP addresses

To clear out cached IP addresses.

System.Diagnostics.Process.Start("ipconfig", "/renew");

// or to hide command window

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = "ipconfig";
p.StartInfo.Arguments = "/renew";

Posted on Friday, April 08, 2016 8:51 AM

Get a registry value

Get a registry value, for instance the "version"

Version version = null;
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"<path>"))
    if (key != null)
        System.Object o = key.GetValue("version");
        if (o != null)
            version = new Version(o as String);

Posted on Tuesday, December 08, 2015 2:05 PM

Infinity Symbol

PlatformKey typeDescription
PC windowsAlt+236Hold the ALT key and type 236 on the num-lock keypad.

Posted on Saturday, December 05, 2015 8:23 AM

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