Skip to content

Instantly share code, notes, and snippets.

View fabienduhamel's full-sized avatar

Fabien Duhamel fabienduhamel

View GitHub Profile
@fabienduhamel
fabienduhamel / cr_sed.sh
Last active October 6, 2015 16:49
Sed replace with carriage returns
sed -i ':a;N;$!ba;s/\[user\]\n//g' $file
@fabienduhamel
fabienduhamel / check.sh
Created October 6, 2015 16:47
Check if cwd is in a specific directory
function gc
{
dir=`pwd`
subdir=${dir%SPECIFIC_DIR*}
if [ "$subdir" != "$dir" ]; then
# do something
fi
}
function ssh_connect ()
{
SSH_EXECUTE_COMMAND="sshpass -p $2 ssh -t $1@$3 '$4'"
eval $SSH_EXECUTE_COMMAND
}
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
@fabienduhamel
fabienduhamel / gist:39b9d3f35138c9111815
Created March 28, 2016 13:14
How to recover an Ubuntu lost public key (after upgrade)
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com XXXXXXX
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to make opened Markdown files always be soft wrapped:
#
# path = require 'path'
#
@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 / docker-compose.yml
Last active August 27, 2016 15:57
Docker compose for symfony app
code:
image: debian:jessie
volumes:
- .:/var/www/html
mysql:
image: mysql
environment:
MYSQL_DATABASE: root
MYSQL_ROOT_PASSWORD: root
@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 / gist
Last active January 7, 2017 23:55
Set newly files as writable by group users recursively
setfacl -R -d -m g::rwx .
# will set newly created files and folders ...rwx...+ :)