Skip to content

Instantly share code, notes, and snippets.

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

Martin Dilling-Hansen martindilling

🏴‍☠️
View GitHub Profile
@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

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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);
};
@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 / 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 / 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;
/**
#!/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 / 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
@martindilling
martindilling / index.php
Created August 25, 2016 11:08
Very very simple template implementation
<?php
/**
* Load a template passing the given data into it.
*
* Note: Assumes templates are loaded from a 'templates' folder.
* Use dot-notation for defining the template name.
* Don't include the file extension in the template name.
* eg. 'pages.home' > 'templates/pages/home.php'
* 'partials.elements.contact-button' > 'templates/partials/elements/contact-button.php'
@martindilling
martindilling / keybase.md
Created July 28, 2016 09:00
Keybase proof

Keybase proof

I hereby claim:

  • I am martindilling on github.
  • I am martindilling (https://keybase.io/martindilling) on keybase.
  • I have a public key ASBSLXzVcyxkYyHJi5VZ0MOMhv7EzBhsvTY1IdfNa-9HHAo

To claim this, I am signing this object: