This project uses AWS's DynamoDB as its database, utilizing single table design.
DynamoDB was chosen primarily to keep prices down, as it offers pay per request billing rather than paying to keep a database running 24/7.
// UTILS | |
export const getPaddingFromPrecision = ( | |
floatingPointPrecision: number, | |
): number => { | |
return Math.ceil(Math.log2(360 * floatingPointPrecision)); | |
}; | |
export const convertToBinary = ( | |
num: number, |
This project uses AWS's DynamoDB as its database, utilizing single table design.
DynamoDB was chosen primarily to keep prices down, as it offers pay per request billing rather than paying to keep a database running 24/7.
const props = { | |
text: 'hello', | |
boolean: true, | |
array: ['hi', 'there', true], | |
object: { | |
cool: true, | |
nice: 'awesome' | |
}, | |
func: () => {}, |
// Used to match HTML entities and HTML characters. | |
const unescapedHtml = /[&<>"']/g | |
const hasUnescapedHtml = RegExp(unescapedHtml.source) | |
const htmlEscapes = { | |
"&": "&", | |
"<": "<", | |
">": ">", | |
'"': """, | |
"'": "'" | |
} |
const { inspect } = require('util') | |
/* Log out everything in the deep array/object */ | |
function deepLog(obj) { | |
console.log(inspect(obj, {showHidden: false, depth: null, colors: true})) | |
} | |
function myScript(input) { | |
/* Lots of crap */ | |
/* And lots more crap */ |
const fs = require('fs') | |
const path = require('path') | |
const cacheManager = require('cache-manager') | |
const fsStoreHash = require('cache-manager-fs-hash') | |
const CACHE_KEY = 'foo' | |
const STORAGE_PATH = (process.env.IS_OFFLINE) ? path.join(__dirname, '../tmp') : '/tmp' | |
const SECONDS = 60 | |
const MINUTES = 60 | |
const ONE_HOUR = SECONDS * MINUTES | |
const mbOfStorage = 512 |
#! /usr/bin/env node | |
// via https://github.com/sure-thing/mdpr/blob/main/index.js | |
import fs from 'fs' | |
import path from 'path' | |
import http from 'http' | |
import getPort from 'get-port' | |
import { micromark } from 'micromark' | |
import { gfm, gfmHtml } from 'micromark-extension-gfm' | |
import pocket from 'pocket.io' |
// via https://stackoverflow.com/questions/8750127/regex-for-parsing-single-key-values-out-of-json-in-javascript | |
const obj1 = { | |
id: 1, | |
'name.1': '123', | |
address: { | |
'address.1': 'Chicken Dinner Road, 69', | |
'address.2': 'Psycho lane, 666', | |
}, | |
'age.1': { | |
'thisIsSomeCrazyJson.3': 10, |
// https://github.com/SiddharthShyniben/typosquatter | |
const peq = new Uint32Array(0x10000); | |
const myers_32 = (a, b) => { | |
const n = a.length; | |
const m = b.length; | |
const lst = 1 << (n - 1); | |
let pv = -1; | |
let mv = 0; | |
let sc = n; | |
let i = m; |
// via https://twitter.com/judicael_andria/status/1501643071494180868 | |
/* usage | |
createStore({ | |
context: { | |
initialize state here | |
}, | |
actions: { | |
add: (context, event) => {} | |
} |