This file contains 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 { Component, Input, ElementRef, Renderer2, PLATFORM_ID } from '@angular/core'; | |
import { isPlatformServer } from '@angular/common'; | |
import { RequestResponseAdapter } from '@gethuman/adapters'; | |
import { config } from '@gethuman/config'; | |
import { GhWebState } from '@gethuman/state'; | |
@Component({ | |
selector: 'icon', | |
standalone: true, | |
template: ``, // no content for <icon></icon> since we are setting a mask-image |
This file contains 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 { signal } from "@angular/core"; | |
import type { Signal, WritableSignal } from "@angular/core"; | |
export type PromiseStatus<T> = PromiseSettledResult<T> | { status: "pending" }; | |
export interface PromiseEx<T> extends Promise<T>, Disposable, AsyncDisposable { | |
$status: Signal<PromiseStatus<T>>; | |
cancel: AbortSignal; | |
abort: AbortController["abort"]; | |
} | |
export class PromiseEx<T> extends Promise<T> implements PromiseEx<T> { |
This file contains 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
//ORIGINAL CODE BY @renatoaraujoc https://gist.github.com/renatoaraujoc/11fab34592fd81c75800aa2934faa913 | |
export class EncryptionUtil { | |
private static _textEncoder = new TextEncoder(); | |
private static _textDecoder = new TextDecoder(); | |
private static ENC_DEC_SIMPLE_CHARS = | |
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'; | |
/** | |
* Simple synchronous encryption using `XOR` algorithm, returning only allowed characters. | |
* This method is fast but offers only low security. Supports UTF-8 characters. |
This file contains 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 { type Observable } from 'rxjs'; | |
import { map } from "rxjs/operators"; | |
//GENERIC toDictionary OPERATOR + indexBy FUNCTION RETURN Map<indexOf, item> TO OTTIMIZE O(1) EXIST/RETRIVE OF ITEM BY idxOf (.has(idx)/.get(idx)) | |
export type Indexer<T extends {}> = keyof T | ((item: T) => unknown); | |
export type IndexOf<T, I extends Indexer<T>> = I extends keyof T ? T[I] : I extends (...args: any) => any ? ReturnType<I> : never; | |
export const indexBy = <T, I extends Indexer<T>>(array: T[], keyOrIndexer: I): Map<IndexOf<T, I>, T> => { | |
if (!array) return new Map<IndexOf<T, I>, T>(); | |
const idexerFn: (item: T) => IndexOf<T, I> = ( | |
typeof keyOrIndexer === "function" ? keyOrIndexer : (item: T) => item[keyOrIndexer as keyof T] |
This file contains 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
//ORIGINAL CODE BY Nevzat Topçu @nevzatopcu | |
//STACKBLIZ SAMPLE https://stackblitz.com/edit/angular-form-share-elements?file=src%2Fmain.ts | |
//READ MORE HERE: https://nevzatopcu.medium.com/angular-child-components-with-reactive-forms-fbf4563b304c | |
import { Optional, SkipSelf, Provider } from '@angular/core'; | |
import { ControlContainer } from '@angular/forms'; | |
const containerFactory = (container: ControlContainer): ControlContainer => { | |
if (!container) { | |
throw new Error('I need a FormGroup instance'); |
This file contains 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 LOGTYPES = ['log', 'info', 'warn', 'error'] as const; | |
interface LogType { | |
type: typeof LOGTYPES[number]; | |
} | |
export const log = (...args: Array<string | LogType | {}>) => { | |
let type: LogType['type'] = 'log'; | |
let prefix = [] as any[]; | |
let postfix = [] as any[]; | |
//@ts-ignore | |
const idx = args.findIndex((a) => LOGTYPES.includes(a?.type)); |
This file contains 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
//CONSOLE LOG OVEERIDE DEFINITION BY LELE 2023-08-30 | |
// declare global { | |
type NLogLevel = 'log' | 'info' | 'warn' | 'error' | 'none'; | |
interface NLogOptions { | |
NDebug?: boolean; | |
NLogLevel?: NLogLevel; | |
NShowLevel?: NLogLevel; | |
NAgent?: string; | |
NApp?: string; |
This file contains 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
//ORIGINAL CODE BY RICK STRAHL https://weblog.west-wind.com/posts/2023/Aug/15/Map-Physical-Paths-with-an-HttpContextMapPath-Extension-Method-in-ASPNET | |
public static class HttpContextExtensions | |
{ | |
static string WebRootPath { get; set; } | |
static string ContentRootPath { get; set; } | |
/// <summary> | |
/// Maps a virtual or relative path to a physical path in a Web site, | |
/// using the WebRootPath as the base path (ie. the `wwwroot` folder) | |
/// </summary> |
This file contains 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
//ORIGINAL CODE REPO: https://github.com/johannschopplich/pdfjs-serverless | |
//# pnpm | |
//pnpm add pdfjs-serverless | |
//# npm | |
//npm install pdfjs-serverless | |
import { getDocument } from 'https://esm.sh/pdfjs-serverless' | |
const data = Deno.readFileSync('./dummy.pdf') | |
const doc = await getDocument(data).promise |
This file contains 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
//READ MORE IN THIS ARTICLE https://morioh.com/a/782c0022755e/using-bcrypt-to-hash-passwords-in-nodejs EXPECIALLY PRE-REQUISITE | |
const bcrypt = require("bcrypt") | |
const saltRounds = 10 | |
const password = "Admin@123" | |
//Password encryption + explicit Salt | |
bcrypt | |
.genSalt(saltRounds) | |
.then(salt => { |
NewerOlder