Skip to content

Instantly share code, notes, and snippets.

View Dormilich's full-sized avatar

Bertold von Dormilich Dormilich

View GitHub Profile
@Dormilich
Dormilich / example-network-v4.php
Created November 13, 2020 15:17
Script to get an example network for use in test setups.
<?php
/**
* @param integer $prefix CIDR prefix (24..32).
* @return array
*/
function example(int $prefix): array
{
// Networks for documentation (RFC 5737)
$source = ['192.0.2.0', '198.51.100.0', '203.0.113.0'];
@Dormilich
Dormilich / vector.js
Last active November 13, 2020 15:20
Follow the movement of an object
/**
* Create an immutable vector object. There's no assumption made on what
* the "unit" and hence the meaning of the vector is.
*
* @param (Number) x - vector value in x-direction
* @param (Number) y - vector value in y-direction
* @return (Object)
*/
function vector(x, y)
{
@Dormilich
Dormilich / ErrorHandler.php
Last active November 13, 2020 15:22
Extensible error handling class
<?php
namespace Dormilich\Core;
/**
* Set a custom error handler that is valid as long as this instance is not
* garbage collected.
*/
class ErrorHandler
{
@Dormilich
Dormilich / filter_array.php
Last active November 13, 2020 15:22
A function to apply the functionality of filter_input() to arbitrary arrays
/**
* filter_input() for arbitrary arrays.
*
* @param array $data The array to fetch the data from.
* @param string $name The array key of interest.
* @param integer $filter A filter constant
* @param integer|array $options Either a filter flag or an array denoting
* flags and/or options.
* @return mixed The requested value or FALSE or NULL.
*/
@Dormilich
Dormilich / gist:6900e258dec2674b0d63
Created March 20, 2015 08:52
setup for git-completion
# Reset
Color_Off='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple