Wednesday, September 30, 2015

Raspberry Pi / Windows 10 Iot - Getting Started

Microsoft updated their Iot Windows 10 content for several platforms, including the Pi.  I started from scratch getting my Pi hardware installed with Windows 10 (core) on the Pi, then proceeded to use Visual Studio 2015 to get my lil' LED light blinking.  Surprisingly I was able to stay within Visual Studio the entire time to write the C# code (no Mono involved), compile, deploy, and execute the application remotely on the Pi (oh yes...even debug the code executing remotely on the Pi).  The latest help/instructions from the Microsoft side have been updated to walk you through the steps in enough detail to be successful without having to search to the end of the Internet for answers.

Here are a few links that lay out the short journey (all you need to have is your Pi assembled).  The last link is the new C# Microsoft GPIO (General Purpose Input/Output hardware pin headers) library which makes is really nice to interface to the hardware.

Download Windows 10 for Raspberry Pi
http://ms-iot.github.io/content/en-US/Downloads.htm

Getting Started (select Raspberry Pi)
http://ms-iot.github.io/content/en-US/GetStarted.htm

Raspberry Pi Source Code Examples
https://github.com/ms-iot/samples/archive/develop.zip

C# Windows.Device.Gpio namespace
https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.gpio.aspx

Saturday, February 14, 2015

Powershell to add Read permission on all files in a directory

Recently I needed to update all the files in a specific directory, adding Read permission for the "Users" NTFS group.  Here is a Powershell script to do that.  It can be easily modified to update other users/groups or different permission sets.

$base = "C:\somefolder"
$files = get-childitem $base
foreach ($file in $files) {
    $Acl = Get-Acl $file.FullName
    $Ar = New-Object  system.security.accesscontrol.filesystemaccessrule("Users","Read","Allow")
    $Acl.SetAccessRule($Ar)
    Set-Acl $file.FullName $Acl
}

Wednesday, February 4, 2015

Basic rules for using ResolveClientUrl in master pages (ASP.NET)

When writing ASP.NET Web Forms, the basic rules for using ResolveClientUrl in master pages are:
<img src="<%= ResolveClientUrl("~/x/resource.jpg")%>" />
<script src="<%= ResolveClientUrl("~/x/resource.js")%>"></script>
If you want to use ResolveClientUrl in the master page <head> section for script tags:
<asp:PlaceHolder ID="PlaceHolder1" runat="server">
   <script src="<%= ResolveClientUrl("~/x/resource.js")%>"></script>
</asp:PlaceHolder>

You do not need to use ResolveClientUrl for CSS link elements in the <head> section (they will automatically be resolved by ASP.NET).

Friday, January 23, 2015

PowerShell: Get a unique list of file name extensions within a directory folder (and sub-folders)

Here is a basic PowerShell script that will provide you a nice list of unique file name extensions for a given directory path. Nothing fancy here, but comes in handle once and a while.

Notice the -Recurse parameter that will drill down every sub-directory as well; remove this if you only want the top level directory.

Get-ChildItem -Path C:\Scripts -Recurse | Select-Object Extension | Sort-Object Extension | Get-Unique -asString

Woo-hoo!

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...