Skip to content

Instantly share code, notes, and snippets.

View duboisf's full-sized avatar

Fred Dubois duboisf

View GitHub Profile
@duboisf
duboisf / operations.graphql
Last active March 18, 2024 15:46
Add branch protection to a repo using GitHub's Graphql API
fragment branchProtection on BranchProtectionRule {
allowsDeletions
allowsForcePushes
creator {
login
}
id
isAdminEnforced
requiredStatusCheckContexts
requiredApprovingReviewCount
@duboisf
duboisf / README.md
Last active May 8, 2024 17:50
Example GitHub graphql queries using the gh cli

List all the default branches of repositories in a specific organisation

gh api graphql --paginate \
    --jq '.data.organization.repositories.nodes[] | .defaultBranchRef.name + "\t" + .name' \
    -F org=SomeOrg \
    -f query='
query($org:String!, $endCursor:String) { 
  organization(login:$org) {
    repositories(first: 100, after: $endCursor, isFork:false, orderBy: {field:NAME, direction:ASC}) {
@duboisf
duboisf / zscaler_ufw.txt
Last active January 18, 2024 19:05
ufw rules to get zscaler working on linux
sudo ufw allow in on zcctun0 proto any from 10.0.0.0/8 to 100.64.0.1 port 9000
sudo ufw allow in on zcctun0 proto any from 100.64.0.0/16 to 100.64.0.1 port 9000
sudo ufw allow in on zcctun0 proto any from 100.64.0.0/16 to 100.64.0.1 port 9010
sudo ufw allow in on zcctun0 proto udp from 100.64.0.0/16 to 100.64.0.1
@duboisf
duboisf / report.sh
Last active February 17, 2023 21:41
GitHub org collaborators csv report
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
if (( $# != 1 )); then
echo "This script takes 1 argument, the GitHub org name" >&2
exit 1
fi
@duboisf
duboisf / golang_project_internal_deps.md
Created June 9, 2022 11:45
How to graph a golang's internal dependency graph

Displaying a golang project's internal dependency graph

Run this at the root of a golang project, where it contains a go.mod file.

Here is how to get the graph for the karpenter project:

cd /tmp
gh clone aws/karpenter
cd karpenter
@duboisf
duboisf / aws
Last active December 6, 2022 16:56
aws docker bash script
#!/bin/bash
# Use docker to run the aws cli.
# This bash script can be put anywhere on your $PATH.
# Inspired from https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-docker.html
AWS_CLI_VERSION=2.8.6
debug() {
if [[ -n ${AWS_CONTAINER_DEBUG} ]]; then
package main
import (
"fmt"
"os"
)
func forEachInRange(start, end int, title string, callback func(int)) {
if start > end {
fmt.Fprintf(os.Stderr, "start %q must be smaller than end %q", start, end)
@duboisf
duboisf / README.md
Last active January 13, 2024 09:31
zscaler apparmor profiles for Pop!_OS 22.04 LTS

To install zscaler on Pop!_OS 22.04, download the connector from the admin zscaler site by clicking the Client Connector link on the sidebar, then clicking Client Connector App Store, New Releases, Linux and download 1.4.0.105.

Before installing, you must temporarily replace your /etc/os-release file:

cd /etc
sudo mv os-release os-release.old
sudo cat <<EOF >> os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
@duboisf
duboisf / README.md
Created January 12, 2024 15:48
Automate the approval of a bunch of GitHub pull requests

Sometimes in the course of your job you might need to approve a bunch of pull requests that were automatically created.

The gh cli is a handy tool to simplify this process.

In this example we'll approve all pull requests in the Foo org that request you as a reviewer and contains autoscaling:

for PR_URL in $(gh search prs org:Foo --review-requested @me --state open autoscaling --json url --jq ".[].url"); do
 echo $PR_URL
@duboisf
duboisf / upgrade_helm_manifest_api_version.sh
Last active January 19, 2024 19:35
Update deprecated kubernetes api version that's stored in a helm release that's stored in a secret
#!/bin/bash
# Strict mode
set -euo pipefail
if [ $# -ne 3 ]; then
echo "Usage: $0 <helm_release_name> <old_api_version> <new_api_version>"
exit 1
fi