Skip to content

Instantly share code, notes, and snippets.

public abstract class BindableBase : INotifyPropertyChanged
{
/// <summary>
/// Multicast event for property change notifications.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Checks if a property already matches a desired value. Sets the property and
/// notifies listeners only when necessary.
@ngbrown
ngbrown / appveyor.yml
Last active August 29, 2015 14:16
AppVeyor for rabbitmq-dotnet-client
version: 3.4.5.{build}
configuration: Release
platform: Any CPU
environment:
RABBITMQ_RABBITMQCTL_PATH: C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.4.1\sbin\rabbitmqctl.bat
install:
- ps: >-
choco install rabbitmq -Version 3.4.1.0
Set-Item -Path Env:\ERLANG_HOME -Value ([Environment]::GetEnvironmentVariables("Machine")["ERLANG_HOME"])
@ngbrown
ngbrown / FileNameUtils.psm1
Last active May 22, 2020 16:42
PowerShell scripts
# Import-Module .\FileNameUtils.psm1
function Rename-FilesToSHA {
[CmdletBinding()]
Param(
[ValidateScript({ Test-Path $_ })]
$Path
)
$hasher = [System.Security.Cryptography.HashAlgorithm]::Create('SHA1')
#! /usr/bin/python
# logging to DbgView with OutputDebugString
# from https://gist.github.com/ngbrown/d38064a844426a00fdaa and https://gist.github.com/wh13371/92df4715fc17eb74299d
import logging
import ctypes
# output "logging" messages to DbgView via OutputDebugString (Windows only!)
OutputDebugStringW = ctypes.windll.kernel32.OutputDebugStringW
OutputDebugStringW.argtypes = [ctypes.c_wchar_p]
@ngbrown
ngbrown / gist:953502517ccabd5bd264
Last active August 29, 2015 14:22
Determine lines of code
Function IIf($If, $IfTrue, $IfFalse) {
If ($If -IsNot "Boolean") {$_ = $If}
If ($If) {If ($IfTrue -is "ScriptBlock") {&$IfTrue} Else {$IfTrue}}
Else {If ($IfFalse -is "ScriptBlock") {&$IfFalse} Else {$IfFalse}}
}
Get-ChildItem -include *.js -exclude *.min.js -recurse | ?{$_.fullname -notmatch "\\node_modules\\?"}
Get-ChildItem -include *.js -recurse | select-string . | Group-Object Path -NoElement | ForEach-Object {IIf($_.Count -le 50) "a. <=50" {IIf($_.Count -le 100) "b. <=100" {IIf($_.Count -le 200) "c. <=200" {IIf($_.Count -le 500) "d. <=500" "e. >500"}}}} | Group-Object -NoElement | Sort-Object Name
@ngbrown
ngbrown / database_spaceused.sql
Created November 3, 2015 23:49
Determine table row count and sizes of full database
-- Determine table row count and sizes of full database
-- Inspired from http://stackoverflow.com/a/19916574/25182
SET NOCOUNT ON
DECLARE @TableInfo TABLE (tablename varchar(128), [rows] int, reserved varchar(18), [data] varchar(18), index_size varchar(18), unused varchar(18))
DECLARE @cmd1 varchar(200)
SET @cmd1 = 'exec sp_spaceused ''?'''
INSERT INTO @TableInfo (tablename,[rows],reserved,[data],index_size,unused)
EXEC sp_msforeachtable @command1=@cmd1
@ngbrown
ngbrown / GenericEqualityComparer.cs
Created January 27, 2016 21:44
Generic IEqualityComparer implementation
using System;
using System.Collections.Generic;
using System.Linq;
namespace Helpers
{
public class GenericEqualityComparer
{
public static IEqualityComparer<T> Create<T>(params Func<T, object>[] Param1)
{
@ngbrown
ngbrown / [WIP] NH-3807 Pull Request.md
Last active August 21, 2016 22:57
NHibernate 5.x Core

This is currently a work in progress. It does compile and I have ran simple programs against it.

A majority of the changes were done to the mainline .NET version so all the mainline tests could be used during development. There are no tests ported to .NET Core yet, and this may be difficult without the dynamic schema support.

By necessity, it includes #241/NH-3431 - Replace System.Data with System.Data.Common and NH-3853 - Switch binary-serialization to an implementation that is supported by CoreClr.

There are a number of compromises that have to take place on .NET Core, chief among them is that there is no GetSchemaTable(). Without this, none of the dynamic schema generation or updates works. The tests, when implemented, will need a static schema c

@ngbrown
ngbrown / BowlingKata.cs
Last active September 15, 2016 17:50
Code to read
namespace BowlingKata02
{
public class Scorer
{
private readonly IList<int> rolls = new List<int>();
private int currentRoll;
private int score;
public int CalculateScore()
{
@ngbrown
ngbrown / AboutFramework.cs
Created October 5, 2016 15:58
Display detailed version information about the .NET framework installed
using System;
using Microsoft.Win32;
namespace AboutFramework
{
class Program
{
static void Main(string[] args)
{
GetVersionFromRegistry();