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 / equal_columns.css
Created April 20, 2017 13:24
Equal size columns with pure CSS. Uses bottom-padding-margin-trick where the overstanding elements will be cutted to proper size by overflow:hidden. From http://stackoverflow.com/questions/1205159/html-css-making-two-floating-divs-the-same-height
#container {
overflow: hidden;
width: 100%;
}
#left-col {
float: left;
width: 50%;
background-color: orange;
padding-bottom: 500em;
margin-bottom: -500em;
<?PHP
$my_URL="http://some-website.com/mydata.txt";
$lines = file($my_URL);
foreach ($lines as $line_num => $line)
{
echo $line_num." ".$line;
}
?>
jQuery.fn.messagePlugin = function(){
var selectedObjects = this;
return {
saySomething : function(message){
$(selectedObjects).each(function(){
$(this).html(message);
});
return selectedObjects; // Preserve the jQuery chainability
},
anotherAction : function(){
@Hexodus
Hexodus / map_replace.js
Created April 17, 2017 15:23
Map Replace function. Replace multiple keys inside string with multiple values http://stackoverflow.com/a/15605648/1600193
String.prototype.map_replace = function (values) {
var string = this, key;
for (key in values) {
string = string.replace(new RegExp('\\{' + key + '\\}', 'gm'), values[key]);
}
return string
}
//usage
var input_string = document.getElementById('my-input').innerText;
var output_element = document.getElementById('my-output');
//here we go
var right_text = input_string.substring(0, input_string.indexOf(":"));
output_element.innerText = right_text;
@Hexodus
Hexodus / composer_help.snippets
Last active April 17, 2017 07:23
Composer basic command line commands for installing and updating packages.
//installs "packagename" latest version
composer require vendorname/packagename
//installs package version 1.2
composer require vendorname/packagename 1.2
//installs package version above 1.2 but lesser then 2.0
composer require vendorname/packagename 1.2.*
//installs package version above 1.2 but lesser then 2.0
@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;
phonegap plugin add cordova-plugin-app-version --save
/*
'--save' command also saves the plugin in the config.xml
*/
@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!
@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) {