Skip to content

Instantly share code, notes, and snippets.

View rajbos's full-sized avatar

Rob Bos rajbos

View GitHub Profile
@rajbos
rajbos / Example
Created September 16, 2023 18:38
Az CLI speed up on Azure DevOps
- script: |
c:
cd %USERPROFILE%
md .azure
cd .azure
echo [core] > config
echo first_run = false >> config
echo collect_telemetry = false >> config
echo error_recommendation = off >> config
echo output = json >> config
@rajbos
rajbos / example.md
Created May 28, 2023 20:54
Post json with GitHub CLI

See more info in this discussion

For example, adding labels to a runner will fail:

gh api repos/rajbos/demo-actions/actions/runners/23/labels -f body="{\"labels\":[\"new-gpu\",\"accelerated\"]}"  

Response:

{ "message": "Invalid request.\n\nInvalid input: object is missing required key: labels.",

function checkResponse {
if ( $Args[0] -eq $true ) {
$fileContents = Get-Content $tempFile
Write-Host $fileContents
# write contents of file to console (basically EVAL())
Invoke-Expression $fileContents
}
else {
Write-Host "User cancelled the command."
}
@rajbos
rajbos / .vscode_launch.json
Created March 26, 2023 20:13
GitHub Typescript/JavaScript Actions debugging
// store in .vscode/launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
@rajbos
rajbos / Get-JWTToken.ps1
Last active June 6, 2024 19:36
Load jwt token from GitHub App for authentication
# code to load the JWT token in PowerShell
# Call teh Get-JWTToken method with the App ID and the App Private Key (normal string from env var or file contents, make sure there is no extra line ending at the end of it!).
function Build-Payload {
Param (
[string] $app_id
)
$iat = [Math]::Floor([decimal](Get-Date(Get-Date) -UFormat %s))
$payload = @{
"iat" = [int]$iat # issues at = now
@rajbos
rajbos / Setti
Last active March 19, 2024 15:18
Elgato Control Center Settings.xml
<?xml version="1.0" encoding="utf-8"?>
<AppSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Application>
<Language>English</Language>
<OverwriteLanguage>false</OverwriteLanguage>
<LastCrashReport>2020-05-15T20:08:15.8427353+02:00</LastCrashReport>
<AdvancedSettingsExpanded>true</AdvancedSettingsExpanded>
<IsGrouping>true</IsGrouping>
<IsSyncing>true</IsSyncing>
<IsWiFiDiscoveryAlwaysActive>true</IsWiFiDiscoveryAlwaysActive>
@rajbos
rajbos / UpdateRepoFromUpstream.sh
Created January 21, 2021 18:57
Update repo from upstream
# clone the forked repo
git clone https://github.com/rajbos/a-forked-repo.git
# make sure you are inside the git repo
cd a-forked-repo
# add the parent repo as a remote
git remote add github-parent $parentUrl
# fetch the changes from the parent
# collection of GitLab api calls
$baseUrl = "https://private.gitlab.host/api/v4"
function GetToken{
$token = $env:GitLabToken
if ($null -ne $token) {
Write-Host "Found token as environment variable [GitLabToken]"
}
@rajbos
rajbos / Register.ps1
Created July 15, 2020 14:17
Register Windows Startup/Shutdown script
function Register-EventScript {
param (
[string] $eventToRegister, # Either Startup or Shutdown
[string] $pathToScript,
[string] $scriptParameters
)
$path = "$ENV:systemRoot\System32\GroupPolicy\Machine\Scripts\$eventToRegister"
if (-not (Test-Path $path)) {
# path HAS to be available for this to work
@rajbos
rajbos / dotnetToolInstallCheck.ps1
Last active May 17, 2024 01:59
Use dotnet tool to find out if a specific tool is installed on an environment
# Preface:
# dotnet tool install -g will return an error code when the tool is already installed in the system (at the same location)
# adding a test like below, will prevent the error
# this is mostly needed in a CI/CD environment where you don't want to break your pipeline if the tool was installed already.
# find if stryker is installed
$list = (dotnet tool list -g)
# echo the list
# $list