Skip to content

Instantly share code, notes, and snippets.

@pimbrouwers
pimbrouwers / PowerShellNTFSStaticFileServer.ps1
Created November 14, 2019 23:36 — forked from Tiberriver256/PowerShellNTFSStaticFileServer.ps1
This script starts a small web server listening on localhost:8080 that will impersonate the authenticated user and serve static content. This means if they do not have NTFS permissions to the file they will get an access denied or a 404 file not found if they do not have NTFS access to list contents of the directory.
function Get-DirectoryContent {
<#
.SYNOPSIS
Function to get directory content
.EXAMPLE
Get-DirectoryContent -Path "C:\" -HeaderName "poshserver.net" -RequestURL "http://poshserver.net" -SubfolderName "/"
@pimbrouwers
pimbrouwers / App.csproj
Last active March 17, 2020 11:41 — forked from davidfowl/Program.cs
A minimal fully asynchronous C# ASP.NET Core 3.x application with routing
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>
@pimbrouwers
pimbrouwers / PSADO.ps1
Created May 3, 2019 11:32
PowerShell ADO.NET Wrapper (incomplete)
# Open connection to SQL Server
function Open-SqlConnection {
param (
[Parameter(Mandatory)][string] $Server,
[string] $Database,
[string] $User,
[string] $Password)
$connection = New-Object System.Data.SqlClient.SqlConnection
@pimbrouwers
pimbrouwers / IDbTransctionExtensions.cs
Created March 13, 2019 21:32
transacter - The dapper extensions you know and love, but via `IDbTransaction`
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
namespace Transacter
{
public static class IDbTransactionExtensions
{
@pimbrouwers
pimbrouwers / masterdb-cleaner.sql
Last active January 31, 2020 12:37
Removes non-system referential constraints and tables from your master db
USE [master];
GO
DECLARE @sql NVARCHAR(MAX);
------ Views ------
DECLARE @view_name NVARCHAR(1024);
SELECT TOP 1
@view_name = N'[' + [s].[name] + N'].[' + [v].[name] + N']'
@pimbrouwers
pimbrouwers / geolite2-city-locations.sql
Last active February 6, 2019 18:23
Parse GeoLite2-City-Locations-en.csv into SQL Server
USE [master];
GO
IF OBJECT_ID('tempdb..#GeoLite2CityLocations') IS NOT NULL
DROP TABLE [tempdb]..[#GeoLite2CityLocations];
CREATE TABLE [#GeoLite2CityLocations]
(PRIMARY KEY ([geoname_id])
, [geoname_id] INT NOT NULL
, [locale_code] NVARCHAR(16) NULL
@pimbrouwers
pimbrouwers / fsharp-runningtotal.fsx
Last active January 24, 2019 13:23
Awesome F# - Running Total
type Split = double
type Lap = { Num : int; Split : Split }
type RunnerLap = { Lap : Lap; TotalTime : double }
let lap1 = { Num = 1; Split = 1.23 }
let lap2 = { Num = 2; Split = 1.13 }
let lap3 = { Num = 3; Split = 1.03 }
let laps = [lap1;lap2;lap3]
let runnerLapsAccumulator =
@pimbrouwers
pimbrouwers / main.go
Last active October 2, 2018 13:03
Go Tree Flattener
package main
import (
"fmt"
)
// Nums is a wrapper around []int
type Nums []int
// Nodes represents an arbitrarily nested tree structure of Node structsß
@pimbrouwers
pimbrouwers / HomeController.cs
Created August 27, 2018 18:50
.NET Core v2.x Empty Web app
//Controllers/HomeController.cs
using Microsoft.AspNetCore.Mvc;
namespace EmptyWebApp.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
@pimbrouwers
pimbrouwers / dapper-sequel-repo.cs
Last active May 2, 2018 21:35
Dapper Repository
using Cinch.Sequel;
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
namespace DapperSequelRepo
{