Skip to content

Instantly share code, notes, and snippets.

View cdhunt's full-sized avatar

Chris Hunt cdhunt

View GitHub Profile
# Requires -Module NameIt, Humanizer
function New-Password {
[CmdletBinding(DefaultParameterSetName = 'Random')]
param (
[Parameter(ParameterSetName = 'Random')]
[switch]
$Random,
[Parameter(ParameterSetName = 'Random')]
[switch]
@cdhunt
cdhunt / configuration.dsc.yaml
Created December 28, 2023 15:00
winget configuration
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
# Reference: https://github.com/dotnet/aspnetcore/blob/main/docs/BuildFromSource.md
properties:
resources:
- resource: Microsoft.WinGet.DSC/WinGetPackage
directives:
description: Install PowerShell 7
allowPrerelease: true
settings:
id: Microsoft.PowerShell
@cdhunt
cdhunt / Convert-Base64.ps1
Last active March 17, 2023 18:36
A PowerShell function to duplicated the Unix base64 util.
function Convert-Base64 {
[CmdletBinding()]
[Alias("base64")]
param (
[Parameter(Mandatory, Position = 0, ValueFromPipeline)]
[string]
$InputObject,
[Parameter()]
[switch]
@cdhunt
cdhunt / DaggerSdk.cs
Created November 11, 2022 12:10
Generated Types from Dagger GraphQL Schema
// <auto-generated> This file has been auto generated. </auto-generated>
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
@cdhunt
cdhunt / night-owl.chunt.omp.json
Last active August 30, 2022 13:04
oh-my-posh theme
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#26C6DA",
"foreground": "#011627",
"leading_diamond": "\u256d\u2500\ue0b6",
@cdhunt
cdhunt / Install.WinGet.ps1
Created August 5, 2022 12:39
This will grab the WinGet appx file and two dependencies and install without user interaction.
function Install-WinGet() {
Write-Information "[winget] Downloading Appx packages"
Push-Location $env:TEMP
# https://github.com/microsoft/winget-cli/issues/2230
if (-not (Test-Path 'Microsoft.DesktopAppInstaller.msixbundle')) {
Write-Information "`tMicrosoft.DesktopAppInstaller"
Invoke-WebRequest 'https://aka.ms/getwinget' -OutFile 'Microsoft.DesktopAppInstaller.msixbundle' -UseBasicParsing
# I don't want to install Python so this docker image and Pwsh function mimic a binary
<# Dockerfile
FROM python:3-alpine
RUN pip install --upgrade cloudsmith-cli
WORKDIR /working
ENTRYPOINT ["cloudsmith"]
#>
function cloudsmith {
# [CloudSmithClientPackagesGet]::new('stackoverflow','nuget').Invoke() | select Name, Version, Uploaded_At, Slug
class CloudSmithClient {
[string]$Namespace
[string]$Uri
[string]$Method
[string] hidden $ApiVersion = 'v1'
[string] hidden $Path
[hashtable] hidden $Headers = @{ }
@cdhunt
cdhunt / cal.ps1
Last active October 8, 2021 13:23
Print a calendar in PowerShell
function Show-Calendar {
[CmdletBinding()]
param (
[Parameter(Position = 0)]
[int]
$Month = (Get-Date).Month,
[Parameter(Position = 1)]
[int]
$Year = (Get-Date).Year,
@cdhunt
cdhunt / Dockerfile
Last active October 4, 2021 11:23
CircleCI build image with Dotnet SDK
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y wget
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
rm packages-microsoft-prod.deb
RUN apt-get update && apt-get install -y \
apt-transport-https \