Skip to content

Instantly share code, notes, and snippets.

View zazaulola's full-sized avatar
馃彔
Working from home

zazaulola

馃彔
Working from home
View GitHub Profile
/** @format */
/**
* 肖褍薪泻褑懈褟 芯褌褔懈褖邪械褌 JPEG-泻邪褉褌懈薪泻褍 芯褌 屑械褌邪写邪薪薪褘褏
*
* @param {ArrayBuffer} buf 斜褍褎械褉 褋 懈蟹芯斜褉邪卸械薪懈械屑
* @returns {Blob|null}
*/
function clearJpegMetadata(buf) {
if (!(buf instanceof ArrayBuffer)) {
function createWorker(callable) {
const code = `onmessage=${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;
}
@zazaulola
zazaulola / crypto-captcha.js
Last active August 4, 2022 14:56
PoW captcha for Node. All code is static - no sessions needed, no cookies needed, no database needed.
/** @format */
/**
*
* The principle of the algorithm is very simple.
*
* The module exports three functions:
*
* getTask()
* The first function does not need any arguments.
function cp1251ToUtf8(buf){
if(buf instanceof ArrayBuffer) buf = new Uint8Array(buf);
if(!Array.isArray(buf)) buf = [...buf];
const map = new Map([
[128,1026], [129,1027], [130,8218], [131,1107],
[132,8222], [133,8230], [134,8224], [135,8225],
[136,8364], [137,8240], [138,1033], [139,8249],
[140,1034], [141,1036], [142,1035], [143,1039],
[144,1106], [145,8216], [146,8217], [147,8220],
function koi8rToUtf8 ( buf ) {
if( buf instanceof ArrayBuffer ) {
buf = new Uint8Array ( buf );
}
if( ! Array.isArray ( buf ) ) {
buf = [ ... buf ];
}
const map = new Map ( [
[0x80,0x2500], [0x81,0x2502], [0x82,0x250C], [0x83,0x2510],
[0x84,0x2514], [0x85,0x2518], [0x86,0x251C], [0x87,0x2524],
function detab(str) {
return str.replaceAll(/^\s*|\s*$|(?<=(?:\n(\s*).*?)+)\1/g, "");
}
// Test
let query = `
SELECT
'table'.*
FROM
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);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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);
#!/bin/bash
# __ __
# ____ ____ _________ ____ ___ ____ / /_ _____/ /_
# /_ / / __ \/ ___/ __ \/ __ `__ \/ __ \/ __/ / ___/ __ \
# / /_/ /_/ / / / /_/ / / / / / / /_/ / /__ (__ ) / / /
# /___/ .___/_/ \____/_/ /_/ /_/ .___/\__(_)____/_/ /_/
# /_/ /_/
PS1='\u@\h \W\$ '