Skip to content

Instantly share code, notes, and snippets.

wolf99 wolf99

  • Ireland
Block or report user

Report or block wolf99

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
wolf99 / BoilerplateSingleton.cs
Created Sep 1, 2017
C# singleton class pattern
View BoilerplateSingleton.cs
namespace Foo
/// <summary>
/// A class showing the bolierplate code for a singleton
/// </summary>
public sealed class BoilerplateSingleton // sealed to prevent derivatives adding non-singleton copies
// this class is a singleton, this field holds the single instatiated
// object. It is instantiated lazily, only being created when a
// reference to the object is requested via the Instance property
wolf99 / FilePathToFileUrl.cs
Created Aug 9, 2017
method to convert a file path to a URI
View FilePathToFileUrl.cs
// The System.Uri class can convert paths to URIs using new Uri(pathString).AbsoluteUri;
// However, that does not work if the path contains some characters, e.g. the percent
// sign or spaces. This method corrects that, it is taken from, explained and MIT
// licensed, here:
public static string FilePathToFileUrl(string filePath)
StringBuilder uri = new StringBuilder();
foreach (char v in filePath)
wolf99 / PaddedVersionToString.vb
Created Jun 9, 2017
A ToString() extension to the System.Version class, that allows specification of padding of the version parts
View PaddedVersionToString.vb
Option Strict On
Option Explicit On
Imports System.Text
Imports System.Runtime.CompilerServices
Module PaddedVersionToString
''' <summary>
''' Converts the value of the current Version object to its equivalent
''' String representation. Specified counts indicate the number of
wolf99 / BoilerplateINotifyPropertyChanged.cs
Created May 31, 2017
A boilerplate C# implementation of INotifyPropertyChanged
View BoilerplateINotifyPropertyChanged.cs
using System;
using System.ComponentModel; // For INotifyPropertyChanged interface
using System.Runtime.CompilerServices; // For CallerMemberName, could use nameof() otherwise
namespace FooProgram
public class BoilerplateNotify : INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
wolf99 /
Created May 18, 2017
TobyForTabs - FAQ For Fun

What is Toby?

Toby is grouchy. Toby wonders why you think you need so many damn tabs open at the same time anyway.

How does Toby work?

By finishing stuff (and with coffee). Then I can close some of those tabs.

Who uses Toby?

Hello magazine says that people that like to be in control of everything all of the time (like browser tabs) might be using Toby.

What are the benfits of using Toby?

wolf99 / isthreads.c
Created May 12, 2017
Quick C program to detect if standard C threads are supported by checking the `__STDC_NO_THREADS__` macro
View isthreads.c
#include <stdio.h>
int main (int argc, char *argv[])
// Get the compiler name and version, where easily obtained, for a more
// informative output
char *compilerName;
char *compilerVersion;
#if defined(__clang__)
compilerName = "Clang/LLVM";
wolf99 / GetDictionaryOfProperties.cs
Last active May 5, 2017
C# function to get a Dictionary of the names and values of the properties of a given object
View GetDictionaryOfProperties.cs
using System.Reflection
public class Gists
public Dictionary<string, object> GetDictionaryOfProperties(o As Object)
Dictionary<string,string> Properties;
Properties = (from x in o.GetType().GetProperties() select x).ToDictionary
( x => x.Name, x => x.GetGetMethod().Invoke (o, null));
wolf99 / GetDictionaryOfProperties.vb
Last active May 5, 2017
VB.NET function to get a Dictionary of the names and values of the properties of a given object
View GetDictionaryOfProperties.vb
Option Strict On
Option Explicit On
Imports System.Reflection
Module Gists
Public Function GetDictionaryOfProperties(ByRef o As Object) As Dictionary(Of String, Object)
Dim Properties As Dictionary(Of String, Object) = New Dictionary(Of String, Object)
wolf99 / ConvertWithSign.vb
Last active Apr 20, 2017
VB.NET extensions to allow conversion from an unsigned type to the equivalent signed type, and vice versa, while preserving the sign bit, by using a structure with explicit layout to simulate a union.
View ConvertWithSign.vb
Option Strict On
Option Explicit On
Imports System.Runtime.InteropServices
Imports System.Runtime.CompilerServices
Module ConvertWithSign
' These extensions allow conversion from an unsigned type to the equivalent
' signed type, and vice versa, while preserving the sign bit.
wolf99 / BoilerplateException.cs
Last active Aug 3, 2017
A boilerplate C# exception class
View BoilerplateException.cs
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
namespace FooProgram
// Recommended practice to derive from Exception rather than ApplicationException
// Recommended practice to make exceptions serializable
public class BoilerplateException : Exception, ISerializable
You can’t perform that action at this time.