Skip to content

Instantly share code, notes, and snippets.

View TheHiddenHaku's full-sized avatar

Alessio Bottiroli TheHiddenHaku

View GitHub Profile

The command line, in short…

wget -k -K -E -r -l 10 -p -N -F --restrict-file-names=windows -nH http://website.com/

…and the options explained

  • -k : convert links to relative
  • -K : keep an original versions of files without the conversions made by wget
  • -E : rename html files to .html (if they don’t already have an htm(l) extension)
  • -r : recursive… of course we want to make a recursive copy
  • -l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.
@TheHiddenHaku
TheHiddenHaku / test-php-basic-auth.php
Created November 21, 2019 15:41 — forked from rchrd2/test-php-basic-auth.php
PHP basic auth example
<?php
function require_auth() {
$AUTH_USER = 'admin';
$AUTH_PASS = 'admin';
header('Cache-Control: no-cache, must-revalidate, max-age=0');
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
$is_not_authenticated = (
!$has_supplied_credentials ||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
ROUND((RAND() * (max-min))+min)
@TheHiddenHaku
TheHiddenHaku / gist:70a0c94585956442ecdc141cf1cd3667
Created May 29, 2018 16:26 — forked from matoakley/gist:1092571
MySQL to convert a string into a slug
LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TRIM('My String'), ':', ''), ')', ''), '(', ''), ',', ''), '\\', ''), '\/', ''), '\"', ''), '?', ''), '\'', ''), '&', ''), '!', ''), '.', ''), ' ', '-'), '--', '-'), '--', '-')) AS `post_name`
@TheHiddenHaku
TheHiddenHaku / nginx.conf
Created March 29, 2016 07:59 — forked from bjorn2404/nginx.conf
WordPress load remote images if they don't exist on the local development server NGINX. vagrant provision after editing site conf file.
location ~ ^/wp-content/uploads/(.*) {
if (!-f $request_filename) {
rewrite ^/wp-content/uploads/(.*)$ http://www.remotesite.com/wp-content/uploads/$1 redirect;
}
}
@TheHiddenHaku
TheHiddenHaku / dumper.sh
Created December 13, 2015 00:30
Backup All MySQL dbs in separate files
#! /bin/bash
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/backup/$TIMESTAMP"
MYSQL_USER="backup"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD="password"
MYSQLDUMP=/usr/bin/mysqldump
mkdir -p "$BACKUP_DIR/mysql"
@TheHiddenHaku
TheHiddenHaku / example.conf
Created October 10, 2015 13:56
Simple Apache 2.5 / PHP-Fpm Virtual Host
<VirtualHost *:80>
ServerAdmin admin@email.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /path/to/document/root
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /path/to/document/root>
AllowOverride All
Require all granted
@TheHiddenHaku
TheHiddenHaku / pingandchec404
Created July 3, 2015 06:55
ping url then check for 404
read -e -p "Inserisci il server/dominio da controllare: " yourURL
read -e -p "Ora inserisci il percorso sul server da aprire: " yourPath
((count = 1000000)) # Maximum number to try.
while [[ $count -ne 0 ]] ; do
ping -c 1 "$yourURL" # Try once.
rc=$?
if [[ $rc -eq 0 ]] ; then
((count = 1)) # If okay, flag to exit loop.
fi
@TheHiddenHaku
TheHiddenHaku / check404
Created July 3, 2015 06:53
Check if url is 404
read -e -p "Inserisci la URL da controllare: " yourURL
while [ 1 ]
do
if curl --output /dev/null --silent --head --fail "$yourURL"
then
echo "This URL Exist"
open $yourURL
exit
else
# ----------------------------------------------------------------------
# /PUBLIC folder .htaccess
# ----------------------------------------------------------------------
# This .htaccess file is recommended
# to be placed at root/public folder
# of your Laravel powered application
# ----------------------------------------------------------------------
# This file works with Laravel 3 and 4
# ----------------------------------------------------------------------
# Turning on the rewrite engine is necessary for the following rules and