Skip to content

Instantly share code, notes, and snippets.

View lidio601's full-sized avatar

Fabio Cigliano lidio601

View GitHub Profile
@lidio601
lidio601 / README.md
Last active October 29, 2018 18:04
Nginx + PHPfpm timeout test

Nginx + PHPfpm timeout test

Test the connection timeout by tweaking those parameters: fastcgi_read_timeout, request_terminate_timeout, set_time_limit.

  • If hitting the fastcgi_read_timeout setting, Nginx will terminate the HTTP connection with a HTTP 504
  • If hitting the request_terminate_timeout setting, PHPfpm will terminate the HTTP connection with a HTTP 502
  • If hitting the set_time_limit setting, PHP itself will terminate the HTTP connection with a HTTP 200
@lidio601
lidio601 / kill_zombies.sh
Created November 24, 2017 08:04
Kill all zombie processes
kill $(ps -A -ostat,ppid | awk '/[zZ]/{print $2}')
@lidio601
lidio601 / crawl_website.sh
Created November 20, 2017 08:45
Crawl an entire website (pages + resources) into a local folder
# Simple as is
wget --recursive --page-requisites --convert-links www.libero.it
# exit if a command fails
set -e
@lidio601
lidio601 / send_email_with_attachment.sh
Created November 19, 2016 15:04
How to send an image via email
# Setup
apt-get install -y sharutils
# How to
f=image0001.png
uuencode $f `basename $f` | mail -s "see the attachment" root@example.com
@lidio601
lidio601 / nginx_ssl_proxy.conf
Created October 14, 2016 07:10
Nginx SSL Proxy configuration to bridge with
#
# Nginx SSL Proxy
# @link https://gist.github.com/lidio601/aa97397f8cdb5f405ce770dde2fe3c2b
# @link https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-with-ssl-as-a-reverse-proxy-for-jenkins
#
# Redirect all HTTP requests to SSL
server {
@lidio601
lidio601 / website_validator.sh
Last active October 13, 2016 15:54
This is a simple Web Page validator which keep a local cache copy and check if the web page content over time. This is useful in case your website got replaced for some reason, while the web server keep answering HTTP 200 but the actual content has been changed. This script is intended to run within a monit script
#!/bin/bash
#WEBSITE="http://example.com"
#THRES=3
#FORCE=$3
CACHEDIR=/tmp
if [ -t 1 ]
then
@lidio601
lidio601 / movie2gif.sh
Last active May 20, 2016 09:11
Video2GIF Convert a video file (maybe a ScreenCast) to a GIF - I usually use QuickCast to output an MP4 video file, then convert it into a GIF
#!/bin/bash
IN="quickcast.mp4"
OUT="output.gif"
# INPUT FILE: quickcast.mp4
# OUTPUT FILE: output.gif
ffmpeg -y -i $IN -vf fps=10,scale=320:-1:flags=lanczos,palettegen palette.png
ffmpeg -i $IN -i palette.png -filter_complex "fps=5,scale=640:-1:flags=lanczos[x];[x][1:v]paletteuse" -y $OUT
@lidio601
lidio601 / print_debug_information.sh
Created January 11, 2016 19:21
In Bash scripting when you want to print useful information when debugging a script from terminal but not when executed in background (like from crontab)
#!/bin/bash
if [ -t 1 ]
then
: # running from terminal
debug="1"
else
: # not running from terminal, cron maybe
debug="0"
fi
@lidio601
lidio601 / mac_label.sh
Created September 20, 2015 20:08
Apply a Mac Tag / Label color to a file via Bash + AppleScript
#!/bin/bash
# http://stackoverflow.com/questions/6212219/passing-parameters-to-a-bash-function
# http://superuser.com/questions/168927/mac-os-x-how-to-change-the-color-label-of-files-from-the-terminal
# Set Finder label color
label() {
#echo "Default colors:"
#echo " 0 No color"
#echo " 1 Orange"