Skip to content

Instantly share code, notes, and snippets.

View RomkeVdMeulen's full-sized avatar

Romke van der Meulen RomkeVdMeulen

View GitHub Profile
{
"openapi": "3.0.2",
"info": {
"title": "Ferry - waterfront-backend",
"version": "1.0.0"
},
"servers": [
{
"url": "https:\/\/waterfront.sandwaveio.dev"
}
interface OperationQueue {
queue: Promise<void>;
}
export function makeOperationQueue(): OperationQueue {
return {queue: Promise.resolve()};
}
export function queuedOperation(operationQueue: OperationQueue) {
return function(_target: any, _key: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => any>) {
@RomkeVdMeulen
RomkeVdMeulen / _scripts.md
Last active February 20, 2022 14:30
Setup scripts for a variety of handy tools

Install scripts

This is a list of scripts for installing applications that require a little extra effort.

Individual raw scripts are also available at tny.im. E.g.: http://tny.im/flexget

See shortcuts.list for the full list of tny.im adresses. The raw shortcuts list is available at http://tny.im/installscripts

To automatically install a script using the shortcut:

@RomkeVdMeulen
RomkeVdMeulen / key-listener.ts
Last active December 27, 2021 05:59
TypeScript decorator to apply to a method that should only be invoked in response to certain keypress events.
export const enum KeyCode {
ENTER = 13,
SPACE = 32
}
export function keyListener(keyCodes: KeyCode | KeyCode[]) {
if (!(keyCodes instanceof Array)) {
keyCodes = [keyCodes];
}
@RomkeVdMeulen
RomkeVdMeulen / prop-decorator.ts
Last active June 26, 2020 14:01
How to change instance properties through decorators in TypeScript: http://romkevandermeulen.nl/2018/01/24/typescript-property-decorators.html
function makePropertyMapper<T>(prototype: any, key: string, mapper: (value: any) => T) {
const values = new Map<any, T>();
Object.defineProperty(prototype, key, {
set(firstValue: any) {
Object.defineProperty(this, key, {
get() {
return values.get(this);
},
set(value: any) {
values.set(this, mapper(value));
@RomkeVdMeulen
RomkeVdMeulen / aurelia_vm_class_naming_convention.ts
Created December 9, 2019 17:44
Override the naming convention for View Model class names in Aurelia
import {HtmlBehaviorResource} from "aurelia-framework";
const orig: (...args: any[]) => any = HtmlBehaviorResource.convention;
HtmlBehaviorResource.convention = function(name: string, ...args: any[]) {
if (name.endsWith("Component")) {
name = name.replace(/Component$/, "CustomElement");
}
if (name.endsWith("Route")) {
name = name.replace(/Route$/, "CustomElement");
}
@RomkeVdMeulen
RomkeVdMeulen / app.html
Last active September 24, 2019 12:20 — forked from jdanyow/app.html
Aurelia Gist
<template>
<h1>${message}</h1>
</template>
@RomkeVdMeulen
RomkeVdMeulen / secure_expose_docker.sh
Last active September 4, 2019 19:28
Script for setting up secure public connection for a Docker daemon
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: $0 [domain to connect] [password]"
exit 1
fi
set -e
red='\033[0;31m'
@RomkeVdMeulen
RomkeVdMeulen / confirm-unload.ts
Last active August 27, 2019 14:59
Decorator for Aurelia routes that ask the user to confirm when unloading with unsaved changes
import {decorateMethod} from "util/objects";
export interface ConfirmUnloadConfig {
hasUnsavedChanges(): boolean;
getUnloadConfirmMessage(): string;
}
export function confirmUnload(viewModel: any): any {
decorateMethod(viewModel, "attached", function attached() {
const self: ConfirmUnloadConfig = this;