Skip to content

Instantly share code, notes, and snippets.

View arueckauer's full-sized avatar
🕵️‍♂️
Looking for 42

Andi Rückauer arueckauer

🕵️‍♂️
Looking for 42
View GitHub Profile
@arueckauer
arueckauer / style.css
Created January 6, 2020 10:56
Inline Definition List
dl {
display: grid;
grid-template-columns: auto 1fr;
grid-gap: .5rem 1rem;
}
@arueckauer
arueckauer / hosts.ps1
Created March 4, 2019 22:13 — forked from markembling/hosts.ps1
Powershell script for adding/removing/viewing entries to the hosts file.
#
# Powershell script for adding/removing/showing entries to the hosts file.
#
# Known limitations:
# - does not handle entries with comments afterwards ("<ip> <host> # comment")
#
$file = "C:\Windows\System32\drivers\etc\hosts"
function add-host([string]$filename, [string]$ip, [string]$hostname) {
@arueckauer
arueckauer / gist:e0f7ecbb76779bb4d2d9bf90762b382a
Created January 28, 2019 08:39 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@arueckauer
arueckauer / gist:8206fb494d64e6a7d2b140efb986d7a3
Created January 28, 2019 08:39 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@arueckauer
arueckauer / Collection.php
Created May 8, 2018 06:03
Abstract implementation of ArrayAccess and Iterator (credits: https://www.stitcher.io/blog/aray-objects-with-fixed-types)
<?php
abstract class Collection implements \ArrayAccess, \Iterator
{
private $position;
private $array = [];
public function __construct() {
$this->position = 0;
@arueckauer
arueckauer / Anonymous classes
Created February 10, 2018 19:47
Global scope of anonymous classes
<?php
function return_anon() {
return new class{
public static $str="foo";
};
}
$test=return_anon();
var_dump($test::$str);
@arueckauer
arueckauer / Variadic function
Created February 10, 2018 19:02
Comparison of variadic functions in different PHP versions with and without type hinting
<?php
/*
* Before PHP 5.6.0
*/
function sum()
{
$result = 0;
foreach (func_get_args() as $i) {
@arueckauer
arueckauer / Fast file inclusion
Last active February 10, 2018 19:05
File loading with error suppression is faster than `file_exists`, `is_file` and `is_readable`
/**
* Error suppression is still faster than `file_exists`, `is_file` and `is_readable`
* @see https://github.com/doctrine/cache/blob/9930e3367777a8727e229f5126c5299890d700bb/lib/Doctrine/Common/Cache/PhpFileCache.php#L111-L112
*/
$value = @include $fileName;
@arueckauer
arueckauer / Referenced method recognition fails
Last active February 10, 2018 19:09
Although signature is correctly set, PHPStorm fails to recognize referenced method in third position.
<?php
class Foo
{
private $a;
private $b;
private $c;
public function __construct($a, $b, $c)
@arueckauer
arueckauer / Protected property access
Last active February 10, 2018 19:11
Access of protected property via magic method __get()
<?php
class A
{
protected $protectedProperty = 'secret value of A';
public function __get($property)
{
return $this->$property;
}