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 / 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 / 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 / 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 / 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 / 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 / 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 / unity_first_level_child_of
Last active April 14, 2017 11:50
How to find out if an element is the first child of some other game object in unity?Unity GetComponentsInChildren method return all children which is not what's needed. So I'm using this method for this purpose instead.
/**
* find out if child is first level child of given GO
* @return Transform
**/
bool IsFirstLevelChildOf(Transform root, Transform child)
{
bool isFirstLevel = false;
var children = root.GetComponentsInChildren<Transform>();
foreach(var c in children) {
if (c.parent == root && c == child) {
@Hexodus
Hexodus / UnityLateStart
Last active April 14, 2017 11:50
While Unit doesen't offer a LateStart() this is to be use meanwhile
void Start ()
{
StartCoroutine (LateStart());
}
IEnumerator LateStart()
{
yield return new WaitForEndOfFrame ();
// Do your magic here!
phonegap plugin add cordova-plugin-app-version --save
/*
'--save' command also saves the plugin in the config.xml
*/
@Hexodus
Hexodus / unity_find_inactive_game_object
Last active June 15, 2017 12:55
Find inactive Game Objects in Unity 3D. The right method to go is to search over the parents transform for a script on the child like this.
var theParentGO = GameObject.Find("ParentName");
theParentGO.transform.GetComponentInChildren<ScriptOnTheChild>(true).gameObject;