This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
A time estimator for use with PowerShell's Write-Progress. Provided a total | |
number of cycles, it tracks how long the last 100 or less itterations of your | |
main loop took and calculates the remaining time based on velocity. Note: when | |
ticks exceed total, it returns a seconds remaining of 0, but continues to track | |
the rate that work is getting done. | |
The intended use case is with Write-Progress, calls to that cmdlet are really | |
slow on PowerShell 2-5, efforts have been made to maintain low overhead. If | |
you're after performance this is still useful, just log the progress yourself. | |
For instance, using [System.Diagnostics.Trace]::Write() and watching with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -Module ActiveDirectory | |
[CmdletBinding()] | |
param ($users_file, [switch]$WhatIf) | |
if (-not $users_file) { | |
Write-Warning "Must pass file name as `$users_file" | |
return 1 | |
} | |
Write-Host -ForegroundColor Cyan $users_file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
using System.Text.RegularExpressions; | |
using McAttributes.Data; | |
using Microsoft.VisualBasic.FileIO; | |
namespace SMM | |
{ | |
public class CsvFileReader | |
{ | |
static string csv_delimiter_pattern = @"(?:^|,)(?=[^""]|("")?)""?((?(1)(?:[^""]|"""")*|[^,""]*))""?(?=,|$)"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -Modules Pester | |
function Test-SemanticEquality { | |
<# | |
.Synopsis | |
When comparing two JSON records, comparing the string representation of one | |
to the other can fail for any nubmer of reasons. This function takes parsed | |
JSON records and compares their structure/values to tell if the sources | |
are semantically equivalent. | |
.DESCRIPTION |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
here=$(dirname "$0") | |
pushd "$here" > /dev/null | |
prep () | |
{ | |
if [ ! -d data ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ADTS_AC_Guids = @{ | |
'Abandon-Replication'=[Guid]"ee914b82-0a98-11d1-adbb-00c04fd8d5cd" | |
'Add-GUID'=[Guid]"440820ad-65b4-11d1-a3da-0000f875ae0d" | |
'Allocate-Rids'=[Guid]"1abd7cf8-0a99-11d1-adbb-00c04fd8d5cd" | |
'Allowed-To-Authenticate'=[Guid]"68b1d179-0d15-4d4f-ab71-46152e79a7bc" | |
'Apply-Group-Policy'=[Guid]"edacfd8f-ffb3-11d1-b41d-00a0c968f939" | |
'Certificate-Enrollment'=[Guid]"0e10c968-78fb-11d2-90d4-00c04f79dc55" | |
'Certificate-AutoEnrollment'=[Guid]"a05b8cc2-17bc-4802-a710-e7c15ab866a2" | |
'Change-Domain-Master'=[Guid]"014bf69c-7b3b-11d1-85f6-08002be74fab" | |
'Change-Infrastructure-Master'=[Guid]"cc17b1fb-33d9-11d2-97d4-00c04fd8d5cd" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IRule { | |
[System.Collections.Generic.IEnumerable[IRule]]$Rules | |
# Or, Any : bail on first match | |
# And, All : evaluate all rules, only return a result if they all succeed | |
[ValidateSet("Or","Any", "And", "All")] | |
$MatchType | |
# Called on matching rules, overload in an inherited class to return | |
# values relevant to that rule. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CacheResolverException : Exception { | |
CacheResolverException ([string]$Message, [Exception]$InnerException) : base ($Message, $InnerException) { } | |
} | |
class HotCache { | |
hidden static [Hashtable]$Records = @{} | |
hidden [UInt64] $Hit = 0 | |
hidden [UInt64] $Miss = 0 | |
hidden [int] $Limit = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-SQL { | |
param( | |
[string] $connectionString = ".\SQLEXPRESS", | |
[string] $sqlCommand = $(throw "Please specify a query."), | |
[hashtable] $parameters = @{}, | |
[switch] $splitOnGo | |
) | |
$queries = @() | |
## Split sqlCommand on GO keyword. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import random as rand | |
import tkinter as tk | |
from tkinter import ttk | |
colors = [ "white", "blue", "green", "red", "purple", "brown", "grey", "black" ] | |
class Tile: | |
def __init__(self, bomb=False): |