Skip to content

Instantly share code, notes, and snippets.

View dominique-mueller's full-sized avatar
🤓
Working hard or hardly working

Dominique Müller dominique-mueller

🤓
Working hard or hardly working
View GitHub Profile
@dominique-mueller
dominique-mueller / group-by.ts
Created February 15, 2024 12:13
group-by.ts
/**
* Group array by item into object
*
* Polyfill for <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy>
* Inspired by <https://stackoverflow.com/questions/14446511/most-efficient-method-to-groupby-on-an-array-of-objects#answer-64489535>
*/
export const groupBy = <T>(array: Array<T>, predicate: (value: T, index: number, array: Array<T>) => string) =>
array.reduce(
(acc, value, index, array) => {
(acc[predicate(value, index, array)] ||= []).push(value);
@dominique-mueller
dominique-mueller / sort-to-top.ts
Created February 14, 2024 11:22
sort-to-top.ts
/**
* Sort one value to the top
*/
export const sortToTop = <T>(list: Array<T>, matchFn: (item: T) => boolean): Array<T> => {
return list.toSorted((listItemA, listItemB) => {
return matchFn(listItemA) ? -1 : matchFn(listItemB) ? 0 : 1;
});
};
@dominique-mueller
dominique-mueller / nuxt-icon-component.vue
Created January 29, 2024 14:17
Nuxt Icon Component
<script lang="ts" setup>
/**
* Icon Component
*
* Inspired by <https://github.com/gitFoxCode/nuxt-icons/blob/d7e4e5b0f59c923fe97c7b9eebd5b94be0650180/src/runtime/components/nuxt-icon.vue>
*/
// Props
const props = defineProps({
name: {
@dominique-mueller
dominique-mueller / virtualbox-ubuntu-setup.md
Created August 23, 2022 13:14
VirtualBox Ubuntu Setup
{
"moduleNameMapper": {
"^d3-([a-z-]*)$": "d3-$1/dist/d3-$1",
"^lodash-es$": "lodash"
}
}
@dominique-mueller
dominique-mueller / delayAtLeast.ts
Created March 24, 2022 19:50
delayAtLeast RxJS Pipe
import { combineLatest, map, Observable, timer } from 'rxjs';
/**
* Delay at least (RxJS operator)
*
* @param delayInMs Delay in ms
*/
export const delayAtLeast = <T>(delayInMs: number) => {
return (observable: Observable<T>) => {
return combineLatest([timer(delayInMs), observable]).pipe(
@dominique-mueller
dominique-mueller / git-cheat-sheet.md
Last active September 16, 2021 09:00
Git Cheat Sheet

Revert last commit but keep changes

git reset HEAD^

Note: If alrady pushed to remote, the next push will require --force for overwriting


@dominique-mueller
dominique-mueller / package-json-exports.json5
Last active April 20, 2021 19:49
package.json fields for exports
{
// Support for native ESM (official)
// See <https://nodejs.org/api/packages.html#packages_type>
"type": "module",
// Export map (official)
// See <https://nodejs.org/api/packages.html#packages_subpath_exports>
"exports": {
".": {
@dominique-mueller
dominique-mueller / release-checklist.md
Last active April 13, 2021 14:14
Release Checklist

Release Checklist


Step 1: Version & Changelog

On the develop branch, do the following changes:

  • Increment version number
    • in the package.json file
@dominique-mueller
dominique-mueller / keepalive.ps1
Last active January 19, 2021 22:10
Are you online in Slack? With this little scripts, always. How neat.
Clear-Host
Echo "Keep alive with scroll lock..."
$WShell = New-Object -com "Wscript.Shell"
while ($true)
{
$WShell.sendkeys("{SCROLLLOCK}")
Start-Sleep -Milliseconds 100
$WShell.sendkeys("{SCROLLLOCK}")
# sleep 29 Minutes
Start-Sleep -Seconds 1740