Skip to content

Instantly share code, notes, and snippets.

View char0n's full-sized avatar
GitHub Star

Vladimír Gorej char0n

GitHub Star
View GitHub Profile
openapi: 3.0.1
info:
version: "0.0.1"
title: Test Defect
description: >-
A client side JS error occurred when using the `TryItOut` feature of the SwaggerUI. It would try fail
to formatKeyValuePairs on a JSON query parameter.
paths:
/test:
get:
name: tailoredADL
title: "Automobile API"
description: "Automobile API"
version: "1.0.0"
resources:
- name: automobile
operations:
- list
- retrieve
properties:
export * from 'ramda-adjunct'
@char0n
char0n / isUinteger32.js
Created June 18, 2022 18:25
Checks whether the passed value is an unsigned 32 bit integer.
RA.isUinteger32(0); //=> true
RA.isUinteger32(2 ** 32 - 1); //=> true
RA.isUinteger32(Infinity); //=> false
RA.isUinteger32(NaN); //=> false
RA.isUinteger32(-1); //=> false
RA.isUinteger32(2 ** 32); //=> false
@char0n
char0n / sortByPaths.js
Created June 18, 2022 18:13
Sorts a list of objects by a list of paths (if first path value is equivalent, sort by second, etc).
const alice = {
name: 'Alice',
address: {
street: 31,
zipCode: 97777,
},
};
const bob = {
name: 'Bob',
address: {
@char0n
char0n / isBlank.js
Created June 18, 2022 18:11
Returns true if the given value is its type's empty value, false, undefined as well as strings containing only whitespace characters; false otherwise.
RA.isBlank(''); //=> true
RA.isBlank(' '); //=> true
RA.isBlank('\t\n'); //=> true
RA.isBlank({}); //=> true
RA.isBlank(null); //=> true
RA.isBlank(undefined); //=> true
RA.isBlank([]); //=> true
RA.isBlank(false); //=> true
RA.isBlank('value'); //=> false
RA.isBlank({ foo: 'foo' }); //=> false
// sync interface
const multiply = (a, b) => a * b;
const multiplyAsync = async (...args) => multiply(...args);
multiply[Symbol.for('nodejs.util.promisify.custom')] = multiplyAsync;
// now in node.js when consuming this
import { promisify } from 'node:util';
openapi: 3.0.0
info:
title: Upload bug in swagger ui
version: 1.0.0
servers:
- url: http://example.com
paths:
/InsertFile:
post:
requestBody:
@char0n
char0n / LICENSE
Last active February 2, 2023 00:29
Advanced memoization for JavaScript functions with lodash.memoize
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
@char0n
char0n / toNumber.js
Created January 23, 2022 09:00
Converts value to a number.
RA.toNumber(3.2); //=> 3.2
RA.toNumber(Number.MIN_VALUE); //=> 5e-324
RA.toNumber(Infinity); //=> Infinity
RA.toNumber('3.2'); //=> 3.2
RA.toNumber(Symbol('3.2')); //=> NaN