Skip to content

Instantly share code, notes, and snippets.

View gmolveau's full-sized avatar

Grégoire MOLVEAU gmolveau

View GitHub Profile
@gmolveau
gmolveau / offline_download.sh
Created May 19, 2022 14:58
download app/package offline with dependencies linux/ubuntu/aptitude
# source : https://stackoverflow.com/a/13757546
APPS=(
cloud-init
cloud-guest-utils
gdisk
open-vm-tools
python3-pip
)
sudo aptitude clean
for app in "${APPS[@]}"; do sudo aptitude -y --download-only install "$app"; done
@gmolveau
gmolveau / remove_old_kernels.sh
Created May 14, 2022 11:42
free space remove old kernels linux ubuntu
sudo apt-get purge $(sudo dpkg --list 'linux-image*'|awk '{ if ($1=="ii") print $2}'|grep -v `uname -r`)
sudo apt-get autoremove
sudo apt autoremove
sudo update-grub
@gmolveau
gmolveau / bash_list_missing_dependencies.sh
Last active July 25, 2023 14:37
bash script - list all missing dependencies and exit
# inspiration : https://stackoverflow.com/a/52552095
deps=0
for app in awk wget; do
! command -v ${app} &> /dev/null && echo "$app is not installed" && deps=1
done
[[ $deps -ne 0 ]] && exit 1
@gmolveau
gmolveau / Makefile
Last active June 8, 2022 13:42
makefile example best practices / opinionated from https://tech.davis-hansson.com/p/make/
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
@gmolveau
gmolveau / fsck_fix.sh
Last active September 11, 2023 21:50
fsck exited with status code 4 (initramfs)
#/dev/sda5: recovering journal
#/dev/sda5 contains a file system with errors, check forces.
#/dev/sda5:
#Inodes that were part of a corrupted system orphan linked list found.
#
#/dev/sda5: UNEXPECTED INCONSISTENCY: RUN fsck MANUALLY.
# (i.e., without -a or -p options)
#fsck exited with status code 4
#the root filesystem on /dev/sda5 requires a manual fsck
#Busybox v [...]
@gmolveau
gmolveau / vscode_download_extensions.sh
Created May 3, 2022 14:41
[offline|airgap] download vscode vsix extension from text file
# list extensions
code --list-extensions > extensions.txt
# example: esbenp.prettier-vscode
# ms-python.python
# download extensions
awk -F. '{print "wget -O "$1"."$2".vsix https://"$1".gallery.vsassets.io/_apis/public/gallery/publisher/"$1"/extension/"$2"/latest/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage"}' extensions.txt | bash
# example: esbenp.prettier-vscode.vsix
# ms-python.python.vsix
@gmolveau
gmolveau / nexus_delete.sh
Created April 28, 2022 12:07
nexus docker registry delete image by tag
#!/bin/bash
# inspiration/source : https://gist.github.com/matzegebbe/a2678b227add6bafad9a3a802618b5ad + https://issues.sonatype.org/browse/NEXUS-12711
NEXUS_HOST="nexus.domain.tld"
NEXUS_REPOSITORY="docker"
NEXUS_USER="service"
NEXUS_PASSWORD="password"
IMAGE="python"
TAG="latest"
@gmolveau
gmolveau / git_squash_all.sh
Created April 25, 2022 13:25
git reset / squash all commits in branch into one single commit
# source : https://stackoverflow.com/a/24154149
export BRANCH="main"
git checkout --orphan new-$BRANCH $BRANCH
git commit -m "Commit message that summaries all the commits"
# Overwrite the old branch reference with the new one
git branch -M new-$BRANCH $BRANCH
@gmolveau
gmolveau / autoadd.js
Created April 21, 2022 19:28
auto-add linkedin connections in group
// open the invite modal in a group
// paste the following code in the console
// try adding 50 people by batch otherwise the tab may crash
[].forEach.call(document.querySelectorAll(".invitee-picker-connections-result-item--can-invite"), function(input) {
input.click()
});
@gmolveau
gmolveau / firefox-mobile-tabs-export-json.md
Last active April 23, 2022 20:19
export firefox mobile opened/synced tabs as json and HTML-bookmarks-file
  • On firefox desktop, install the addon https://addons.mozilla.org/en-US/firefox/addon/about-sync/
  • in the URL bar, type about:sync
  • scroll down to tabs then Record Editor (server)
  • In select record choose your firefox mobile
  • Copy the JSON into a code editor and save it as firefox_mobile_tabs.json
  • run the following python code to convert it to a valid firefox bookmarks HTML file if you want to import it
import json