Skip to content

Instantly share code, notes, and snippets.

runas /u:[my account]@outlook.com cmd.exe

This is a registry tweak tip

Windows is hidding a lot of options from the advanced power settings window. You can show options by going inside regedit at : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings Inside this folder there are a lot of subdirectories. Click on each one you want, 44f3beca-a7c0-460e-9df2-bb8b99e0cba6 for Intel Graphics as an example. You will find a

@Eddy-Barraud
Eddy-Barraud / gethint.php
Last active May 6, 2019 18:59
Sample for converting textarea containing links with php & ajax
<?php
$q = trim($_POST["q"]);
$lines = explode(PHP_EOL, $q);
$result = "";
foreach ($lines as $key => $value) {
$result .= $value . PHP_EOL;
}
echo $result;
exit;
?>
@Eddy-Barraud
Eddy-Barraud / count-number-of-lines-in-each-files.md
Created March 14, 2019 17:16
sum the number of lines in each file of a folder

Run this command to sum the number of lines in each file of a folder

find . -maxdepth 1 -type f -exec wc -l {} + | awk '{sum+=$1} END {print sum}'

@Eddy-Barraud
Eddy-Barraud / number-of-files.md
Last active February 16, 2019 12:17
List folders by the number of files inside of it, recursively

This one line command will list each folders in current path by the number of files inside of it, recursively.

find . -type d -exec sh -c "fc=\$(find '{}' -type f | wc -l); echo \"\$fc\t{}\"" \; | sort -nr

For only one/specified level of recursion :

find . -maxdepth 1 -type d -exec sh -c "fc=\$(find '{}' -type f | wc -l); echo \"\$fc\t{}\"" \; | sort -nr
@Eddy-Barraud
Eddy-Barraud / nginx_webp.conf
Created January 25, 2019 17:46
Serves webp images instead of jpg or png if supported by browser
http {
##
# WebP conf
##
map $http_accept $webp_suffix {
default "";
"~*webp" ".webp";
}
@Eddy-Barraud
Eddy-Barraud / ALL-m4a-to-mp3.sh
Created December 30, 2018 12:55
convert each m4a inside a folder to mp3
find . -type f -name '*.m4a' -exec bash -c 'avconv -i "$0" "${0/%m4a/mp3}"' '{}' \;

Install fail2ban

apt install fail2ban

Fail2ban will ban IPs reported in log files. So, you need to configure it to know wich reported IP is to ban.

All configs are located in /etc/fail2ban/ A jail is configured inside the jail.local file that will overwrite jail.conf. It refferes to a filter file inside the filter.d folder. Here are some usefull example of jails.

[DEFAULT]

@Eddy-Barraud
Eddy-Barraud / nginx-amp.conf
Last active January 20, 2019 14:35
Redirect every mobiles to the amp version of the site with map and try files
http{
...
##
#AMP
##
map $http_user_agent $mobile_agent{
default "";
"~*android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino" "/amp/";