Skip to content

Instantly share code, notes, and snippets.

View philipstears's full-sized avatar

Philip Stears philipstears

View GitHub Profile
Imports DriveWorks.Specification
<Condition("Is Not Owner", Nothing)>
Public Class IsNotOwner
Inherits Condition
Protected Overrides Function Evaluate(ByVal specificationContext As SpecificationContext) As Boolean
Dim currentUser = specificationContext.Group.CurrentUser.Id
Dim creator = specificationContext.Group.Specifications.GetSpecification(specificationContext.Id).CreatorId
<Task("Name", "embedded://DriveWorks.MyImagePlain16.png", "Category")> _
Public Class DoSomethingWithOpenSpecification
Inherits Task
Private Sub New()
End Sub
''' <summary>
''' Overridden to indicate that a running specification is required by the task to execute.
''' </summary>
@philipstears
philipstears / Release and Swap a COM reference.vb
Created May 27, 2011 09:49
Release and Swap a COM reference
<Extension()>
Public Sub ReleaseAndExchange(Of T As Class)(ByRef oldComObject As T, ByVal newComObject As T)
If oldComObject IsNot Nothing Then
Marshal.ReleaseComObject(oldComObject)
End If
oldComObject = newComObject
End Sub
@philipstears
philipstears / FlipBits.cs
Created November 27, 2012 14:15
FlipBits
/// <summary>
/// Flips the order of the bits in the passed-in byte.
/// </summary>
/// <param name="original">The byte whose bits should be flipped.</param>
/// <returns>A byte containing the flipped bits.</returns>
private static byte Flip(byte original)
{
return TABLE_FLIP[original];
}
module PubSub {
interface ISubscription {
(...args: any[]): void;
}
interface IDictionary {
[name: string] : ISubscription[];
}
var registry : IDictionary = {