This file contains hidden or 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
onmessage = ({ data: { data, width, height } }) => { | |
const add = (d, i, v) => { | |
if (i >= d.length) return; | |
d[i] += v; | |
}; | |
const w = width * 4; | |
let i = 0; | |
for (let y = 0; y < height; y++) { | |
for (let x = 0; x < width; x++, i += 4) { |
This file contains hidden or 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
onmessage = ({ data: { data, width, height } }) => { | |
const thresholdMap = [ | |
[15, 135, 45, 165], | |
[195, 75, 225, 105], | |
[60, 180, 30, 150], | |
[240, 120, 210, 90], | |
]; | |
let min = 255, | |
max = 0, |
This file contains hidden or 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
onmessage = ({ data: { data, width, height } }) => { | |
const add = (d, i, v) => { | |
if (i >= d.length) return; | |
d[i] += v; | |
}; | |
let i = 0, | |
w = width * 4; | |
for (let y = 0; y < height; y++) { | |
for (let x = 0; x < width; x++, i += 4) { |
This file contains hidden or 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 s2l = c => (c > 0.04045 ? ((c + 0.055) / 1.055) ** 2.4 : c / 12.92); | |
const l2s = c => (c > 0.0031308 ? 1.055 * Math.pow(c, 1 / 2.4) - 0.055 : 12.92 * c); | |
const LINEAR = new Array(256).fill().map((_, i) => s2l(i / 255)); | |
onmessage = ({ data: { srcData, srcWidth, srcHeight, dstWidth, dstHeight } }) => { | |
const { ceil, floor, abs, min, hypot } = Math; | |
const ratioH = srcHeight / dstHeight; | |
const ratioW = srcWidth / dstWidth; | |
const halfRatioW = ceil(ratioW / 2); | |
const halfRatioH = ceil(ratioH / 2); |
This file contains hidden or 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
export function createWorker(callable) { | |
const code = `(${callable.toString()})()`; | |
const blob = new Blob([code], { type: 'text/javascript' }); | |
const url = URL.createObjectURL(blob); | |
const worker = new Worker(url); | |
URL.revokeObjectURL(url); | |
return worker; | |
} | |
export function executeWorker(callable, data) { |
This file contains hidden or 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
#!/bin/bash | |
# __ __ | |
# ____ ____ _________ ____ ___ ____ / /_ _____/ /_ | |
# /_ / / __ \/ ___/ __ \/ __ `__ \/ __ \/ __/ / ___/ __ \ | |
# / /_/ /_/ / / / /_/ / / / / / / /_/ / /__ (__ ) / / / | |
# /___/ .___/_/ \____/_/ /_/ /_/ .___/\__(_)____/_/ /_/ | |
# /_/ /_/ | |
PS1='\u@\h \W\$ ' |
This file contains hidden or 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
Object.defineProperties(EventTarget.prototype, { | |
on: { value: EventTarget.prototype.addEventListener }, | |
off: { value: EventTarget.prototype.removeEventListener }, | |
emit: { | |
value: function (eventType, eventData) { | |
let event = new Event(eventType); | |
if (eventData) { | |
Object.assign(event, eventData, { details: eventData }); | |
} | |
this.dispatchEvent(event); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
function geodistance(lat1,lon1,lat2,lon2){ | |
const R = 6371e3; // in metres | |
const 蠁1 = lat1 * Math.PI/180; // 蠁, 位 in radians | |
const 蠁2 = lat2 * Math.PI/180; | |
const 螖蠁 = (lat2-lat1) * Math.PI/180; | |
const 螖位 = (lon2-lon1) * Math.PI/180; | |
const a = Math.sin(螖蠁/2) * Math.sin(螖蠁/2) + | |
Math.cos(蠁1) * Math.cos(蠁2) * | |
Math.sin(螖位/2) * Math.sin(螖位/2); |
This file contains hidden or 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
function detab(str) { | |
return str.replaceAll(/^\s*|\s*$|(?<=(?:\n(\s*).*?)+)\1/g, ""); | |
} | |
// Test | |
let query = ` | |
SELECT | |
'table'.* | |
FROM |