Skip to content

Instantly share code, notes, and snippets.

@automatonic
automatonic / UriTemplateTableWildcardPrecedence.cs
Created September 9, 2015 21:18
Some tests to investigate the precedence/priority of UriTemplate wildcards in a UriTemplateTable for C#
var baseUri = new Uri("foo://testy");
//Test1 - "*"
var templates1 = new Dictionary<UriTemplate, object>()
{
{ new UriTemplate("*") , "[star]" },
};
var templateTable1 = new UriTemplateTable(baseUri, templates1);
templateTable1
@automatonic
automatonic / FindConflictingReferences.cs
Last active September 22, 2017 07:13 — forked from WaffleSouffle/FindConflictingReferences.cs
LinqPad version that runs in the location of the .Linq file http://share.linqpad.net/e9ne3q.linq
<Query Kind="Program">
<Namespace>System.Collections.Generic</Namespace>
<Namespace>System.IO</Namespace>
<Namespace>System.Linq</Namespace>
<Namespace>System.Reflection</Namespace>
</Query>
public class Reference
{
public AssemblyName Assembly { get; set; }
@automatonic
automatonic / keybase.md
Created March 5, 2015 23:54
Keybase.io Proof

Keybase proof

I hereby claim:

  • I am automatonic on github.
  • I am automatonic (https://keybase.io/automatonic) on keybase.
  • I have a public key whose fingerprint is 5F41 1C2F F989 A131 7AB2 DC9E 1F9D 7E6B 4AEE 5D31

To claim this, I am signing this object:

@automatonic
automatonic / XNamespaceXDocument.cs
Created January 13, 2015 03:55
Get XDocument descendants when an xmlns is in play
XNamespace ns = "http://somedomain.com/some/path";
//if file.xml root element has xmlns="http://somedomain.com/some/path"
var descendants = XDocument.Load("file.xml").Descendants(ns + "Child");
@automatonic
automatonic / example.boxstarter
Last active February 22, 2019 14:35
An example boxstarter.org setup script
#As described here: http://boxstarter.org/Learn/WebLauncher
#The command to run, built from the raw link of this gist
#START http://boxstarter.org/package/nr/url?https://gist.github.com/automatonic/7771dfd7015a72453091/raw/4cbbf4811d11929ebe0f98c51f04e7476179c13f/example.boxstarter
#Special windowsy stuff. see http://boxstarter.org/WinConfig
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
Enable-RemoteDesktop
Install-WindowsUpdate
Disable-InternetExplorerESC
@automatonic
automatonic / ValidateXmlWithXsd.cs
Last active July 29, 2020 12:01
Programmatically validate an XML document with an XSD (XML Schema)
//License: MIT
//using System.Xml;
//using System.Xml.Schema;
public static List<ValidationEventArgs> ValidateXmlWithXsd(string xmlPath, string xsdPath)
{
XmlSchemaSet s = new XmlSchemaSet();
var args = new List<ValidationEventArgs>();
using (XmlReader reader = XmlReader.Create(xsdPath))
{
//These validations will be from reading the xsd itself
@automatonic
automatonic / gist:3783025
Created September 25, 2012 16:39
SWIGing to C#: Batch rename member variable prefixes
//Handle "m_TypeName" cases without lowercase hungarian notation prefix, avoiding the other cases
%rename("%(strip:[m_])s", match$ismember="1", regexmatch$name="m_[^lbsd].*$") "";
//We can interpret the above as:
//Rename all identifiers
// + that are class members
// + and have a "m_" prefix
// + but don't have a "m_s|m_l|m_b|m_d" prefix (they will be dealt with later)
// + from their original text
// + to a "strip"ped version that removes the "m_" portion
//Into Intermediate (P/Invoke) Class
%pragma(csharp) imclassimports=%{
using System;
using System.Runtime.InteropServices;
//The above are in the default version, additions follow:
using System.Collections.Generic;
using Some.Other.Namespace;
%}
//Into Generated Module Class (for globals, etc.)
@automatonic
automatonic / upcoming_examples.html
Created September 23, 2012 03:55
upcoming.js examples
<html>
<head>
<!-- Project Page - http://github.com/automatonic/upcoming -->
<title>upcoming.js Example</title>
<!-- include the default styling file for upcoming.js-->
<link rel="stylesheet" type="text/css" media="all" href="upcoming.css" title="system" />
<!-- include the JavaScript routines that make upcoming.js work-->
<script type="text/javascript" src="upcoming.js"></script>
</head>
@automatonic
automatonic / MurMurHash3.cs
Created September 14, 2012 22:46
MurMurHash3 .Net (C#) implementation
/*
This code is public domain.
The MurmurHash3 algorithm was created by Austin Appleby and put into the public domain. See http://code.google.com/p/smhasher/
This C# variant was authored by
Elliott B. Edwards and was placed into the public domain as a gist
Status...Working on verification (Test Suite)
Set up to run as a LinqPad (linqpad.net) script (thus the ".Dump()" call)
*/