Skip to content

Instantly share code, notes, and snippets.

View Manbearpiet's full-sized avatar
🏠
Working from home

Christian Piet Manbearpiet

🏠
Working from home
View GitHub Profile
@Manbearpiet
Manbearpiet / autopairs.lua
Created September 12, 2025 19:03
Nvim setup
-- ~/nvim/lua/slydragonn/plugins/autopairs.lua
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
config = true,
enabled = true
}
@Manbearpiet
Manbearpiet / GitHubJWT.ps1
Last active July 7, 2025 10:19
Code from my post "A view into GitHub Apps, their use cases, and authentication"
install-PSResource 'powershell-jwt' -Repository PSGallery | Import-Module
$newjwtSplat = @{
Algorithm = 'RS256'
SecretKey = (Get-Content /Users/christianpiet/Downloads/manbearpiet-app.2025-06-25.private-key.pem -AsByteStream) # This accepts a byte-array
ExpiryTimestamp = ([math]::Round((Get-Date -UFormat %s)) + (8 * 60))
Issuer = 1459729 # Trimmed
PayloadClaims = @{
iat = ([math]::Round((Get-Date -UFormat %s)) - 10)
}
@Manbearpiet
Manbearpiet / Get-TweakersNews.ps1
Created May 7, 2025 14:09
Get the tweakers news directly from the RSS feed
function Get-TweakersNews {
[CmdletBinding()]
param (
[int]$numberofitems = '20'
)
[xml]$feed = Invoke-WebRequest https://tweakers.net/feeds/nieuws.xml
$total = foreach ($item in $feed.rss.channel.item) {
[PSCustomObject]@{
Date = $item.pubDate | get-date -Format g
Title = $item.Title
@Manbearpiet
Manbearpiet / new-lighthouseroleassignmentexample.ps1
Last active March 20, 2025 09:46
Lighthouse role assignment example
$invokeAzRestMethodSplat = @{
Path = "/subscriptions/cceb1495-9940-4f29-abef-8fef7540161d/resourceGroups/DefaultResourceGroup-WEU/providers/Microsoft.Authorization/roleAssignments/$((New-Guid).Guid)?api-version=2022-04-01"
Method = 'PUT'
Payload = (
@{
properties = @{
roleDefinitionId = '/subscriptions/cceb1495-9940-4f29-abef-8fef7540161d/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7' # The only allowed roledefinitions are those under the lighthouse offer under delegatedRoleDefinitionIds
principalId = '3cb5e715-bb86-41b3-a240-1468814d0eb0' # Not the client ID but the OBJECT ID of the service principal
principalType = 'ServicePrincipal' # this must be a Service Principal else it won't work
delegatedManagedIdentityResourceId = '/subscriptions/cceb1495-9940-4f29-abef-8fef7540161d/resourceGroups/DefaultResourceGroup-WEU/providers/Microsoft.Managed
@Manbearpiet
Manbearpiet / nasa.md
Last active February 17, 2025 10:21
NASA video GPT suggestions

Here are PowerShell examples that align with NASA’s “Power of 10” coding principles:

  1. Avoid Complex Control Flow (No goto or Recursion)

PowerShell doesn’t support goto, but recursion should be avoided.

❌ Bad Example (Recursion)

function Get-Factorial {
 param ([int]$n)
@Manbearpiet
Manbearpiet / AuditAndHealthLogsSentinel.bicep
Last active January 16, 2025 12:20
Sentinel Audit and Health Logs Bicep
@description('The name of the diagnostic setting')
param diagnosticSettingName string = 'AuditAndHealthMonitoring'
@description('The Log Analytics workspace ID where diagnostics will be sent')
param workspaceResourceId string
resource reslogAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-10-01' existing = {
name: split(workspaceResourceId, '/')[8]
}
@Manbearpiet
Manbearpiet / parsemulticonfigdsc.ps1
Created January 9, 2025 16:30
Parse DSC Configuration File with multiple Configurations using the DSCParser module
$ast = [System.Management.Automation.Language.Parser]::ParseFile('C:\Temp\src\common\common.ps1', [ref]$null, [ref]$null)
$configurations = $ast.FindAll({ $args[0] -is [System.Management.Automation.Language.ConfigurationDefinitionAst] }, $false)
$objectstable = $configurations.Extent.text | ForEach-Object {
ConvertTo-DSCObject -Content $_
}
$objectstable | Group-Object -Property ResourceName | ConvertTo-Json -Depth 10
@Manbearpiet
Manbearpiet / errors.md
Last active November 25, 2024 20:31
Errors.md

author: "Christian Piet" title: "How to work with error in PowerShell" date: 2024-11-20T20:00:00.0000000+01:00 draft: true description: "An basic course in PowerShell errors" tags: - errors series: powershell aliases:

@Manbearpiet
Manbearpiet / location.kql
Created November 21, 2024 07:45
Detect resources in other regions than resourcegroup location
resources
| where location != "global"
| join (
resourcecontainers
| where ['type'] =~ 'microsoft.resources/subscriptions/resourcegroups'
| project resourceGroup, location,subscriptionId
) on resourceGroup, subscriptionId
| where location != location1
@Manbearpiet
Manbearpiet / README.md
Created August 28, 2023 14:47 — forked from MichaelCurrin/README.md
GitHub GraphQL - Get Pull Requests using GH's GraphQL API

Get Pull Requests using GH's GraphQL API

How to get Pull Requests data using Github in the browser, or using the API to allow for automating reporting or building in values into a website.

Resources