Here is a sample tt template (sample.tt):
<#@ output extension=”.txt” #>
<# for(int i =0; i < 10; i++) {#>
<#=i #>
<# }
#>
<#@ include file=”testme.t4″ #>
I can see how useful this can be in reducing repetative code.
Random outpourings of a software developer
Here is a sample tt template (sample.tt):
<#@ output extension=”.txt” #>
<# for(int i =0; i < 10; i++) {#>
<#=i #>
<# }
#>
<#@ include file=”testme.t4″ #>
I can see how useful this can be in reducing repetative code.
This is a powershell version of get-service that works across remote machines (provided that you have sufficient access to the box).
function Get-ServiceRemote($computerName = “.”)
{
Get-WmiObject win32_service -ComputerName . | sort Name | select SystemName,State,Name,DisplayName
}
This can be passed through ft -Auto to become more readable.
A few scripts like these could be of great use in checking the state of a remote system.
I have been looking at how to easily consume json from C#.
Given the source of the data I don’t want to create specific types (I’ll be creating a dynamic wpf control to allow editing of json read from a configuration database).
This requires newtonsoft.json to be pulled from nuget and a reference made to newtonsoft.json.
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SimpleJsonTest
{
class Program
{
static void Main(string[] args)
{
string json = @"[{""First"":""Chris"",""LastName"":""Pietschmann""}, {""First"":""Chris"",""LastName"":""Eyre""}]";
List<Dictionary> values = JsonConvert.DeserializeObject<List<Dictionary>>(json);
Console.WriteLine( string.Join(",", values[0].Keys));
Console.WriteLine(string.Join(",", values[0].Values));
Console.WriteLine(string.Join(",", values[1].Values));
Console.ReadLine();
}
}
}
This is a wonderful article on using StudioShell with the visual studio debugger.
This artictle shows how to script the local variables of the currently debugged process.
Given StudioShell has out-html and out-chart this allows the dynamic creation of visualised data straight from the current debug session.
StudioShell is a powershell console that is embedded into visual studio (it can also be invoked from the NuGet console).
It exposes the visual studio extension api known as dte as a set of powershell scripts.