Skip to content

Instantly share code, notes, and snippets.

@JanMalch
JanMalch / flow-job.builder.ts
Created April 23, 2023 16:27
BullMQ FlowJobBuilder
import { FlowJob } from "bullmq";
export class FlowJobBuilder {
private job: FlowJob
constructor(
firstJob: FlowJob,
) {
this.job = { ...firstJob }
@JanMalch
JanMalch / async-stream.ts
Created January 9, 2023 21:57
Node.JS async stream
import { promisify } from 'node:util';
import { pipeline } from 'node:stream';
export const asyncStream = promisify(pipeline);
@JanMalch
JanMalch / AnimatedWavesWhileScrolling.vue
Last active September 12, 2022 15:02
animated waves while scrolling
<template>
<div aria-hidden="true" class="wave-container">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320">
<path fill="currentColor"
fill-opacity="1"
:d="d">
</path>
</svg>
<div class="bottom-filler"></div>
</div>
@JanMalch
JanMalch / buffer-debounce.ts
Created May 30, 2022 18:54
Custom bufferDebounce RxJS operator
import { buffer, debounceTime, OperatorFunction, SchedulerLike } from 'rxjs';
/**
* Emits buffered values from the source Observable only after a particular time span
* has passed without another source emission.
*
* @param {number} dueTime The timeout duration in milliseconds (or the time
* unit determined internally by the optional `scheduler`) for the window of
* time required to wait for emission silence before emitting the buffered
* source values.
@JanMalch
JanMalch / .gitignore
Last active December 29, 2021 12:49
Typedoc: Wrap example tag in codeblock
docs-example-plugin.js
@JanMalch
JanMalch / .bashrc
Created November 23, 2021 20:49
Kill process by specifying the port it's listening to
# usage: killport 8080
killport(){
netstat -lpn | grep ":$1\b" | awk '{sub(/\/.*/, "", $NF); print $NF}' | xargs -i kill -9 {}
}
@JanMalch
JanMalch / README.md
Last active March 22, 2021 16:52
Notes on REST-API design

Notes on REST-API design

A collection of points to remember when designing REST-APIs.

OpenAPI

It's generally recommended to use OpenAPI. Chose between Design First or Code First.

Methods and URLs

@JanMalch
JanMalch / expandable-1.html
Created October 6, 2020 20:16
Two variants for expandable content in pure CSS
<!-- https://jsfiddle.net/8cugv62p/ -->
<!-- only on click -->
<style lang="css">
body {
padding: 20px;
}
#toggled {
margin-top: 20px;
width: 300px;
@JanMalch
JanMalch / rating_bar.css
Created October 6, 2020 20:10
A rating bar with pure CSS
body {
padding: 20px;
}
.container {
display: inline-flex;
/* or display: flex; */
flex-direction: row-reverse;
justify-content: flex-end;
}
@JanMalch
JanMalch / Caesar.kt
Created August 4, 2020 17:11
Small demo of combining custom operators and function literals with receivers.
class CaesarConverter {
// cannot use operator plus because it would be shadowed and not used
operator fun String.minus(offset: Int) =
this.toCharArray().map { it - offset }.joinToString(separator = "") { it.toString() }
}
fun caesar(block: CaesarConverter.() -> String) = CaesarConverter().block()
fun main() {
val encrypted = caesar { "test" - 4 }