Skip to content

Instantly share code, notes, and snippets.

View sharwell's full-sized avatar
🏠
Working from home

Sam Harwell sharwell

🏠
Working from home
  • Tunnel Vision Laboratories, LLC
  • Houston, Texas
  • X @samharwell
View GitHub Profile
@sharwell
sharwell / nuspec.md
Last active May 29, 2025 14:22
A schema definition for NuGet specifications suitable for use with Visual Studio's IntelliSense.

A schema definition for NuGet specifications suitable for use with Visual Studio's IntelliSense.

Installation

To use this file:

  1. Download the file to your Visual Studio XML schemas folder. For example:
    • Visual Studio 2010: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas
    • Visual Studio 2012: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Xml\Schemas
  2. Make sure to specify the XML namespace in your .nuspec file. If you previously used , change it to
@sharwell
sharwell / pom.xml
Created August 12, 2013 19:13
A general Maven configuration that can be used for projects with ANTLR 4 grammars. This configuration works great in NetBeans, but additional configuration may be required for use in Eclipse.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.yourgroup</groupId>
<artifactId>yourartifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>YourProjectName</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@sharwell
sharwell / CustomIdentityProvider.cs
Created November 21, 2013 14:48
This example shows a `CustomIdentityProvider` class which can perform OpenStack authentication with the `tenantId` and/or `tenantName` properties which are not supported by the default `CloudIdentityProvider`.
public class CloudIdentityWithProject : CloudIdentity
{
/// <summary>
/// Gets or sets the project ID for this identity.
/// </summary>
/// <value>
/// The project ID for this identity. The value may be <c>null</c> if the particular
/// provider supports authenticating without a project ID.
/// </value>
public ProjectId ProjectId
@sharwell
sharwell / SampleQueues.cs
Created December 3, 2013 23:51
Cloud Queues example using multiple programming strategies
namespace OpenStackNet.Testing.Unit.Providers.Rackspace
{
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using net.openstack.Core.Domain.Queues;
using net.openstack.Core.Providers;
using net.openstack.Core.Synchronous;
using Newtonsoft.Json;
@sharwell
sharwell / Wrapping.cs
Created January 29, 2014 17:24
Infinite loop, or clean wrapper?
static class Helper
{
public static T WrapCall<T>(Func<T> func)
{
Console.WriteLine("Calling function");
return func();
}
}
class Foo
@sharwell
sharwell / FunnyCalls.cs
Created January 29, 2014 18:36
The assertions in the test method all pass. Read carefully :)
[TestMethod]
public void TestCalls()
{
FooDerived foo = new FooDerived();
Func<int> method = foo.Bar;
Assert.AreEqual(1, method());
method = foo.FooBar();
Assert.AreEqual(1, method());
@sharwell
sharwell / CaseInsensitiveStringStream.cs
Created February 19, 2014 05:10
Case-insensitive ANTLRStringStream for ANTLR 3
using Antlr.Runtime;
public class CaseInsensitiveStringStream : ANTLRStringStream
{
// the string used for lookahead (performance improvement by not having to call Char.ToLowerInvariant())
private readonly string _lastring;
public CaseInsensitiveStringStream(string input, string sourceName)
: base(input, sourceName)
{
@sharwell
sharwell / CaseInsensitiveInputStream.java
Created March 8, 2014 03:00
Case insensitive input stream for ANTLR 4
/*
* [The "BSD license"]
* Copyright (c) 2012 Terence Parr
* Copyright (c) 2012 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
@sharwell
sharwell / Program.cs
Created April 1, 2014 11:24
TreePatternTest in C#
namespace TreePatternTest
{
using System;
using System.Collections.Generic;
using Antlr4.Runtime;
using Antlr4.Runtime.Tree;
using Antlr4.Runtime.Tree.Pattern;
class Program
{
@sharwell
sharwell / Test.cs
Created April 20, 2014 18:16
Reversing an RFC 6570 URI Template
namespace Testing.Rfc6570
{
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rackspace.Net;
[TestClass]
public class SampleTest
{
[TestMethod]