Skip to content

Instantly share code, notes, and snippets.

View datYori's full-sized avatar
🛹

Yann Bouzonie datYori

🛹
  • RAW Labs S.A
  • Lausanne - Switzerland
  • 21:16 (UTC +02:00)
  • X @datYori
View GitHub Profile
@datYori
datYori / firstgitadddate.sh
Created April 16, 2024 14:46
first add commit for a file
WIDTH=35 ; for filename in * ; do created_date=$(git log --follow --format=%ad --date default $filename | tail -1); printf "%-${WIDTH}s | %s \n" "$created_date" $filename ; done | sort
@datYori
datYori / build.sbt
Created August 24, 2023 13:23
find unused Dependencies.scala val in build.sbt
import scala.io.Source
import scala.util.matching.Regex
val findUnusedDeps = taskKey[Unit]("Finds unused dependencies from Dependencies.scala")
findUnusedDeps := {
// 1. Parse Dependencies.scala
val depsFile = (baseDirectory.value / "project" / "Dependencies.scala").getAbsolutePath
val depsContent = Source.fromFile(depsFile).getLines.mkString("\n")
val valuesRegex: Regex = """val (\w+) =""".r
@datYori
datYori / instant_switch_gha_run.sh
Last active December 4, 2023 13:10
trigger new gha workflow from non default branch
gh api -XPATCH "repos/raw-labs/$REPO_NAME" -f default_branch="$(git symbolic-ref --short HEAD)" > /dev/null && gh workflow run $WORKFLOW_FULL_NAME && gh api -XPATCH "repos/raw-labs/$REPO_NAME" -f default_branch="$REPO_DEFAULT_BRANCH" > /dev/null
@datYori
datYori / switch-run-switch.sh
Last active December 19, 2022 09:00
switch default and run
export INITIAL_DEFAULT_BRANCH=${INITIAL_DEFAULT_BRANCH:-master}
export WORKFLOW_YAML=<workflow_yaml>
export ORG_REPO=<repo> # example : export REPO="raw-labs/raw"
gh api -XPATCH "${ORG_REPO}" -f default_branch="$(git symbolic-ref --short HEAD)" > dev/null \
&& gh workflow run ${WORKFLOW_YAML} \
&& gh api -XPATCH "${ORG_REPO}" -f default_branch="${INITIAL_DEFAULT_BRANCH}" > dev/null
@datYori
datYori / clean-tm-local-snap.sh
Created December 8, 2021 18:56
clear macos time machine local snapshots
for SNAPSHOT in $(tmutil listlocalsnapshots / | egrep '[0-9]{4}\-[0-9]{2}\-[0-9]{2}\-[0-9]{6}' -o | tail -r); do tmutil deletelocalsnapshots $SNAPSHOT; done
@datYori
datYori / cleanbranch.sh
Last active December 23, 2021 06:24
clean branch
git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done
@datYori
datYori / GoogleSpreadSheetTimeStamp.gs
Created March 2, 2021 14:10
SimpleTimeStampTradFromStephVB
function onEdit() {
var s = SpreadsheetApp.getActiveSheet(); // equivalent VB -> Worksheet_SelectionChange
var r = s.getActiveCell();
// on fait la meme chose pour la colonne C (index:3) et F (index:5) donc on va tout faire d'un coup
if (r.getColumn() == 3 || r.getColumn() == 5) {
var nextRCell = r.offset(0, 1); // permet d'aller chercher la cell tout de suite a droite
if (nextRCell.getValue() === '') {
var thetime = new Date();
// quand on instancie un temps on a besoin d'une zone horaire de référence
// ici on aura bien l'heure de Paris mais seulement parce-que je suis allé