the code should be called right after we obtain the GL context. Don't forget to reset/edit ignoreCommands if you intend to capture some of those.
fakeGl.captureOperations(40)
...
fakeGl.ignoreCommands = []
import { expect } from 'chai'; | |
import { ArrayUtils } from './ArrayUtils'; | |
function sortByNumericAttribute() { | |
const arr = [ | |
{ a: 'a', n: 3 }, | |
{ a: 'b', n: 2 }, | |
{ a: 'c', n: 6 }, | |
]; | |
expect(ArrayUtils.sortByNumericAttribute(arr, 'n', false)).to.deep.eq([ |
// to capture actual responses | |
let i = 0; | |
global.fetch = jest.fn(async (url, options) => { | |
console.log(`#${i++}: ${options.method || 'GET'} ${url}`); | |
const resp = await originalFetch(url, options); | |
const body = await resp.json(); | |
console.log(` status: ${resp.status}, body: ${JSON.stringify(body, null, 2)}`); | |
return body; | |
}); |
mysql -h localhost -u USER -P 3306 -p --protocol=TCP |
function clamp(v, m, M) { | |
return v < m ? m : v > M ? M : v; | |
} | |
function average(arr) { | |
return arr.reduce((prev, curr) => prev + curr, 0) / arr.length; | |
} | |
// triangle m0 x l of area 1 (linear degradation) | |
function averageWithDegradation(arr) { |
Your GPS device has messed up and the recorded route has a faulty segment?
This code iterates over recorded points, finding biggest distance discrepancy and allowing you to remove it and save an altered XML version leaving out those measurements.
import http from 'http'; | |
import https from 'https'; | |
import fetch, { Response } from 'node-fetch'; | |
import { AbortController } from 'abort-controller'; | |
const DEFAULT_TIMEOUT = 10000; | |
const httpAgent = new http.Agent({ | |
keepAlive: true, |
const http = require('http'); | |
const https = require('https'); | |
const HEADERS = {}; | |
function get(url, body, moreHeaders) { | |
const prot = url.indexOf('https:') === 0 ? https : http; | |
return new Promise((resolve, reject) => { | |
const r = prot.request( | |
url, |