Skip to content

Instantly share code, notes, and snippets.

View fabienduhamel's full-sized avatar

Fabien Duhamel fabienduhamel

View GitHub Profile
@fabienduhamel
fabienduhamel / config-nvim-lua-config-config-keymaps.lua
Created September 19, 2024 10:10
Lazyvim personal configuration
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
vim.keymap.set("n", "<C-b>", "<Cmd>Neotree toggle<CR>")
@fabienduhamel
fabienduhamel / Redis migration script
Last active August 27, 2024 09:05
Redis migration script
#!/bin/bash
#set connection data accordingly
source_host=xxx
source_port=6379
target_host=localhost
target_port=6379
#copy all keys without preserving ttl!
redis-cli -h $source_host -p $source_port keys \* | while read key; do
ssh -q -o ConnectTimeout=4 -oBatchMode=yes $host exit && echo Connexion successful $host
@fabienduhamel
fabienduhamel / negate.txt
Last active August 17, 2017 09:33
Regex - Negate a line containing specific words
^(?!.*STRING1|.*STRING2|.*STRING3).*$
@fabienduhamel
fabienduhamel / .zshrc
Last active June 2, 2020 13:37
zsh-git-prompt with agnoster theme
# Better zsh git prompt with zsh-git-prompt
# Add it to your .zshrc after the plugins(... zsh-git-prompt ...) line
# First, it rewrites git prompt style
# Then overrides git_super_status()
# And overrides build_prompt() from agnoster (depends of what you want)
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_SEPARATOR="  "
ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg[black]%}"
@fabienduhamel
fabienduhamel / Set newly files as writable by group users recursively
Last active August 27, 2024 09:04
Set newly files as writable by group users recursively
setfacl -R -d -m g::rwx .
# will set newly created files and folders ...rwx...+ :)
@fabienduhamel
fabienduhamel / livestreamer-launcher
Last active August 11, 2016 00:10
Twitch livestreamer desktop launcher
#!/bin/bash
VIDEO="vlc"
echo "Which stream?"
read stream
starting_video_proc_count=`ps aux | grep -v grep | grep $VIDEO | wc -l`
nohup livestreamer twitch.tv/$stream best &>/dev/null & export LIVESTREAMER_ID=$!
@fabienduhamel
fabienduhamel / backup_and_restore.sh
Last active February 9, 2018 16:51
Backup and restore a hard drive by gzipping an iso
#!/bin/bash
# Backup
sudo dd if=/dev/sda | gzip > /path/to/backup.iso.gz
# Restore
sudo bash -c "gzip -dc /path/to/backup.iso.gz | dd of=/dev/sda"
@fabienduhamel
fabienduhamel / How to recover an Ubuntu lost public key (after upgrade)
Last active August 27, 2024 09:05
How to recover an Ubuntu lost public key (after upgrade)
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com XXXXXXX
for file in *.jpg;
do OUT=${file%*.jpg}.pdf;
convert -quality 300 -resize 60% $file $OUT;
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages -dCompressFonts=true -sOutputFile=out.pdf $OUT;
mv out.pdf $OUT;
done