Skip to content

Instantly share code, notes, and snippets.

View Hexodus's full-sized avatar

Adrian Maleska Hexodus

  • Wiesbaden - Germany
View GitHub Profile
@Hexodus
Hexodus / sort_multi_dimensional_associative_array_by_value.php
Created March 30, 2016 18:59
This sorts a multidimensional associative array and keeps the values. Please note that uasort() and usort() are sorting an array and not returning a new one.
uasort($array_to_sort, function($a, $b)
{
return $a['order'] - $b['order'];
});
@Hexodus
Hexodus / invert_darken_page_colors.css
Created March 30, 2016 17:57
Invert a bright website to be a dark one.
/* CSS Document */
html {
-webkit-filter: invert(100%) hue-rotate(270deg) brightness(100%) contrast(100%);
background: #222;
}
@Hexodus
Hexodus / recaptcha_secure_token_generation.php
Created March 12, 2016 13:15
Google ReCaptcha secure token generation using slushie class from: https://github.com/slushie/recaptcha-secure-token/blob/master/lib/ReCaptchaToken.php Secure token makes it possible to use ReCaptcha for testing on localhost.
<?PHP
use ReCaptchaSecureToken\ReCaptchaToken as ReCaptchaToken;
require_once("ReCaptchaToken.php");
//Generate recaptcha token
$recaptcha_config = [
'site_key' => 'your-site-key',
'site_secret' => 'your-site-secret-key'
];
$recaptcha_token = new ReCaptchaToken($recaptcha_config);
@Hexodus
Hexodus / browser_language_extraction.php
Created March 12, 2016 13:08
Extracts the browser language. Returns the first two letters i.e.: de, en, fr
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
echo $lang;
@Hexodus
Hexodus / simple_url_routing.php
Created March 12, 2016 13:05
Rewrites all url requests to index.php and stores the path in the url variable which is being processed into $uri variable (to prevent empty values).
//.htaccess code
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
//PHP part
@Hexodus
Hexodus / Terminate Linux command with CTRL + C
Created June 22, 2014 13:38
How to terminate a started process? Maybe you accidentally started something that is obviously wrong an may take a long time to process - this hint will save you skin.
Just use:
CTRL + C
@Hexodus
Hexodus / Tar current directory except subdirectory
Created June 22, 2014 13:24
This shows how to tar the current directory except the unwanted subdirectory files.
tar cvpzf backup.tgz --exclude='dir_to_exculde/*' *
tar cvpzf backup.tgz --exclude='dir_to_exculde/*'
--exclude='dir_to_exculde' *
//The last asteric means that the current dir is used. Keep in mind that files with a dot aren't included.
//The secound example excludes also the directory from being included otherwise it would be included as empty one...
@Hexodus
Hexodus / Linux move files one directory down
Created June 10, 2014 20:16
Move files one directory down in the hierarchy on linux
mv myfolder/.* .
So for example if the data was in /home/myuser/myfolder then from /home/myuser/ run the command.
Found here:
http://unix.stackexchange.com/questions/19344/move-folder-content-up-one-level/19345#19345
@Hexodus
Hexodus / Unzip tar.gz
Created May 14, 2014 14:32
How to unzip tar.gz files
tar -zxvf my_file.tar.gz
Found here:
http://www.computing.vt.edu/kb/entry/233
@Hexodus
Hexodus / Directory Size via Shell
Created April 11, 2014 17:59
Determine directorys sizes on your webserver via shell
du -h