Skip to content

Instantly share code, notes, and snippets.

View mfcollins3's full-sized avatar

Michael Collins mfcollins3

View GitHub Profile
@mfcollins3
mfcollins3 / Server.coffee
Created February 26, 2012 23:52
Node.js (CoffeeScript) HTTP server that allows a Git client to clone a repository from an HTTP server
connect = require "connect"
child_process = require "child_process"
spawn = child_process.spawn
url = require "url"
getInfoRefs = (req, res) ->
res.setHeader "Expires", "Fri, 01 Jan 1980 00:00:00 GMT"
res.setHeader "Pragma", "no-cache"
res.setHeader "Cache-Control", "no-cache, max-age=0, must-revalidate"
res.setHeader "Content-Type", "application/x-#{req.query.service}-advertisement"
@mfcollins3
mfcollins3 / hg.pl
Created May 2, 2012 04:25
Microsoft Source Server plug-in to index PDB files based on a Mercurial repository.
# ------------------------------------------------------------------------
# hg.pm
#
# Source Server module to handle adding version control information to
# PDB symbol files for source code that is stored in a Mercurial
# repository.
#
# Copyright (c) 2010 ImaginaryRealities, LLC
# ------------------------------------------------------------------------
@mfcollins3
mfcollins3 / Program.cs
Created May 10, 2012 14:30
Node.js application that spawns a .NET application to query Active Directory and return a user's profile
namespace ADUserProfile
{
using System;
using System.DirectoryServices;
using System.Globalization;
using Newtonsoft.Json;
/// <summary>
/// Program that will query Active Directory for a user's
@mfcollins3
mfcollins3 / ClientProgram.cs
Created September 20, 2012 17:54
This Gist demonstrates how to use WCF with MSMQ to handle dead letters or poison messages.
namespace Client
{
using System;
using System.ServiceModel;
using Contracts;
internal class ClientProgram
{
public static void Main(string[] args)
@mfcollins3
mfcollins3 / gist:4448042
Last active December 10, 2015 14:29
PowerShell function that will find a Windows Installer component in the registry and will delete the component.
# This function will accept component GUIDs from the pipeline
# and will attempt to find and delete the component records
# in the Windows Installer registry hive if they exist.
#
# For whatever reason, Windows Installer reverses the GUIDs
# when creating the component records in the registry. This
# function implements the logic for reversing the GUID values
# and building the correct registry key for each component.
function Remove-WindowsInstallerComponent {
$flags = [System.Text.RegularExpressions.RegexOptions]::Compiled -bor [System.Text.RegularExpressions.RegexOptions]::Singleline
@mfcollins3
mfcollins3 / GenerateVersionInfo.xml
Created January 24, 2013 16:44
Classes for using semantic version numbers with .NET applications. For more information, see <http://www.michaelfcollins3.me/blog/2013/01/23/semantic_versioning_dotnet.html>.
<!--
The GenerateVersionInfo task will generate the VersionInfo.cs file with the
metadata for the current build.
-->
<UsingTask TaskName="GenerateVersionInfo"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
@mfcollins3
mfcollins3 / CaptureProgramDebugOutput.cs
Created June 2, 2013 21:31
Windows console mode program that will capture debug trace messages written by a process using OutputDebugString and will write the messages to standard output
// Copyright 2013 Michael F. Collins, III
// This program will enhance the previous sample by running
// a program as a child process and only outputting the debug
// messages from the child process to standard output.
using System;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Text;
@mfcollins3
mfcollins3 / NativeMethods.cs
Created June 29, 2013 06:03
Process Monitor is a great tool for finding and solving problems with programs in production environments. Along with the usual events that Process Monitor captures and logs, Process Monitor allows developers to send log messages to be included in the log so that process events can be correlated to program source code. This Gist contains the sou…
internal static class NativeMethods
{
[DllImport("kernel32.dll", CallingConvention = CallingConvention.WinApi,
EntryPoint = "CloseHandle", ExactSpelling = true, SetLastError = true)]
internal static extern bool CloseHandle(IntPtr handle);
[DllImport("kernel32.dll", CallingConvention = CallingConvention.WinApi,
CharSet = CharSet.Unicode, EntryPoint = "CreateFileW",
ExactSpelling = true, SetLastError = true)]
internal static extern IntPtr CreateFile(
@mfcollins3
mfcollins3 / ProcessPeople.cs
Created July 18, 2013 15:51
Example that uses the TPL Dataflow library to process XML records and output a formatted string.
using System;
using System.Globalization;
using System.Threading.Tasks.Dataflow;
using System.Xml.Linq;
internal class Program
{
private static void Main()
{
var inputBlock = new BufferBlock<string>();
@mfcollins3
mfcollins3 / NeuronEsbBlock.cs
Created July 18, 2013 18:12
Sample TPL Dataflow block that shows a custom dataflow block for Neuron ESB parties. The NeuronEsbBlock class can be used either as a source block or a target block in a dataflow pipeline.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using Neuron.Esb;
public sealed class NeuronEsbBlock : IDisposable,
IPropagatorBlock<ESBMessage, ESBMessage>,
IReceivableSourceBlock<ESBMessage>