Skip to content

Instantly share code, notes, and snippets.

View anthonydahanne's full-sized avatar

Anthony Dahanne anthonydahanne

View GitHub Profile
@anthonydahanne
anthonydahanne / update-tags.sh
Created December 22, 2023 00:24
Bash script to rename tags locally and remotely; with an exception
#!/bin/bash
for n in $(git tag)
do
if [ $n != "v6.0.4" ]; then
git tag ${n/v} $n
git tag -d $n
git push origin ${n/v} :$n
fi
done
@anthonydahanne
anthonydahanne / update-with-hacktoberfest-label.sh
Last active October 5, 2023 20:20
Script to ad the hacktoberfest label to existing issues matching a label
gh search issues --owner paketo-buildpacks --label "note:ideal-for-contribution" --limit 1000 --json repository,number | jq -r '.[] | [.number,.repository.nameWithOwner] | @tsv' | while IFS=$'\t' read -r number repository; do
echo "gh label -R $repository create hacktoberfest --description \"Hacktoberfest eligible\" --color D93F0B --force"
gh label -R $repository create hacktoberfest --description "Hacktoberfest eligible" --color D93F0B --force
echo "gh repo edit $repository --add-topic hacktoberfest"
gh repo edit $repository --add-topic hacktoberfest
echo "gh issue edit $number -R $repository --add-label \"hacktoberfest\""
gh issue edit $number -R $repository --add-label "hacktoberfest"
done
@anthonydahanne
anthonydahanne / UpdateReleaseNumbersPivnet
Last active July 7, 2023 14:02
Update release numbers on pivnet
A simple go app to connect to TanzuNet / Pivnet and update the release versions; to match the expected schema X.Y.Z instead of X.Y
# from https://stackoverflow.com/a/67638584/24069
# read each item in the JSON array to an item in the Bash array
set +x
readarray -t my_array < <(jq --raw-output '.[]' $1)
# iterate through the Bash array
for item in "${my_array[@]}"; do
git clone git@github.com:$item.git &>/dev/null
cd ${item#*/}
@anthonydahanne
anthonydahanne / force-push-to-main-branch.sh
Created April 24, 2023 21:19
Github has disabled force-push to the main branch; except that sometimes, that can come in handy. Use this gist with care ❤️
git checkout -b other-main
git push origin other-main
gh api -XPATCH "repos/pivotal-cf/tanzu-bellsoft-liberica" -f default_branch="other-main" >/dev/null
git push --delete tanzu main
gh api "repos/pivotal-cf/tanzu-bellsoft-liberica/branches/other-main/rename" -f new_name="main" >/dev/null
git checkout main
git pull origin main
@anthonydahanne
anthonydahanne / extract-all-links.js
Last active August 26, 2022 02:47
Extract all links (with a non empry rel attribute) from a webpage - to run from firefox or chrome, convenient for hackernews
@anthonydahanne
anthonydahanne / aws-last-services-used.sh
Created March 23, 2022 13:42
Retrieve last accessed services in AWS
#!/usr/bin/env bash
ARN=arn:aws:iam::xxx:user/xxx
JOB_ID=$(aws iam generate-service-last-accessed-details --arn $ARN --output=json | jq -r .JobId)
aws iam get-service-last-accessed-details --job-id $JOB_ID --output=json | jq '[.ServicesLastAccessed[] | select (.TotalAuthenticatedEntities | contains(1))] | sort_by(.LastAuthenticated)'
@anthonydahanne
anthonydahanne / jenkins-jobs.main.kts
Created November 12, 2021 18:52
Find all Jenkins Jobs Git origin urls
#!/usr/bin/env kotlin
@file:DependsOn("com.github.kittinunf.fuel:fuel:2.3.1")
@file:DependsOn("com.google.code.gson:gson:2.8.6")
@file:DependsOn("com.beust:klaxon:5.5")
import com.beust.klaxon.JsonObject
import com.beust.klaxon.Klaxon
import com.beust.klaxon.Parser
import com.beust.klaxon.PathMatcher
import com.github.kittinunf.fuel.core.extensions.authentication
@anthonydahanne
anthonydahanne / README.md
Created May 26, 2020 22:02
Configure Prometheus for AWS EC2 discovery

I had trouble figuring out how to configure Prometheus EC2 instances discovery once, so I'm sharing this gist that includes some sample config that worked fine for me with Prometheus v2.17.2!

Good luck!

Keybase proof

I hereby claim:

  • I am anthonydahanne on github.
  • I am anthonydahanne (https://keybase.io/anthonydahanne) on keybase.
  • I have a public key ASBD72b9PpLKD2S6Nwt5mt8TT0rhCxeu_oSEkEjrgxNBugo

To claim this, I am signing this object: