Skip to content

Instantly share code, notes, and snippets.

View JohnRoos's full-sized avatar

John Roos JohnRoos

View GitHub Profile
@JohnRoos
JohnRoos / chroma_style.css
Created November 22, 2022 08:05
CSS which I am using for code highlights in Hugo
/* Background */ .chroma { color: #d4d4d4; background-color: #161616; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; }
/* Other */ .chroma .x { }
/* Error */ .chroma .err { color: #960050; background-color: #1e0010 }
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; width: auto; overflow: auto; display: block; }
/* LineHighlight */ .chroma .hl { display: block; width: 100%;background-color: #ffffcc }
/* LineNumbersTable */ .chroma .lnt { margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
/* LineNumbers */ .chroma .ln { margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f }
/* Keyword */ .chroma .k { color: #c586c0 }
/* KeywordConstant */ .chroma .kc { color: #66d9ef }
@JohnRoos
JohnRoos / New-RandomFile.ps1
Last active January 26, 2021 10:40
Creates a file with a specified size
function New-RandomFile {
[CmdletBinding()]
param (
# Where the file will be created
[parameter(Mandatory)]
$Path,
# Size of file (tip: use 20mb, 1gb etc.)
[parameter(Mandatory)]
[int64]$Size
@JohnRoos
JohnRoos / Start-FunctionAppFunction.ps1
Created January 20, 2021 10:58
Function to trigger the start of a function inside an Azure Function App
# This function triggers the start of a function inside an Azure Function App
function Start-FunctionAppFunction {
[CmdletBinding()]
param (
# Enter the base url for the function app. Example: https://myappname.azurewebsites.net
[Parameter(Mandatory)]
[Uri]$FunctionAppBaseUrl,
# Enter the app key called _master
@JohnRoos
JohnRoos / Create_Lab_function_app.ps1
Created October 22, 2020 20:13
Create lab function app
<#
Requires Az module. Use Connect-AzAccount before running.
Creates the following:
Resource group
Key vault
Storage account (Standard_LRS)
Function app (EP1)
PowerShell 7 runtime
Assigned identity
using namespace System.Management.Automation
class ValidCommandsGenerator : IValidateSetValuesGenerator {
[string[]] GetValidValues() {
$Values = (Get-Command).Name
return $Values
}
}
Function New-ProxyFunction {
#region LabModule.psd1
@{
RootModule = 'LabModule.psm1'
ModuleVersion = '1.0'
GUID = 'd00578f5-fb6b-4c47-83fb-ed1c8d9a1ec2'
FunctionsToExport = 'Get-PublicStuff'
}
#endregion
function Get-FileEncoding {
[CmdletBinding()]
param (
[ValidateScript({Test-Path -Path $_})]
[string]$Path
)
$fullpath = (Resolve-Path -Path $Path).Path
$file = [System.IO.FileStream]::new($fullpath,[System.IO.FileMode]::Open)
@JohnRoos
JohnRoos / ConvertSecureToString.ps1
Created May 29, 2017 18:15
Convert secure string to plain text
function ConvertSecureToString
{
[CmdletBinding()]
[OutputType([String])]
param (
[Parameter(Mandatory=$true,
ValueFromPipeline=$true,
Position=0)]
[ValidateNotNull()]
[SecureString]
@JohnRoos
JohnRoos / Invoke-RestMethod with cookie and header.ps1
Last active April 15, 2024 06:57
Invoke-RestMethod with cookies and headers
@JohnRoos
JohnRoos / Play-JingleBells.ps1
Created December 23, 2015 13:51
Play-JingleBells.ps1
function Play-JingleBells {
[System.Console]::Beep(659, 300);
[System.Console]::Beep(659, 300);
[System.Console]::Beep(659, 300);
[System.Threading.Thread]::Sleep(300);
[System.Console]::Beep(659, 300);
[System.Console]::Beep(659, 300);
[System.Console]::Beep(659, 300);
[System.Threading.Thread]::Sleep(300);
[System.Console]::Beep(659, 300);