This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Group tasks into batches, apply a series of asynchronous transformations and gather results | |
const chunkSize = 3; | |
const inputs = "abcdefghijklmnopqrstuvwxyz".split(""); | |
const chunker = n => { | |
return (acc, elem, i) => { | |
const j = Math.floor( i / n ); | |
(acc[j] = acc[j] || []).push(elem); | |
return acc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cyann Donnot, Antoine Genitrini, Yassine Herida. Unranking Combinations Lexicographically: an | |
// efficient new strategy compared with others. 2020. hal-02462764 | |
// https://hal.sorbonne-universite.fr/hal-02462764v1/preview/paper.pdf | |
const crypto = require("crypto"); | |
function randomBigInt(bitLength) { | |
const u = crypto.randomBytes(bitLength / 8); | |
return BigInt("0x" + u.toString("hex")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generic GNUMakefile | |
# Just a snippet to stop executing under other make(1) commands | |
# that won't understand these lines | |
ifneq (,) | |
This makefile requires GNU Make. | |
endif | |
PROGRAM = foo | |
C_FILES := $(wildcard *.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
import * as readline from "node:readline/promises"; | |
const { stdin: input, stdout: output } = process; | |
const rl = readline.createInterface({ input, output }); | |
const name = await rl.question("What is your name? "); | |
console.log(`Hello there, ${name}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2023-08-04T15:07:37+03:00 net.keksipurkki.demos.Application INFO Starting Application() | |
2023-08-04T15:07:37+03:00 net.keksipurkki.demos.HelloWorld INFO Deploying HelloWorld() | |
2023-08-04T15:07:37+03:00 net.keksipurkki.demos.Application INFO Deployment complete. Success = true | |
2023-08-04T15:07:44+03:00 net.keksipurkki.demos.Application INFO Handling request. Method = GET. URI = http://localhost:8080/hello-world | |
2023-08-04T15:07:44+03:00 net.keksipurkki.demos.HelloWorld INFO {"message":"Hello world!"} | |
2023-08-04T15:07:45+03:00 net.keksipurkki.demos.Application INFO Handling request. Method = GET. URI = http://localhost:8080/hello-world | |
2023-08-04T15:07:46+03:00 net.keksipurkki.demos.HelloWorld INFO {"message":"Hello world!"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.annotation.JsonCreator; | |
import com.fasterxml.jackson.annotation.JsonValue; | |
import io.vertx.core.json.Json; | |
import io.vertx.core.json.JsonArray; | |
import io.vertx.core.json.JsonObject; | |
import io.vertx.core.json.jackson.DatabindCodec; | |
import lombok.extern.slf4j.Slf4j; | |
import java.util.List; | |
import java.util.Map; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NullableEnumConverter implements ModelConverter { | |
@Override | |
public Schema<?> resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) { | |
var schema = chain.next().resolve(type, context, chain); | |
if (isNull(schema)) { | |
return schema; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from "fs"; | |
import * as assert from "assert"; | |
type DictionaryEntry<K, V> = [key: K, value: V]; | |
const DICT_INITIAL_SIZE = 8; | |
const DICT_MAX_LOAD_FACTOR = 0.75; | |
class Dictionary<V> implements Iterable<[string, V]> { | |
private _entries = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; clojure -M main.clj 3 | |
; 000 | |
; 001 | |
; 010 | |
; 011 | |
; 100 | |
; 101 | |
; 110 | |
; 111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const cartesian = (...a) => a.reduce((a, b) => a.flatMap(d => b.map(e => [d, e].flat()))); | |
const intersection = (a, b) => new Set([...a].filter((x) => b.has(x))); | |
const letters = [ | |
["n", "h", "i", "m", "w"], | |
["a", "h", "y", "i", "m"], | |
["c", "b", "x", "o", "l"], | |
["k", "o", "i", "u"], |
NewerOlder