Skip to content

Instantly share code, notes, and snippets.

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

Sam Harwell sharwell

🏠
Working from home
View GitHub Profile
@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 / 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 / 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 / nuspec.md
Last active May 13, 2023 23:02
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 / ExampleDefinitions.cs
Created April 19, 2013 15:16
Simple example to export the `ContentTypeDefinition`
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Utilities;
public static class ExampleDefinitions
{
/* The language name (used for the language service) and content type must be the same
* due to the way Visual Studio internally registers file extensions and content types.
*/
[Export]
[Name("Example")]
@sharwell
sharwell / ExamplePackage.cs
Created April 19, 2013 15:11
Minimal implementation of `Package` to register and provide an implementation of `IVsLanguageInfo`.
using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
using IServiceContainer = System.ComponentModel.Design.IServiceContainer;
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#111", "1.0")]
[ProvideLanguageService(typeof(ExampleLanguageInfo), "Example", 100)]
[ProvideLanguageExtension(typeof(ExampleLanguageInfo), ".e1")]
@sharwell
sharwell / ExampleLanguageInfo.cs
Created April 19, 2013 14:33
A minimal implementation of `IVsLanguageInfo`
using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.TextManager.Interop;
[Guid("your guid here")]
internal class ExampleLanguageInfo : IVsLanguageInfo
{
public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr)
{
@sharwell
sharwell / pom.xml
Last active January 23, 2022 15:55
Maven pom.xml to support automatic code generation for ANTLR 4 grammar(s) during an Eclipse build. This configuration does not support (and is not intended for) building using Maven alone.
<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.uiuc</groupId>
<artifactId>cchistory</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CodeCompletionWithHistory</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@sharwell
sharwell / opentempfile.java
Last active December 12, 2015 04:48
NetBeans API: Create and open a temporary in-memory file with explicit non-serialized semantic data.
FileSystem fileSystem = FileUtil.createMemoryFileSystem();
// Store the actual text that will be displayed to the memory file system
FileObject tempFileObject = FileUtil.copyFile(FileUtil.toFileObject(inputFile), fileSystem.getRoot(), inputFile.getName(), "linterp");
DataObject od = DataObject.find(tempFileObject);
EditorCookie ec = od.getLookup().lookup(EditorCookie.class);
Document opened = ec.openDocument();
if (opened != null) {
// here I add the additional data as a property to the Document without needing to serialize it
opened.putProperty(LexerDebuggerEditorKit.PROP_INTERP_DATA, lexerInterpreterData);
@sharwell
sharwell / SimplePolicy.g
Created December 19, 2012 16:35
Example grammar from email to the antlr-discussion group: https://groups.google.com/d/topic/antlr-discussion/KpjR95MfAKE/discussion
grammar SimplePolicy;
options {
language = Java;
backtrack = true;
}
@header {
package com.manager.impl;