Skip to content

Instantly share code, notes, and snippets.

View praschl's full-sized avatar

Michael Praschl praschl

View GitHub Profile
@praschl
praschl / HtmlFormatter.cs
Last active May 24, 2018 17:26
Format JObject as HTML
public class HtmlFormatter
{
#region Public Methods
public void Format(JObject item, TextWriter writer)
{
writer.WriteLine("<table>");
foreach (JProperty property in item.Properties())
{
@praschl
praschl / Diff
Last active January 31, 2018 13:34
A simple Diff algorithm with example
// Algorithm taken from
// http://devdirective.com/post/91/creating-a-reusable-though-simple-diff-implementation-in-csharp-part-1
// http://devdirective.com/post/109/creating-a-reusable-though-simple-diff-implementation-in-csharp-part-2
// http://devdirective.com/post/115/creating-a-reusable-though-simple-diff-implementation-in-csharp-part-3
// Site is not available anymore
const string FIRST = "Hello, beautiful world, I like you"; // -lie
const string SECOND = "Hello, incredible world, I love you!"; // +ös
@praschl
praschl / QueryTfsBuilds
Last active October 2, 2017 07:55
Query running builds on TFS
TimeSpan maxBuildAge = TimeSpan.FromMinutes(15);
void Main()
{
var coll = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://sv-int-tfs-02:8080/tfs/DefaultCollection"));
var buildService = coll.GetService<IBuildServer>();
var spec = buildService.CreateBuildQueueSpec("*", "*");
spec.CompletedWindow = maxBuildAge;
@praschl
praschl / CSharpClassFromSqlGeneratorExtensions
Created August 24, 2017 13:15
LINQPad Extensions to generate Class and Insert Statements from SQL
// DumpClass: this.Connection.DumpClass("SELECT * from finalpdfpageinfo")
// DumpInsert: this.Connection.DumpInsert("SELECT * from finalpdfpageinfo")
public static class CSharpClassFromSqlGeneratorExtensions
{
private static readonly Dictionary<Type, string> TypeAliases = new Dictionary<Type, string> {
{ typeof(int), "int" },
{ typeof(short), "short" },
{ typeof(byte), "byte" },
{ typeof(byte[]), "byte[]" },
@praschl
praschl / CreateBitmapGrid
Last active April 3, 2017 21:41
Creates a bitmap, draws a grid on it, and copies it to clipboard... easier than installing whatever plugins into Paint.Net
const int IWidth = 320;
const int IHeight = 320;
const int RWidth = 16;
const int RHeight = 16;
Bitmap b = new Bitmap(IWidth, IHeight);
Graphics g = Graphics.FromImage(b);
g.Clear(Color.Transparent);
@praschl
praschl / capslock_remap_alt.ahk
Last active August 8, 2017 13:25 — forked from Danik/capslock_remap_alt.ahk
Autohotkey Capslock Remapping Script. Makes Capslock function as a modifier key to get cursor keys etc. on the left side of the keyboard, so you never have to move your hand to the right.
; The original script can be found at https://gist.github.com/Danik/5808330 (forked from there)
; Adapt to german layout:
; Capslock + Z - PageUp (changed from Y)
; And some new key remappings for better accessibility of {[]}\/ and adapt to german layout:
; Capslock + ( - [
; Capslock + ) - ]
; Capslock + ? - \
; Capslock + / - {
; Capslock + = - }
; Capslock + - - /
@praschl
praschl / NullableValuesTest.cs
Last active March 1, 2016 19:51
Shows a problem in RavenDb 3 with queries for nullable Values, when the queried value is a property of an item in a collection of the aggregate root
// required references:
// Microsoft.VisualStudio.QualityTools.UnitTestFramework
// Raven.Abstractions (3.0)
// Raven.Client.Lightweight (3.0)
// Raven.Database (3.0)
// System
// Sstem.ComponentModel.Composition
using System;
using System.Collections.Generic;