Skip to content

Instantly share code, notes, and snippets.

Thomas Freudenberg thoemmi

Block or report user

Report or block thoemmi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Keybase proof

I hereby claim:

  • I am thoemmi on github.
  • I am thoemmi ( on keybase.
  • I have a public key ASD1LqmfVwJ9qgVmFamgIyLV28FTLDOwzDiIph2oyBtA9go

To claim this, I am signing this object:

thoemmi / EnumFlagsConverter.cs
Created Sep 5, 2018
JSON Converter for enum flags
View EnumFlagsConverter.cs
public class EnumFlagsConverter : JsonConverter
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
var x = ((Enum) value).ToString();
var list = new List<string>();
foreach (var v in x.Split(new[] {", "}, StringSplitOptions.RemoveEmptyEntries))
thoemmi / Create-WorkflowDiagramFromWitd.ps1
Last active Feb 10, 2020
This Powershell scripts generates a nice workflow diagram from a TFS work item template definition file. See for details
View Create-WorkflowDiagramFromWitd.ps1
[Parameter(Mandatory=$true, HelpMessage="Path to work item template definition file")]
# path to dot.exe; e.g. use "choco install graphviz"
$dotPath = "C:\ProgramData\chocolatey\bin\dot.exe"
thoemmi / Clear-NuGetCache.ps1
Created Apr 21, 2017
Script to delete old NuGet packages from %USERPROFILE%\.nuget\packages which haven't been accessed for 150 days
View Clear-NuGetCache.ps1
[int]$CutoffDays = 150
$cutoffDate = (Get-Date).AddDays(-$CutoffDays)
# get path to cached NuGet packages ("%USERPROFILE$\.nuget\packages")
$nugetCachePath = Join-Path "$([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile))" ".nuget\packages"
View EncryptingJsonConverter.cs
public class EncryptingJsonConverter : JsonConverter {
private readonly byte[] _encryptionKeyBytes;
public EncryptingJsonConverter(string encryptionKey) {
if (encryptionKey == null) {
throw new ArgumentNullException(nameof(encryptionKey));
// Hash the key to ensure it is exactly 256 bits long, as required by AES-256
using (var sha = new SHA256Managed()) {
View FormatKbSizeConverter.cs
public class FormatKbSizeConverter : IValueConverter {
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
private static extern long StrFormatByteSizeW(long qdw, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszBuf,
int cchBuf);
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
var number = System.Convert.ToInt64(value);
var sb = new StringBuilder(32);
StrFormatByteSizeW(number, sb, sb.Capacity);
return sb.ToString();
thoemmi / UpdateVcxprojFiles.ps1
Last active Aug 29, 2015
Updates .vcxproj files to Visual Studio 2013 while still building against VS2012 platform
View UpdateVcxprojFiles.ps1
function UpdateVcxprojFile($filename) {
$content = [xml](Get-Content -Path $filename)
$changed = $false
$toolsVersion = $content.Project.ToolsVersion
if ($toolsVersion -ne "12.0") {
$content.Project.ToolsVersion = "12.0"
$changed = $true
View gist:8123604
using System.Diagnostics;
using Raven.Client.Embedded;
using Raven.Client.Listeners;
using Raven.Json.Linq;
namespace StackOverflow20764813 {
internal class Program {
private static void Main() {
using (var store = new EmbeddableDocumentStore { RunInMemory = true }) {
store.RegisterListener(new TestDocumentStoreListener());
thoemmi / gist:5613845
Created May 20, 2013
Regular expression for unsigned short
View gist:5613845
public class UshortRegexTest {
readonly Regex _ushortRegex = new Regex(@"^(
0 # 0
[1-9]\d{0,3} # 1-9999
[1-5]\d{4} # 10000-59999
6[0-4]\d\d\d # 60000-64999
View InitializeSQLProvider.ps1
# Add the SQL Server Provider.
# Source:
$ErrorActionPreference = "Stop"
if (Get-ChildItem $sqlpsreg -ErrorAction "SilentlyContinue")
You can’t perform that action at this time.