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;
}
}
# ----------------------------------------------------------------------
# /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
<?php
// Next two functions taken from a commenter on http://php.net/manual/en/function.unserialize.php
function unserialize_recursive($val) {
//$pattern = "/.*\{(.*)\}/";
if(is_serialized($val)){
$val = trim($val);
$ret = unserialize($val);
if (is_array($ret)) {
foreach($ret as &$r) $r = unserialize_recursive($r);
@TheHiddenHaku
TheHiddenHaku / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# Why rewrite URLs? Read this: http://en.wikipedia.org/wiki/Rewrite_engine
# Apache (.htaccess or httpd.conf)
# Make sure AllowOverride is on for the directory, or put the rewrite rules in httpd.conf
# http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
# Nginx (nginx.conf)
@TheHiddenHaku
TheHiddenHaku / recursive_unserialize.php
Last active August 29, 2015 14:08 — forked from SimonEast/gist:1117476
Recursive unserialize functions
<?php
// Next two functions taken from a commenter on http://php.net/manual/en/function.unserialize.php
function unserialize_recursive($val) {
//$pattern = "/.*\{(.*)\}/";
if(is_serialized($val)){
$val = trim($val);
$ret = unserialize($val);
if (is_array($ret)) {
foreach($ret as &$r) $r = unserialize_recursive($r);