This file contains 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
## Takes and ACL and SID, returns an ACL with the correct entry for read-only permissions added. | |
function Add-ReadAce { | |
[OutputType([System.Security.AccessControl.FileSystemSecurity])] | |
param( | |
[Parameter(Mandatory=$true, ValueFromPipeline=$false)] | |
[System.Security.Principal.IdentityReference]$SID, | |
[Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)] | |
[System.Security.AccessControl.FileSystemSecurity]$ACL | |
) |
This file contains 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
public string ToKvText(object entry) { | |
if (entry == null) return string.Empty; | |
StringBuilder sb = new StringBuilder(); | |
var properties = entry.GetType().GetProperties(); | |
var longestPropertyLength = properties.Select(x => x.Name.Length).Max(); | |
int indentation = longestPropertyLength + 3; | |
foreach (var p in properties) { |
This file contains 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
<?xml version="1.0" encoding="utf-16"?> | |
<StorableColorTheme xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<Keys> | |
<string>ErrorForegroundColor</string> | |
<string>ErrorBackgroundColor</string> | |
<string>WarningForegroundColor</string> | |
<string>WarningBackgroundColor</string> | |
<string>VerboseForegroundColor</string> | |
<string>VerboseBackgroundColor</string> | |
<string>DebugForegroundColor</string> |
This file contains 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
/// <summary> | |
/// Let's say you have a collection of things with an indeterminate ordering but when you | |
/// enumerate the things, you'd like a subset to be grouped together. That's what this | |
/// can do but there's no guarantee elements in the group parameter exist in the primaryCollection. | |
/// That can be seen as a bug or a feature, it's up to you. | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="primaryCollection"></param> | |
/// <param name="group"></param> | |
/// <returns></returns> |
This file contains 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 Microsoft.VisualBasic.FileIO; | |
namespace SMM { | |
public class CsvFileReader { | |
string file_path; | |
private CsvFileReader(string FilePath) { |
This file contains 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/pwsh | |
#Requires -Version 5 | |
#region TimeKeeper | |
################################################################################ | |
## TimeKeeper ## | |
################################################################################ | |
class TimeEvent { | |
<# |
This file contains 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
/* | |
Usage: | |
var five = 5000.FromMB(); | |
Console.WriteLine($"{five.ToKB()} KB"); | |
Console.WriteLine($"{five.ToMB()} MB"); | |
Console.WriteLine($"{five.ToGB()} GB"); | |
Console.WriteLine($"{five.ToTB()} TB"); | |
Console.WriteLine($"{five.ToPB()} PB"); |
This file contains 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 BeepOnChange { | |
<# | |
.Synopsis | |
Take pipeline input and beep when the input changes. | |
It will optionally stop when the change occurs. | |
.PARAMETER Skip | |
Number of lines to not consider for comparison. If you're piping | |
a long running command like ping /t, you want it to skip the | |
header of the command. Combine ping with the StopOnChange switch | |
for it to alert when a network connection comes back up and ping |
This file contains 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
# Save the output of this file and use kubectl create -f to import | |
# it into Kubernetes. | |
# | |
# Created with podman-4.0.2 | |
# | |
# Where you see: /bulk/*, update those paths to correlate with your filesystem. Note: /dev/dri is what | |
# passes through devices for Intel Quick Sync hardware encoding. For me that dropped CPU usage on 4k | |
# video from 90% to 2% on 8th gen i5. | |
# | |
# After running $ podman play kube jelly-kube.yml, run the following command to generate systemd unit files: |
This file contains 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 |
NewerOlder