Skip to content

Instantly share code, notes, and snippets.

View stijn1989's full-sized avatar
I hate Python

Stijn Leenknegt stijn1989

I hate Python
View GitHub Profile
stijn1989 / map_list.dart
Created August 24, 2022 15:31
Map helpers with lists as values
///This extension contains some usefull helpers for maps
///which value contains a list of [V] objects.
extension MapList<K, V> on Map<K, List<V>>
///Add [value] to the list of [key].
///If this map doesn't contain the [key],
///a new list is added with [value] as only value.
void add(K key, V value)
stijn1989 / list_helpers.dart
Last active August 24, 2022 15:04
Some usefull list helpers
///This extension contains some usefull helpers for lists.
extension ListHelpers<E> on List<E>
///Calculates the sum of the list items.
/// [callBackValue] returns the number value of the item that is added
/// to the sum.
int sum(int Function(E item) callbackValue)
stijn1989 / ResizeTool.js
Last active May 25, 2022 07:41
JointJS 3.5 resize tool for element
const ResizeTool = joint.elementTools.Control.extend({
getPosition: function(view) {
const model = view.model;
if(model.attr('root/originalSize') === void 0) {
model.attr('root/originalSize', model.attributes.size);
return {x: model.attributes.size.width, y: model.attributes.size.height};
setPosition: function(view, coordinates) {
view.model.resize(coordinates.x, coordinates.y);
stijn1989 /
Created October 14, 2021 15:55
some fun with functions
import java.util.function.BiFunction;
public class Mqtt
public double calculate(BiFunction<Double, Double, Double> calc, double a, double b)
return calc.apply(a, b);
stijn1989 / Bestelling.php
Created January 10, 2021 08:55
haha wtf ik was dronken zeker... :D
$versie = $detail->getArtikel()->getHuidigReceptVersie();
$detail->recept = \ArtikelInfo::findByArtikelAndReceptVersie($order->klant, $detail->artikel, $versie)->recept_versie;
public function toArray($columns = null): array
$array = parent::toArray($columns);
//wat een shit hack man man toch
$array['klant_silo'] = $this->klant_silo;
$array['klant_silo_original'] = $this->klant_silo_original;
return $array;
stijn1989 / CombinedForm.php
Created October 28, 2020 10:32
why i love PHP :D
public function getOriginalEntity(string $entity_class_name) : ?Model
if(array_key_exists($entity_class_name, $this->entities)) {
$entity = $this->entities[ $entity_class_name ];
//copy properties from stdEntity to this entity
$stdEntity = $this->getEntity();
foreach($this->entityProperties[ $entity_class_name ] as $property) {
$entity->{$property} = $stdEntity->{$property};