Skip to content

Instantly share code, notes, and snippets.

View tanishqmanuja's full-sized avatar
😇
Having fun with Tech

Tanishq Manuja tanishqmanuja

😇
Having fun with Tech
View GitHub Profile
@tanishqmanuja
tanishqmanuja / README.md
Created September 8, 2024 14:34
PGLite with angular 17+

1) Error 1 - Prebundling

1

Solution:
disable prebundling all together for dev server

"serve": {
 "builder": "@angular-devkit/build-angular:dev-server",
import { AsyncPipe } from "@angular/common";
import { Component } from "@angular/core";
import { takeUntilDestroyed, toObservable } from "@angular/core/rxjs-interop";
import { injectNetwork } from "ngxtension/inject-network";
import {
distinctUntilChanged,
map,
skipWhile,
startWith,
switchMap,
@tanishqmanuja
tanishqmanuja / index.ts
Created May 22, 2024 09:05
Bun Github Repos Cli
import { $ } from "bun";
import { parseArgs } from "util";
const { values, positionals } = parseArgs({
args: Bun.argv,
options: {
user: {
short: "u",
type: "string",
},
@tanishqmanuja
tanishqmanuja / load.ts
Created April 20, 2024 15:14
Load ENV file bun style.
import * as dotenv from "dotenv";
export const DEFAULT_ENV_FILE_MAP = {
production: ".env.production",
development: ".env.development",
test: ".env.test",
};
type Config = Record<string, string | false | undefined>;
type ConfigFn = (defaultFilemap: Config) => Config;
@tanishqmanuja
tanishqmanuja / scrypt.ts
Last active October 21, 2023 19:38
Typescript scrypt password hashing
import { randomBytes, scrypt, timingSafeEqual } from "crypto";
/*
#Wikipedia:
Scrypt: https://en.wikipedia.org/wiki/Scrypt
PBKDF2: https://en.wikipedia.org/wiki/PBKDF2
*/
const SALT_LENGTH_BYTES = 32;
const HASH_LENGTH_BYTES = 64;
@tanishqmanuja
tanishqmanuja / result.ts
Last active August 28, 2023 12:21
Typescript Result Wrapper
import { isNativeError } from "util/types";
/* Type Definitions */
export type ResultOk<T> = {
ok: true;
value: T;
};
export type ResultError<E extends Error = Error> = {
ok: false;
error: E;