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 / api-calls.sh
Last active January 17, 2024 09:14
Load jwt token from GitHub App for authentication
#!/bin/bash
# Purpose
# grab the jwt token
# make API calls as the GitHub App used
# get a temporary jwt token from the key file and app id (hardcoded in the file:)
generated_jwt=$(./github-app-jwt.sh)
github_api_url="https://api.github.com/app"
@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 February 7, 2024 12:45
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