Skip to content

Instantly share code, notes, and snippets.

@CJHarmath
CJHarmath / fastapi_proxy_logging.py
Last active April 3, 2023 21:57
FastAPI with logging and proxying to target with blacklist support
import json
from datetime import datetime
from typing import List
from fastapi import FastAPI, Request, HTTPException
from starlette.responses import JSONResponse
import httpx
app = FastAPI()
BLACKLIST_PATHS: List[str] = [
@CJHarmath
CJHarmath / Test-DnsResolve.ps1
Created March 15, 2020 20:18
DNS Resolve Test
function Test-DnsResolve($name, $server) {
<#
.SUMMARY
DNS Resolver tester
.PARAMETER Name
The host name to resolve
.PARAMETER Server
The DNS Server to be used
#>
@CJHarmath
CJHarmath / Get-PasswordComplexity.ps1
Last active August 2, 2019 18:54
Function to test password complexity
function Get-PasswordComplexity {
<#
.SYNOPSIS
Testing if a given password is complex
.DESCRIPTION
Based on the given SecureString or Credential the function tests if the password used is complex enough.
The complexity is calculated based on the number of character classes use in the password.
The classes are lower case letter, upper case letters, numbers and special characters.
Each class gets a complexity point and the password must include at least 3 classes.
@CJHarmath
CJHarmath / boxstarter.ps1
Created June 12, 2019 03:06 — forked from jessfraz/boxstarter.ps1
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Jess Frazelle <[email protected]>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
@CJHarmath
CJHarmath / SetProtection.cs
Last active February 25, 2019 19:27
Sample attempt to protect a document with RMS
// method was added to the Action.cs in the sample
// https://github.com/Azure-Samples/MipSdk-Dotnet-File-Quickstart/blob/master/mip-sdk-dotnet-quickstart/Action.cs
public bool SetProtection(FileOptions options)
{
try
{
var handler = CreateFileHandler(options);
var newRights = new List<UserRights>
{
# Setup
Import-Module WebAdministration
# create 2 site root directories
$a = 'C:\inetpub\AspNetCoreSampleA'
$b = 'C:\inetpub\AspNetCoreSampleB'
$siteRoot = 'C:\inetpub\aspnetcoresample'
$siteName = 'AspNetCoreSample'
$poolName = "aspnetcore"
New-Item -Type Directory $a
New-Item -Type Directory $b
@CJHarmath
CJHarmath / DmpAnalysis.linq
Created November 15, 2018 22:33 — forked from NickCraver/DmpAnalysis.linq
DMP Analysis in LinqPad
<Query Kind="Program">
<NuGetReference Prerelease="true">Microsoft.Diagnostics.Runtime</NuGetReference>
<Namespace>Microsoft.Diagnostics.Runtime</Namespace>
<Namespace>System</Namespace>
<Namespace>System.IO</Namespace>
<Namespace>System.Linq</Namespace>
<Namespace>System.Text</Namespace>
<Namespace>Microsoft.Diagnostics.Runtime.Utilities</Namespace>
</Query>
@CJHarmath
CJHarmath / bookmarklet.url
Created September 17, 2018 14:12 — forked from sv-in/bookmarklet.url
JS: Bookmarklet for displaying QR code of current URL (good for presentations)
javascript:void !function(e,t,n,r,i,s){while(n--&&(i=t[n])>e);s=r.style,s.position="fixed",s.zIndex=-1>>>1,s.top=s.left="50%",s.marginTop=s.marginLeft=i/-2+"px",r.src="http://chart.apis.google.com/chart?cht=qr&chld=H|0&chs="+i+"x"+i+"&chl="+escape(location)}(Math.min(top.innerHeight,top.innerWidth),[100,150,200,250,300,350,400,500],8,document.body.appendChild(new Image))
@CJHarmath
CJHarmath / setup-forge.ps1
Created June 22, 2017 04:11
Setup-Forge
[CmdletBinding()]
param(
[switch]
$Update
)
if ($update.IsPresent -and $Update){
Write-Warning "running in update mode will not delete existing folders which might lead to issues"
}
else {
Write-Warning "Running in the default clean install mode. Slower but the safest option!"
@CJHarmath
CJHarmath / PSDesiredStateConfiguration.psm1
Created February 28, 2017 22:40
try catch workaround for PSDscResources/issues/43
###########################################################
#
# 'PSDesiredStateConfiguration' logic module
#
###########################################################
data LocalizedData
{
# culture="en-US"
ConvertFrom-StringData -StringData @'
CheckSumFileExists = File '{0}' already exists. Please specify -Force parameter to overwrite existing checksum files.