Skip to content

Instantly share code, notes, and snippets.

View martindilling's full-sized avatar
🏴‍☠️

Martin Dilling-Hansen martindilling

🏴‍☠️
View GitHub Profile
@martindilling
martindilling / Circle Output
Last active May 25, 2021 08:38
The actual "application" code isn't that great, but the structure of the objects should be decent to work with and make it easy to expand the system with more shapes or calculating different things for shapes. For example, add a method on the Shape interface to get the circumference, then you're forced to implement that method on all the shapes.
--------------------------------------------------------------------------------
Choose shape:
1: Rectangle
2: Isosceles Triangle
3: Circle
#> 3
--------------------------------------------------------------------------------
Write the arguments for a Circle:
#Radius> 15
#!/bin/bash
# Replace with the correct url to the raw file
# curl -L https://url_to_raw/install_elasticsearch.sh | bash
echo "###"
echo "### Install Java 8..."
echo "###"
sudo apt-get update
sudo apt-get install -y python-software-properties debconf-utils
@martindilling
martindilling / example.php
Last active May 25, 2021 08:37
Example of keeping a class immutable, meaning that from the outside you are not able to modify the object after it has been instantiated.
<?php
class User
{
/**
* @var int
*/
private $id;
/**
@martindilling
martindilling / colors.col
Last active June 3, 2018 17:46
Color schema for SequoiaView
MKV 128 255 192
FLV 128 255 192
MPG 128 255 192
MPEG 128 255 192
WMV 128 255 192
MP4 128 255 192
MOV 128 255 192
AVI 128 255 192
M4V 128 255 192
WEBM 128 255 192
@martindilling
martindilling / engine.js
Created January 4, 2019 14:26
Simple Entity Component System game engine in Javascript
window.ECS = {
Engine: {
Game: null,
Entity: null,
},
Components: {},
Systems: {},
Entities: {},
/**
* @type {ECS.Engine.Game}
@martindilling
martindilling / wat.php
Last active May 25, 2021 08:25
Sometimes you find crazy things
<?php
$value = function (string $field, $default = null) use ($input_data, $notification, $user_setup) {
$from_attr = substr($field, 0, 1) === '!';
$val = $from_attr ? $user_setup->get(substr($field, 1), array_get($input_data, substr($field, 1), $default)) : $val = array_get($input_data, $field, $default);
return htmlentities(substr($val, 0, 1) === '@' ? $notification->payload->get(substr($val, 1), $default) : $val);
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@martindilling
martindilling / _php_function_to_find_birthdate_from_cpr_number.md
Last active May 25, 2021 08:58
Calculate the full birthdate given a CPR number.

cprToBirthdate(string $cpr): ?string