Skip to content

Instantly share code, notes, and snippets.

View boukeversteegh's full-sized avatar

Bouke Versteegh boukeversteegh

View GitHub Profile
@boukeversteegh
boukeversteegh / e2e-implementation.md
Created August 11, 2023 13:39
Rethinking Boundaries: Merging End-to-End Testing and Implementation with Macro Abstractions

Rethinking Boundaries: Merging End-to-End Testing and Implementation with Macro Abstractions

In traditional software development, there's a clear boundary separating end-to-end testing and implementation. This conventional mindset, however, faces a challenge with the introduction of a unique software development paradigm proposing the unification of these two aspects.

Underpinning this concept, a Domain-Specific Language (DSL) is used. This language serves to sketch out a detailed sequence of actions and responses - acting as test specifications. Interestingly, at the same time, these sequences also provide a functional model of the system's behavior and thus can serve as an efficient implementation.

Let's dive deeper with an example. Consider you are crafting multiple test cases for a basic addition operation in a calculator application. After designing a few tests, you spot a consistent pattern of steps - you enter two numbers, add them together, and finally, you expect a result.

Here is how it would

@boukeversteegh
boukeversteegh / _example.vue
Last active February 2, 2022 23:07
Async getters for vue
<template>
<input v-model="query"/>
<ul>
<li v-for="user in users" :key="user.name">{{ user.name }}</li>
</ul>
</template>
<script lang="ts">
@Component({})
@boukeversteegh
boukeversteegh / Emails.Templates.csproj
Last active January 12, 2022 21:57
Render Razor views from a Console Application (Dotnet 6)
<!-- If you wish to keep your templates in a separate project, this is what the project file should contain, at least. -->
<!-- I'm using Dotnet 5 to be able to use the templates in Dotnet 5 and 6. -->
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5"/>
@boukeversteegh
boukeversteegh / readfiletest.dart
Last active September 23, 2020 17:52
Dart reading files (sync/async) performance test
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';
const KB = 1024;
const MB = 1024 * KB;
const GB = 1024 * MB;
const sizes = {'B': 1, 'KB': KB, 'MB': MB, 'GB': GB};
const blockSize = 16 * MB;
@boukeversteegh
boukeversteegh / enum_template.dart
Last active July 1, 2024 10:05
Dart class as enum template
void main() {
print(Number.one);
print(Number.two);
print(Number.three);
print(Number.fromInt(1));
print(Number.fromInt(2));
print(Number.fromInt(3));
print(Number.fromString('1'));
@boukeversteegh
boukeversteegh / main.dart
Last active September 23, 2020 17:57
Luck or hard work?
// run this script in your browser on:
//
// https://dartpad.dev/000ff368df58b18627652d5c6dc2cfc3
import 'dart:math';
// number of participants:
const n_participants = 18300;
// that will receive a skill between:
@boukeversteegh
boukeversteegh / sortArrays.js
Last active February 15, 2023 09:21
Sorting multiple arrays in Javascript
/**
* Sorts all arrays together with the first. Pass either a list of arrays, or a map. Any key is accepted.
* Array|Object arrays [sortableArray, ...otherArrays]; {sortableArray: [], secondaryArray: [], ...}
* Function comparator(?,?) -> int optional compareFunction, compatible with Array.sort(compareFunction)
*/
function sortArrays(arrays, comparator = (a, b) => (a < b) ? -1 : (a > b) ? 1 : 0) {
let arrayKeys = Object.keys(arrays);
let sortableArray = Object.values(arrays)[0];
let indexes = Object.keys(sortableArray);
let sortedIndexes = indexes.sort((a, b) => comparator(sortableArray[a], sortableArray[b]));
@boukeversteegh
boukeversteegh / BaseModel.php
Last active April 21, 2017 13:45
Sorting Laravel model by relationship count (see comments for usage)
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Class BaseModel
Constanten gebruiken voor ENUM waardes
<?php
class Ticket {
/**
* @ORM\Column(type="string", nullable=false, options={"default":"available"}, columnDefinition="enum('available','assigned','blocked','cancelled')")
*/
public $status = 'available';
}
$ticket = new Ticket();
@boukeversteegh
boukeversteegh / move_file_sessions_to_database.php
Created October 7, 2015 16:36
Migration to switch from file sessions to database sessions
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Session\FileSessionHandler;
use Illuminate\Session\DatabaseSessionHandler;
use Symfony\Component\Finder\Finder;
/**
* @author Bouke Versteegh
*/