Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block eddydu44

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
eddydu44 / gethint.php
Last active May 6, 2019
Sample for converting textarea containing links with php & ajax
View gethint.php
$q = trim($_POST["q"]);
$lines = explode(PHP_EOL, $q);
$result = "";
foreach ($lines as $key => $value) {
$result .= $value . PHP_EOL;
echo $result;
eddydu44 /
Created Mar 14, 2019
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}'
eddydu44 /
Last active Feb 16, 2019
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
eddydu44 / nginx_webp.conf
Created Jan 25, 2019
Serves webp images instead of jpg or png if supported by browser
View nginx_webp.conf
http {
# WebP conf
map $http_accept $webp_suffix {
default "";
"~*webp" ".webp";
eddydu44 /
Created Dec 30, 2018
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.


eddydu44 / nginx-amp.conf
Last active Jan 20, 2019
Redirect every mobiles to the amp version of the site with map and try files
View nginx-amp.conf
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/";

PyInstaller Quickstart

Install PyInstaller from PyPI:

pip install pyinstaller

Go to your program’s directory and run:


It will generate an executable in a dist folder

from functools import reduce
from sympy import Symbol
X = Symbol('X')
def Lagrange(points):
P=[reduce((lambda x,y: x*y),[(X-points[j][0])/(points[i][0] - points[j][0]) for j in range(len(points)) if i != j])*points[i][1] for i in range(len(points))]
return sum(P)
You can’t perform that action at this time.