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
/** | |
* Requires a billion row weather dataset from https://github.com/gunnarmorling/1brc/blob/main/data/weather_stations.csv | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <math.h> |
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
<template> | |
<div style="display: fixed; top: 8px; left: 8px"> | |
<input type="text" onchange="updateTextField()" id="floating-input" /> | |
</div> | |
</template> |
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
static FdoDecimal divideFast(FdoDecimal dividend, FdoDecimal divisor) { | |
final result = dividend.amount.toDouble() / divisor.amount.toDouble(); | |
final resultStr = result.abs().toString(); | |
final decimalPointAt = resultStr.indexOf('.'); | |
final newPrecision = (dividend.precision - divisor.precision).toInt(); | |
// it divides evenly | |
if (decimalPointAt == -1 || resultStr.endsWith('.0')) { | |
var precisionToAdd = newPrecision < 0 ? newPrecision.abs() : 0; | |
var newRefinedPrecision = newPrecision + precisionToAdd; |
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
#include <stdlib.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <time.h> | |
#define CHUNKSIZE 4 | |
#define CHUNKSIZE_DOUBLE 8 | |
#define BITSIZE 32 | |
#define b_uint uint32_t | |
#define r_uint uint64_t |
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
import assert from 'assert/strict'; | |
function isDeepEqual<T>(a: unknown, b: T): a is T { | |
// return true; | |
try { | |
assert.deepStrictEqual(a, b); | |
return true; | |
} catch (error: any) { | |
if (error.name == 'AssertionError') { | |
return false; |
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
async function pollForInspector(): Promise<boolean> { | |
try { | |
const inspector = await import('node:inspector'); | |
const startedAt = performance.now(); | |
let lastPolledAt: number; | |
do { | |
lastPolledAt = performance.now(); | |
const inspectorUrl = inspector.url(); | |
if (inspectorUrl) { |
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
extension on JSAny { | |
dartify2() { | |
if (this is JSArray) { | |
final asJsArray = this as JSArray; | |
final length = asJsArray["length"]!.dartify() as int; | |
final result = List.filled(length, null as Object?); | |
for (var i = 0; i < length; i++) { | |
final value = asJsArray["$i"]; | |
result[i] = value?.dartify2(); |
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
import { z } from "zod"; | |
import { FdoInventoryUnit } from "../../src"; | |
function isOptional(schema: any): schema is z.ZodOptional<any> { | |
return schema._def.typeName === z.ZodFirstPartyTypeKind.ZodOptional; | |
} | |
function isNullable(schema: any): schema is z.ZodNullable<any> { | |
return schema._def.typeName === z.ZodFirstPartyTypeKind.ZodNullable; | |
} |
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
/** | |
* Dependency: | |
* pnpm i node-html-parser | |
*/ | |
import { readdirSync, readFileSync, statSync } from 'node:fs' | |
import path from 'node:path' | |
import { HTMLElement, Node, NodeType, parse, TextNode } from 'node-html-parser' | |
const lightGray = '\x1b[90m%s\x1b[0m' |
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
brew install parallel | |
ls *.mp4 | parallel ffmpeg -i {} -vcodec libx264 -crf 20 compressed/{} |
NewerOlder