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 byteMask = 0xff_ff; | |
function AddFloat16(a: number, b: number): number { | |
a = a & byteMask; | |
b = b & byteMask; | |
const signA = a >> 15; | |
const signB = b >> 15; | |
let expA = (a >> 10) & 0b11111; | |
let expB = (b >> 10) & 0b11111; | |
let mantA = a & 0b1111111111; |
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 interface TimeSpanProps { | |
ms?: number; | |
seconds?: number; | |
minutes?: number; | |
hours?: number; | |
days?: number; | |
} | |
export class TimeSpan { | |
private readonly _ms: number; |
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
type ValueOfNumber = { valueOf(): number }; | |
abstract class Int<T extends new (value: ValueOfNumber) => InstanceType<T>> { | |
public abstract get value(): number; | |
public abstract set value(val: ValueOfNumber); | |
public abstract valueOf(): number; | |
private Construct: T; | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
public constructor(_: ValueOfNumber) { |
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 std = @import("std"); | |
const gpa = std.heap.page_allocator; | |
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
pub fn main() !void { | |
const text = "AAA"; | |
var base64Length = (text.len / 3) * 4; | |
if ((text.len % 3) > 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
export function SelfPromiseFunc<Params extends Array<unknown>, ReturnType>( | |
func: (this: Promise<ReturnType>, ...params: Params) => ReturnType, | |
) { | |
return (...p: Params) => { | |
let resolve: (v: ReturnType) => void; | |
let reject: (v: unknown) => void; | |
const promise = new Promise<ReturnType>((rsv, rjc) => { | |
resolve = rsv; | |
reject = rjc; |
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
fn modadd(a: u64, b: u64, module: u64) -> u64{ | |
if a >= module{ | |
return a%module; | |
}else if b >= module{ | |
return b%module; | |
} | |
if a > module - b{ | |
return a - (module - b); | |
}else if b > module - a { | |
return b - (module - a); |
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 type Func<P extends Array<unknown>, R> = (...args: P) => R; | |
interface JSTypes{ | |
string: string | |
number: number | |
bigint: bigint | |
boolean: boolean | |
symbol: symbol | |
undefined: undefined | |
object: object |
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
<?php | |
namespace App\Http\Middleware; | |
use Illuminate\Http\Request; | |
use Inertia\Middleware; | |
class HandleInertiaRequests extends Middleware | |
{ | |
/** |
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 fs from "fs"; | |
/** | |
* @param {Array<T>} arr | |
* @param {number} index | |
* @returns {Array<T>} | |
* @template T | |
*/ | |
function RemoveIndexOfArray(arr, index){ | |
const copyOfArray = [... arr]; |
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
<?php | |
/** | |
* @property-read int $length | |
*/ | |
class BetterStr{ | |
protected string $value = ""; | |
public function get_value(){ | |
return $this->value; | |
} |