Skip to content

Instantly share code, notes, and snippets.

@mdubourg001
mdubourg001 / next.config.js
Created April 20, 2023 21:38
Next.js - Force the creation of an index.html file for every page
module.exports = {
// forcing the creation of an index.html for every page to allow
// providers serving pages without having to add .html to the url
exportPathMap: async function (defaultPathMap) {
const pathMap = {};
for (const [path, config] of Object.entries(defaultPathMap)) {
if (path === "/") {
pathMap[path] = config;
} else {
@mdubourg001
mdubourg001 / random-santa.js
Created November 25, 2021 10:46
Everybody gifts someone randomly for Christmas 🎁
const gifters = [
"Maxime",
"Joffrey",
"Quentin",
"Delphine",
"Cécile",
"Tatie Solange",
"Svetlana"
];
const gifted = [];
@mdubourg001
mdubourg001 / workers-array-multiplication.ts
Created February 25, 2020 14:19
Multiplication of huge array of number using waitable, inline workers.
/*
* Multiplication of a huge amount of numbers throught Web Workers
* The goal is:
* - to measure performance earnings
* - to implement and try 'Inline' and 'Waitable' Web Workers
*/
/* tsconfig.json
{
"target": "ESNext",
@mdubourg001
mdubourg001 / fp-utils.ts
Created February 13, 2020 13:24
Functionnal Programming Utils
// -----
// development utils
// -----
// just a formatted console.log
const log = (...args: any[]) => console.log(`=> ${args.join(' ')}`);
// logs and returns the exact given argument
const tapLog = (x: any): any => {
log(x);
@mdubourg001
mdubourg001 / io.ts
Last active February 25, 2020 14:41
Typescript IO Monad Implementation
abstract class Monad<T> {
protected value: T;
public abstract map(f: Function): Monad<T>;
public abstract flatMap(f: Function): Monad<T>;
}
type Effect<T> = () => T;
class IO<T> extends Monad<Effect<T>> {
constructor(val: Effect<T>) {
@mdubourg001
mdubourg001 / either.ts
Last active February 12, 2020 10:23
Typescript Either Monad Implementation
abstract class Monad<T> {
protected value: T;
public abstract map(f: Function): Monad<T>;
public abstract flatMap(f: Function): Monad<T>;
}
enum EitherType {
Left = "Left",
Right = "Right"
}
@mdubourg001
mdubourg001 / maybe.ts
Last active February 12, 2020 10:20
TypeScript Maybe Monad Implementation
abstract class Monad<T> {
protected value: T;
}
class Maybe<T> extends Monad<T> {
constructor(val: T | null) {
super();
this.value = val;
}
@mdubourg001
mdubourg001 / ascii_table.json
Created March 26, 2018 13:37
JSON formatted ASCII table.
{
"ascii_chars": [{
"code": 0,
"char": "NULL"
},
{
"code": 1,
"char": "SOH"
},
{
@mdubourg001
mdubourg001 / rsa.py
Created February 11, 2017 15:45
RSA implementation in python
# !usr/bin/python
# coding: utf-8
# author: mdubourg001 : https://github.com/mdubourg001
import random
import base64
import struct
import sys
from random import randrange