Skip to content

Instantly share code, notes, and snippets.

View benjlevesque's full-sized avatar

Benjamin Levesque benjlevesque

View GitHub Profile
@benjlevesque
benjlevesque / jwt-utils.sh
Last active March 14, 2023 20:17
Bash utils to decode a JWT token.
#!/bin/bash
jwt-decode () {
jq -R 'split(".") | .[1] | @base64d | fromjson' $1
}
jwt-exp () {
jq -rR 'split(".") | .[1] | @base64d | fromjson | .exp | todate' $1
}
@benjlevesque
benjlevesque / autocommitmessage.js
Last active March 8, 2024 10:55
A utility to commit staged changes based on current branch. Add as git alias "autocommit". Usage: `gcb feat/my-domain/my-title`. Then : `git autocommit`.
#!/usr/bin/env node
// @ts-check
const replaceDashes = (str) => str.replace(/(?<!-)-(?!-)/g, ' ').replace(/--/g, '-');
try {
const { execSync } = require("child_process");
const branch = execSync("git rev-parse --abbrev-ref HEAD").toString();
const { change, domain, title } = branch.match(
/((?<change>\w*)\/)((?<domain>.*)\/)?(?<title>.*)/
@benjlevesque
benjlevesque / faq.md
Last active October 7, 2020 12:00
FAQ

FAQ

What is lorem ipsum?

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Where does it come from?

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical li

@benjlevesque
benjlevesque / README.md
Last active July 26, 2020 14:04
set-cluster - Switch GKE cluster with multiple GCP accounts

set-cluster

Motivation

I use multiple GKE (Google Kubernetes Engine) cluster, which I access from multiple Google accounts (work and personal).

Switching from personal and work context is a pain, as you first need to switch your gcloud account, then change the current cluster for kubectl. I always ended up messing up my configs (default namesapces...) so I created this script.

Requirements

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

import { EthereumPrivateKeySignatureProvider } from "@requestnetwork/epk-signature";
import * as RequestNetwork from "@requestnetwork/request-client.js";
const data = {
signatureInfo: {
method: RequestNetwork.Types.Signature.METHOD.ECDSA,
privateKey: '0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3',
},
requestCreationHash: {
currency: RequestNetwork.Types.RequestLogic.CURRENCY.BTC,
@benjlevesque
benjlevesque / get-latest-tags.sh
Last active March 28, 2019 15:14
get most recent tags for a repository on AWS ECR
aws ecr describe-images \
--repository-name REPO_NAME \
--region eu-west-1 | jq -s -c '.[].imageDetails | sort_by(-.imagePushedAt) | first | {tags: .imageTags, date: .imagePushedAt | strftime("%d/%m/%Y %H:%M")}' | jq
@benjlevesque
benjlevesque / kubedashboard.sh
Created February 4, 2019 13:25
Run Kubedashboard in 1 command
#! /bin/zsh
echo ${$(kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk '{print $1}') | grep token:)#'token:'} | xargs | xclip -selection clipboard && echo 'Token copied to clipboard' && xdg-open 'http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login' && kubectl proxy