Skip to content

Instantly share code, notes, and snippets.

View 1ARdotNO's full-sized avatar

Einar Stenberg 1ARdotNO

View GitHub Profile
@1ARdotNO
1ARdotNO / githubsetdefaultbranchforteam.ps1
Created January 13, 2025 13:25
Set the default branch for all repos for a particular team
# Set your GitHub API token and team details
$GitHubToken = $env:GH_PAT
$Organization = "orgname" # Replace with your GitHub Organization name
$TeamSlug = "team-slug" # Replace with your GitHub Team slug (e.g., "dev-team")
$DefaultBranch = "master"
# GitHub API URL
$GitHubApiBaseUrl = "https://api.github.com"
# Headers for the GitHub API request
@1ARdotNO
1ARdotNO / githubSAMLuserdetails.ps1
Created December 18, 2024 09:12
Script to use graphql api to fetch a list of emails and usernames from github,
param (
[Parameter(Mandatory = $true)] $orgName
)
$pat = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($ENV:GITHUB_TOKEN)"))
$query="{
organization(login: `"$orgName`") {
samlIdentityProvider {
externalIdentities(first: 100) {
nodes {
@1ARdotNO
1ARdotNO / addCodeowners.ps1
Last active April 26, 2023 00:59
add codeowners to github repo
param (
[Parameter(Mandatory = $true)] $repoName,
[Parameter(Mandatory = $true)] $teamName, #allows multiple teams speatated by comma
[Parameter(Mandatory = $true)] $orgName,
$CodeOwnerTeam, #allows multiple teams speatated by comma, use this to define what team has the rights to change the codeowners file itself
$branch, #if not specified default branch is used
[switch]$overwrite, #automatically overwrite the existing CODEOWNERS FILE
[switch]$addperms, #automatically add the required perm for the select team. WILL OVERWRITE CURRENT PERMISSIONS
[switch]$enablebranchprotectioncodeowners #automatically add the required perm for the select team. WILL OVERWRITE CURRENT PERMISSIONS
)
@1ARdotNO
1ARdotNO / zerotier-usg.sh
Created December 7, 2022 14:43
Install zerotier on Unifi USG
# related to bug https://github.com/zerotier/ZeroTierOne/issues/1553
mkdir -p /config/data/firstboot/install-packages
cd /config/data/firstboot/install-packages
curl https://download.zerotier.com/dist/ubiquiti/zerotier-one_mips64.deb --output /config/data/firstboot/install-packages/zerotier-one.deb
mv zerotier-one.deb zerotier-one-xz.deb
ar -x zerotier-one-xz.deb
xz --decompress control.tar.xz
xz --decompress data.tar.xz
@1ARdotNO
1ARdotNO / meshgentoken.js
Created August 22, 2022 12:44
improve mesgentoken to account for slight time variations between hosts
// Generates a MeshCentral login token
//
// Start by running the following on your server to get the login key:
//
// node node_module/meshcentral --LoginTokenKey
//
// You can also run the following command to get a list of user identifiers
//
// node node_module/meshcentral --ListUserIDs
//
@1ARdotNO
1ARdotNO / resume.json
Last active February 6, 2025 15:41
resume.json
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "Einar Stenberg",
"label": "Security Advisor & IT Manager",
"image": "https://avatars.githubusercontent.com/u/14344702?v=4",
"email": "[email protected]",
"phone": "",
"url": "http://1AR.NO/",
"summary": "",
### Keybase proof
I hereby claim:
* I am ovrap3x on github.
* I am einars (https://keybase.io/einars) on keybase.
* I have a public key ASBFaW840KF510wRzHO7y-aAtub4yskSd3-UFiqRdgaKrQo
To claim this, I am signing this object: