Skip to content

Instantly share code, notes, and snippets.

View eric-glb's full-sized avatar

Éric eric-glb

  • France
  • 12:08 (UTC +01:00)
View GitHub Profile
@eric-glb
eric-glb / separators.sh
Created August 21, 2024 21:04
shell: separator line
perl -le 'print "─"x80'
printf "%80s" " " | tr ' ' '-'; echo
printf "─%.0s" $(seq 1 80); echo
@eric-glb
eric-glb / list_swapped_out.sh
Created July 30, 2024 08:51
List swapped out processes
(
echo -e "Name\tPID\tSwap\n----\t---\t----"
for file in /proc/*/status; do
awk '/^(VmSwap|Name|Pid):/{printf $2 " " $3}END{ print ""}' $file 2>/dev/null
done | sort -k 3 -n -r | head -20
) | column -t
@eric-glb
eric-glb / centos7-dl_last_docker_rpms.sh
Last active July 16, 2024 15:20
Docker - RHEL7 / CentOS 7: get last packages
#!/bien/env bash
SRC=https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
rm -rf /tmp/centos7
mkdir -p /tmp/centos7
cd /tmp/centos7
curl -s $SRC | \
perl -MSort::Versions -nle '
@eric-glb
eric-glb / WG.sh
Last active May 12, 2024 22:49
Wireguard: script to enable / disable VPN connection from CLI
#!/usr/bin/env bash
export LC_ALL=C
CLEAR="\e[0;m"
RED="\e[1;31m"
GREEN="\e[1;32m"
YELLOW="\e[1;33m"
UP="\e[1A" # Move cursor one line up
CL="\r$(printf %$(tput cols)s)\r" # Clear line
@eric-glb
eric-glb / howto-capslock-apple-keyboard.md
Last active March 19, 2024 08:47
Macbook Air 6.2 (2014) Azerty keyboard / Debian: CapsLock like on Windows

Debian: CapsLock like on Windows (Macbook Air edition)

How to configure the keyboard on Debian in order for capslock to function like on Windows, using a french Apple Keyboard (French (Macintosh)).

Solution found here, adapted for my old french Macbook Air.

Configuration file to create:

@eric-glb
eric-glb / steampipe-plugin-vanta_post-processing.md
Created September 27, 2023 10:56
steampipe & steampipe-plugin-vanta output issue: post-processing with Perl
@eric-glb
eric-glb / git-debug.md
Created August 21, 2023 15:07
How to debug git CLI issues
@eric-glb
eric-glb / show-notification.sh
Last active August 6, 2023 20:27
Bash: show a notification in the terminal's last line
write_message() {
local message
message=" ${*} "
__write() {
local reset col_bg col_fg
reset="$(tput sgr0)"
col_bg="$(tput setab 4)"
col_fg="$(tput setaf 0)"
[[ "${2-}" == "--no-background" ]] && unset col_bg
tput sc
@eric-glb
eric-glb / switch-mic
Last active May 24, 2023 11:58
Linux: short script to mute/unmute mic (to associate to a keyboard shortcut)
#!/usr/bin/env bash
# Short script to mute/unmute mic; to associate to a keyboard shortcut
icon="audio-input-microphone-symbolic"
state=$(amixer set Capture toggle | awk 'match($0, /Front Left.*\[(.*)\]/, a) {print a[1]}')
# On Debian/Ubuntu/...: apt-get install libnotify-bin
which notify-send &>/dev/null && notify-send --hint=int:transient:1 -i $icon "Mic switched: $state"
echo -e "\nMic switched: $state\n"

Use a squid proxy cache container for container build

Assuming we run a squid container configured.

Ensure the RH-based container will only use one external repo

FROM centos:7
RUN  sed -i '/^mirrorlist/d; s/^#baseurl=/baseurl=/' /etc/yum.repos.d/*.repo
...