Skip to content

Instantly share code, notes, and snippets.

View Eddy-Barraud's full-sized avatar

Eddy Barraud Eddy-Barraud

View GitHub Profile
@Eddy-Barraud
Eddy-Barraud / ram_disk_create.sh
Created May 16, 2018 14:57
Sync ram disk with hard disk & mount it
mkdir /ramdisk
mount -t tmpfs -o size=2048M tmpfs /ramdisk
or copy inside /etc/fstab
tmpfs /media/ramdisk tmpfs rw,size=2048M 0 0
And do :
mount -a
@Eddy-Barraud
Eddy-Barraud / tmux_watch.sh
Created May 16, 2018 15:01
Start a tmux with top - hour - iftop ; uses panes ;
#!/bin/bash
source /root/.bashrc
tmux kill-session -t watch
tmux new -d -s watch
tmux send-keys -t watch:0.0 'tmux split-window -h' ENTER
tmux send-keys -t watch:0.0 'tmux split-window' ENTER
tmux send-keys -t watch:0.0 'tmux split-window' ENTER
sleep 1
tmux send-keys -t watch:0.1 'top' ENTER
tmux send-keys -t watch:0.2 'iftop' ENTER
@Eddy-Barraud
Eddy-Barraud / .bash_aliases
Created May 16, 2018 15:06
Usefull bash aliases : location in ~/.bash_aliases
alias header='curl -I --insecure'
alias top='top -d1'
alias ttfb='curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n"'
alias avg='cat /proc/loadavg'
alias cs='pidstat -hw | head -3 && pidstat -hw | tail -n +3 | sort -nr -k 4 | head -n 10'
alias pflog='cat /var/log/mail.log | /root/scripts/pflogsumm-1.1.1/pflogsumm.pl'
alias logmail='tail -f /var/log/mail.log'
alias dl='aria2c -x5'
alias ngxreport='goaccess -f /var/log/nginx/access.log -a > report.html'
@Eddy-Barraud
Eddy-Barraud / audio-convert.sh
Last active May 16, 2018 16:28
Convert every audio files inside the current directory to mp3
#!/bin/bash
find . -regex ".*\.\(opus\|ogg\|m4a\)" -print0 |
while IFS= read -r -d $'\0' filename; do
echo $filename
name="${filename%.*}"
< /dev/null ffmpeg -nostats -loglevel 0 -n -i "$filename" -b:a 0 -codec:a libmp3lame -vn "./$name.mp3"
done
@Eddy-Barraud
Eddy-Barraud / download_webpage.sh
Created May 17, 2018 14:53
Download a webpage with wget recursively
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains www.domain.com \
--no-parent \
www.domain.com
#COPY FILES TO THE PROGRAM DIR
New-Item -ItemType Directory -Force -Path "${env:programfiles(x86)}\Aria2\"
Copy-Item aria2c.exe "${env:programfiles(x86)}\Aria2\"
Copy-Item installer.ps1 "${env:programfiles(x86)}\Aria2\"
Copy-Item nssm.exe "${env:programfiles(x86)}\Aria2\"
#Install the service
##Verify that it's not already installed
sc.exe stop aria2c-rpc
sc.exe delete aria2c-rpc
sleep 2
#Edit /etc/locale.gen
nano /etc/locale.gen
#Uncomment en_US.UTF-8 UTF-8
#DO
locale-gen

Using imegemagick

apt-get install imagemagick

  • Convert single file

    convert ubuntuhandbook.png ubuntuhandbook.jpg

  • Convert all files

@Eddy-Barraud
Eddy-Barraud / Renaming_files_to_sequential_numbers.md
Last active June 16, 2018 23:47
Renaming files in a folder to sequential numbers

Here are multiple ways to rename files inside a folder to a sequential numbers

1- In one line :

ls | cat -n | while read n f; do mv "$f" "$n.extension"; done

you can also use ls -uT to sort files by creation date

2- With the 'rename' command

<?php
$characters = ["a", "b", "c", "d", "e", "f", "g", "h",
"i", "j", "k", "l", "m", "n", "o", "p",
"q", "r", "s", "t", "u", "v", "w", "x",
"y", "z", "A", "B", "C", "D", "E", "F",
"G", "H", "I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z", "1", "2", "3", "4",
"5", "6", "7", "8", "9", "0"];