Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Security.Principal;
internal static class IdentityExtensions
{
internal static string GetNormalizedLogin(this IIdentity identity)
{
if (identity == null)
{
throw new ArgumentNullException(nameof(identity));
@ngbrown
ngbrown / TUT017.md
Created May 13, 2018 04:03 — forked from dapperfu/TUT017.md
TUT017 Example YAML to MD.

active: true derived: false level: 1.5 links:

  • REQ004: 94f4db8d1a50ab62ee0edec1e28c0afb normative: true ref: '' reviewed: 98ba42c551fec65d9796fee72d15f844 title: Tutorial Requirement 17
using System;
using System.Security.Cryptography;
using System.Text;
namespace Utility
{
/// <summary>
/// Helper methods for working with <see cref="Guid"/>.
/// </summary>
@ngbrown
ngbrown / bunyan-format.js
Last active January 17, 2019 21:43
bunyan-format for node
'use strict';
const util = require('util');
const format = util.format;
const http = require('http');
const chalk = require('chalk');
const stream = require('stream');
const _merge = require('lodash/merge');
const _get = require('lodash/get');
@ngbrown
ngbrown / check_used_characters.sql
Last active July 18, 2019 23:32
Check used characters
-- Based on https://stackoverflow.com/a/2926213/25182
WITH a AS (SELECT LTRIM(dut_eosonum) AS s, '' AS x, 0 AS n
FROM dbo.[dutmast]
WHERE LEN(dut_eosonum)>0
UNION ALL
SELECT a.s, SUBSTRING(a.s, n+1, 1) AS x, n+1 AS n FROM a WHERE n<LEN(a.s))
SELECT x, COUNT(*) AS c FROM a WHERE n>0 GROUP BY x ORDER BY x
OPTION(MAXRECURSION 0);
@ngbrown
ngbrown / ResetRDPCertToLetsEncrypt.ps1
Created October 17, 2019 20:44
Reset RDP Cert To Let's Encrypt
Write-Host Clear security certificates. Removes SSLCertificateSHA1Hash from the registry.
$name = 'SSLCertificateSHA1Hash'
$path = 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'
Remove-ItemProperty -Path $path -Name $name -ErrorAction SilentlyContinue
Set-ItemProperty -Path $path -Name 'MinEncryptionLevel' -Value 1
Set-ItemProperty -Path $path -Name 'SecurityLayer' -Value 0
Remove-ItemProperty -Path 'HKLM:\SYSTEM\ControlSet001\Control\Terminal Server\WinStations\RDP-Tcp' -Name $name -ErrorAction SilentlyContinue
Remove-ItemProperty -Path 'HKLM:\SYSTEM\ControlSet002\Control\Terminal Server\WinStations\RDP-Tcp' -Name $name -ErrorAction SilentlyContinue
Write-Host Clear security certificates. Set SSLCertificateSHA1Hash to .
@ngbrown
ngbrown / Program.cs
Last active April 3, 2020 03:32 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@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')
@ngbrown
ngbrown / ApolloLoggingExtension.ts
Created March 29, 2019 04:00
Custom logging in Apollo Server 2 using the extension API
import {GraphQLExtension, GraphQLResponse} from 'graphql-extensions';
import {formatApolloErrors} from 'apollo-server-errors';
import {GraphQLError, GraphQLFormattedError} from 'graphql';
import Logger from 'bunyan';
import icepick from 'icepick';
const filterOutErrorPaths = [
['extensions', 'exception', 'options', 'auth', 'bearer'],
[
'extensions',
@ngbrown
ngbrown / calendar.css
Created August 3, 2020 04:54 — forked from AndyCross/calendar.css
How the Calendar Visual might look in a few files
.day {
fill: #fff;
stroke: #ccc;
}
.month {
fill: none;
stroke-width: 2px;
}