Skip to content

Instantly share code, notes, and snippets.

View SwadicalRag's full-sized avatar
👨‍⚕️
working :)

swadical SwadicalRag

👨‍⚕️
working :)
View GitHub Profile
@SwadicalRag
SwadicalRag / obj2obj.js
Last active June 12, 2023 08:34
Obj2Obj for message passing between electron/node
/**
* @typedef {(EncodedValue|EncodedDate|EncodedArray|EncodedMap|EncodedSet|EncodedObject|EncodedReference)} EncodedObj
*/
/**
* @typedef {{type: "string"|"number"|"boolean"|"undefined", val: string|number|boolean|undefined}} EncodedValue
*/
/**
* @typedef {{type: "date", val: string, ref: number}} EncodedDate
@SwadicalRag
SwadicalRag / clipboard.ts
Created June 25, 2023 09:32
ffi-napi / ref-napi based typescript library to interact with the system clipboard using WinAPI
import * as ffi from "ffi-napi"
import * as ref from "ref-napi"
export enum ClipboardFormat {
TEXT = 1,
BITMAP = 2,
METAFILEPICT = 3,
SYLK = 4,
DIF = 5,
TIFF = 6,
@SwadicalRag
SwadicalRag / synctcp.ts
Last active June 29, 2023 02:39
A class for synchronous TCP using Worker threads and SharedArrayBuffer in node.js
// Node.js worker threads and networking libraries
import { Worker, isMainThread, parentPort, workerData } from "node:worker_threads";
import net from "net";
const _DEBUG = true;
function log(...args: any) {
if(_DEBUG) console.log.apply(this, args);
}
// Define the size of the shared buffer. 16MB
@SwadicalRag
SwadicalRag / augmentedplayer.user.js
Last active September 11, 2023 01:28
HTML5 player augment
// ==UserScript==
// @name Augmented HTML5 Video Player
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Adds volume boost to 400% and player speed control to 4x and changes skip forward/backward duration to 2s
// @author swadical
// @match https://*/*
// @include *
// @grant none
// @run-at document-end
@SwadicalRag
SwadicalRag / statistics.ts
Last active March 1, 2024 04:48
AUROC / AUPRC / binary classifier statistics in typescript
import * as fs from "fs";
/**
* Class representing evaluation metrics for a binary classifier system.
* This class is designed to calculate and analyze the performance of a binary classifier
* as its discrimination threshold is varied, including ROC curve analysis and Precision-Recall curve analysis.
*/
export class BinaryClassifierStatistics {
/** Sorted array of unique thresholds from the scores in descending order */
thresholds: number[] = [];