Skip to content

Instantly share code, notes, and snippets.

View stefanofiorentino's full-sized avatar

Stefano Fiorentino stefanofiorentino

View GitHub Profile
@stefanofiorentino
stefanofiorentino / git-gone
Last active December 23, 2021 08:43
git script to add to $PATH to be launched by `git gone` or `git gone --force` (it only print commands to issue)
#!/bin/bash
git fetch
REMOTE=origin
if [ $# -ge 1 ]; then
REMOTE=$1
fi
echo "Pruning ${REMOTE}: $#"
@stefanofiorentino
stefanofiorentino / gist:aa0e76dadfd1fdb0cb0267c28363e306
Created November 7, 2019 16:47
c/c++ function to translate RGB bash terminal colot
// based on https://gist.github.com/mhulse/b11e568260fb8c3aa2a8
void UserLedManager::print_terminal_background_color(const int &r, const int &g, const int &b) const
{
auto r_weight = r < 75 ? 0 : (r - 35) / 40;
auto g_weight = g < 75 ? 0 : (g - 35) / 40;
auto b_weight = b < 75 ? 0 : (b - 35) / 40;
int status = (r_weight * 6 * 6 + g_weight * 6 + b_weight + 16);
fprintf(stdout, "\e[48;5;%dm %3d \e[0m", status, status);
fflush(stdout);
}
From c1bc3bf02474fc4aa44e81b153e49b039a1f74b7 Mon Sep 17 00:00:00 2001
From: "Fiorentino Ing. Stefano" <stefano.fiore84@gmail.com>
Date: Fri, 22 May 2020 18:40:28 +0200
Subject: [PATCH] (extern) explicit instantiation of a type_factory
Signed-off-by: Fiorentino Ing. Stefano <stefano.fiore84@gmail.com>
---
.github/workflows/build.yml | 45 +-
...41fa871a7e818a75275294b82d2b3555ca79.patch | 1606 +++++++++++++++++
src/CMakeLists.txt | 15 +-
@stefanofiorentino
stefanofiorentino / git-hard-reset
Last active May 6, 2020 14:31
git hard reset from repo.log from git-repos
#!/bin/bash
PREVPWD=${PWD}
echo "Current Directory -> " ${PREVPWD}
while IFS= read -r line
do
command=$(echo "$line" | awk 'BEGIN { FS = " " } ; {print "cd \""$2"\" && git reset --hard "$8}')
if eval "${command}"; then
echo "${command}"
@stefanofiorentino
stefanofiorentino / git filter-author
Created May 6, 2020 13:05
Change all signed-off on from..to commits
#!/bin/bash
OLDSIGNED="stefano.fiorentino@home"
OLDNAME="Fiorentino Stefano"
NEWSIGNED="stefano.fiorentino@work"
NEWNAME="Stefano Fiorentino"
git filter-branch --msg-filter 'sed "s/'"${OLDSIGNED}"'/'"${NEWSIGNED}"'/g"' "$@"
git filter-branch --msg-filter 'sed "s/'"${OLDNAME}"'/'"${NEWNAME}"'/g"' "$@"
@stefanofiorentino
stefanofiorentino / git-custom-reset
Created May 5, 2020 08:33
Git custom reset to hard reset all your repos to a specific tag
#!/bin/bash
if [[ ${1} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
for dir in $(find . -maxdepth 1 ! -path . -type d);
do
cd $dir
find . -type d -name '.git*' ! -path "*/poky-tmp/*" 2>/dev/null | \
sed 's/\.git$//g' | \
xargs -I '{}' sh -c 'readlink -e {};' | \
@stefanofiorentino
stefanofiorentino / git-repos
Last active May 4, 2020 10:39
git script to add to $PATH to get all sub-directories' repository commit sha
#!/bin/bash
GIT_REPOS_HOME=$PWD \
find . -type d -name '.git*' ! -path "*/poky-tmp/*" 2>/dev/null | \
sed 's/\.git$//g' | \
xargs -I '{}' sh -c 'readlink -e {};' | \
uniq | \
sort | \
xargs -I '{}' sh -c 'cd {}; echo "dir: $(pwd) url: $(git config --get remote.origin.url) branch: $(git rev-parse --abbrev-ref HEAD) hash: $(git rev-parse HEAD)"; cd $GIT_REPOS_HOME;'
#!/bin/bash
sudo git config --system --unset credential.helper
git config --global --unset credential.helper
git config --unset credential.helper
@stefanofiorentino
stefanofiorentino / git-custom-push
Created April 24, 2020 15:37
push along with meaningful tags
#!/bin/bash
for dir in $(find . -maxdepth 1 ! -path . -type d);
do
cd $dir
find . -type d -name '.git*' ! -path "*/poky-tmp/*" 2>/dev/null | \
sed 's/\.git$//g' | \
xargs -I '{}' sh -c 'readlink -e {};' | \
uniq | \
sort | \
@stefanofiorentino
stefanofiorentino / git-custom-tag
Last active April 24, 2020 14:12
git tag all repository in the current workdir
#!/bin/bash
if [[ ${1} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
for dir in $(find . -maxdepth 1 ! -path . -type d);
do
cd $dir
find . -type d -name '.git*' ! -path "*/poky-tmp/*" 2>/dev/null | \
sed 's/\.git$//g' | \
xargs -I '{}' sh -c 'readlink -e {};' | \