Get the clients IP address

$clientIpAdress = isset($_SERVER['HTTP_CLIENT_IP'])?$_SERVER['HTTP_CLIENT_IP']:isset($_SERVER['HTTP_X_FORWARDED_FOR'])?$_SERVER['HTTP_X_FORWARDED_FOR']:$_SERVER['REMOTE_ADDR'];

Do *not* use this on it’s own for security purposes!

Sort the output of ‘ls’

Sort ls output – Directories, then files, then links:

ls -la | grep "^d" && ls -la | grep "^-" && ls -la | grep "^l"

HyperHTML

The 8-Point Grid

Intro to The 8-Point Grid System

Spec.fm on The 8-Point Grid

PHP: URL path to file in same directory

<?php
$urlPathToFileInSameDirectory = (isset($_SERVER['HTTPS'])) ? "https" : "http" . str_replace('/index.php',"",str_replace(basename(__FILE__),"","://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]")).'/MyFileName.txt';
?>

 

Remote WordPress File Dump with wget & ftp (excluding uploads dir)

Put this in a bash script and execute it:

#!/bin/bash
wget -X /PATH/TO/WP_ROOT/wp-content/uploads -r -nH -nc ftp://FTP_USER:FT_PPW@FTP_HOST//WP_ROOT

Bash CLI Farben/Colors

reg bld und tput-command-colors
 Text Text Text $(tput setaf 1)
 Text Text Text $(tput setaf 2)
 Text Text Text $(tput setaf 3)
 Text Text Text $(tput setaf 4)
 Text Text Text $(tput setaf 5)
 Text Text Text $(tput setaf 6)
 Text Text Text $(tput setaf 7)
 Bold $(tput bold)
 Underline $(tput sgr 0 1)
 Reset $(tput sgr0)

Prevent perpetual WordPress login redirects in local and test installations

To prevent perpetual login redircet loops in local/development WordPress installations add this function to your wp-config.php (have it return the users ID you want to authenticate):

function wp_validate_auth_cookie($cookie='',$scheme='')
{
        return 1; // admin user id
}

PhpMyAdmin SQL Dump – split into smaller files / in kleinere Dateien aufteilen

csplit MEINE_SQL_DATEI.sql '/-- --------------------------------------------------------/' {9999} && rename 's/(xx.*)/$1.sql/' *

xx – Je nach Anzahl der Fragmentdateien stehen im Prefix mehr oder weniger Xe.

PHP Frameworks & Toolkits

Online IDEs