Skip to content

Instantly share code, notes, and snippets.

View harm-smits's full-sized avatar
🖥️
while (!(succeed = try()));

Harm Smits harm-smits

🖥️
while (!(succeed = try()));
  • Optiver
  • Amsterdam
  • 04:27 (UTC +02:00)
  • LinkedIn in/harmsmits
View GitHub Profile
### Keybase proof
I hereby claim:
* I am harm-smits on github.
* I am hsmits (https://keybase.io/hsmits) on keybase.
* I have a public key whose fingerprint is 7FCC C2CB A814 1BFB 13E3 08A7 1491 6155 B7ED 5196
To claim this, I am signing this object:
@harm-smits
harm-smits / url.js
Last active October 12, 2020 12:24
Simple url function to add / remove components of a url dynamically
const URL_REGEX = /^(?:([^:\/?#]+):\/\/)?((?:([^\/?#@]*)@)?([^\/?#:]*)(?:\:(\d*))?)?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n)*))?/i
/**
* Map search parameters to an according associative array
* @param search
* @returns {{}}
*/
function mapSearchParams(search) {
let map = {}
if (typeof search === 'string') {
@harm-smits
harm-smits / BarcodeScannerProvider.vue
Created August 3, 2021 09:16
Simple Vue3 barcode scanner detector.
<template>
<slot />
</template>
<script lang="ts">
import { defineComponent } from "vue";
interface ComponentSetup {
buff: string;
isReading: boolean;
@harm-smits
harm-smits / countdown.ts
Created August 3, 2021 09:20
Very simple countdown for a plaintext countdown from a given timestamp.
let selectors = {
'days' : '.js-countdown-days',
'hours' : '.js-countdown-hours',
'minutes': '.js-countdown-minutes',
'seconds': '.js-countdown-seconds'
};
/**
* Get the time remaining till a date.
*/
@harm-smits
harm-smits / events.ts
Created August 3, 2021 09:21
Very simple context based event system.
export interface EventClient {
subscribe: CallableFunction,
subscribeOnce: CallableFunction,
publish: CallableFunction,
unsubscribe: CallableFunction,
unsubscribeAll: CallableFunction
}
interface EventSubscription {
subject: Object,