Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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');
using System;
using System.Security.Cryptography;
using System.Text;
namespace Utility
{
/// <summary>
/// Helper methods for working with <see cref="Guid"/>.
/// </summary>
@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.Principal;
internal static class IdentityExtensions
{
internal static string GetNormalizedLogin(this IIdentity identity)
{
if (identity == null)
{
throw new ArgumentNullException(nameof(identity));
@ngbrown
ngbrown / SQLiteDateRoundTripTests.cs
Created October 13, 2017 23:22
SQLiteDateRoundTripTests
using System;
using System.Globalization;
using NUnit.Framework;
namespace UnitTestProject1
{
[TestFixture]
public class SQLiteDateRoundTripTests
{
private int _optionToStringInSqLite = 1; // Currently implemented in System.Data.SQLite
@ngbrown
ngbrown / typescript-babel-jest.js
Last active July 14, 2017 16:09
Transformer helper for Jest to take Typescript through Babel, with sourcemap support.
"use strict";
/**
*
* This source code is licensed under the BSD-style license.
* Portions of code derived from "babel-jest", copyrighted by
* Facebook, Inc. and released under a BSD-style license.
*
*/
@ngbrown
ngbrown / utilities.js
Last active November 29, 2016 17:48
redux-little-router utility functions for onClick and onSubmit
import {PUSH, REPLACE} from "redux-little-router";
import defaultCreateLocation from "redux-little-router/lib/util/create-location.js";
// Adapted from https://github.com/FormidableLabs/redux-little-router
// specifically the Link component (https://github.com/FormidableLabs/redux-little-router/blob/master/src/link.js)
const normalizeHref = ({ basename, pathname, search }) =>
`${basename || ''}${pathname}${search || ''}`;
const normalizeLocation = href => {