Skip to content

Instantly share code, notes, and snippets.

View josdejong's full-sized avatar

Jos de Jong josdejong

View GitHub Profile
@josdejong
josdejong / npm.js
Last active March 14, 2024 22:28
Helper function to load ESM packages from NPM in your browser dev tools console
/**
* Load an ESM package from npm in your JavaScript environment.
*
* Loads packages from https://www.npmjs.com/ via the CDN https://www.jsdelivr.com/
*
* Usage:
*
* const lodash = await npm('lodash-es')
* const lodash = await npm('lodash-es@4')
* const lodash = await npm('lodash-es@4.17.21')
@josdejong
josdejong / merge.kt
Last active October 24, 2023 09:30
Merge two data classes in Kotlin
import kotlin.reflect.full.declaredMemberProperties
import kotlin.reflect.full.primaryConstructor
/**
* Merge two data classes
*
* The resulting data class will contain:
* - all fields of `other` which are non null
* - the fields of `this` for the fields which are null in `other`
*
@josdejong
josdejong / package.json
Last active August 29, 2015 14:22
Test ES7 async/await
{
"name": "es7_async",
"version": "0.0.1",
"description": "",
"license": "ISC",
"dependencies": {
"asyncawait": "^0.7.4",
"babel-core": "^5.4.4",
"babel-plugin-typecheck": "0.0.3"
}
@josdejong
josdejong / gist:4537647
Last active September 27, 2022 22:55
String interpolation method for underscore.js.
/*
String interpolation method for underscore.js
Usage:
var props = {
first: 'Jos',
last: 'de Jong'
};
var message = _.interpolate('Hello $first $last, welcome!', props);