Skip to content

Instantly share code, notes, and snippets.

View SagnikPradhan's full-sized avatar
πŸ’•
Hope you have a lovely day!

Sagnik Pradhan SagnikPradhan

πŸ’•
Hope you have a lovely day!
View GitHub Profile
@SagnikPradhan
SagnikPradhan / Request.ts
Last active April 3, 2020 08:53
Request Function in Typescript for a Discord API Wrapper
import https from 'https';
import {validErrors, AppError} from '../../Error-Management';
// All errors originating here are of the same type
const errName = validErrors['DISCORD_CLIENT_INTERNAL'];
// Better object
type ValidObjectValues = string|number|boolean|string[]|number[]|boolean[];
type BetterObject<T> = {[index: string]: T|BetterObject<T>};
// Request Options
@SagnikPradhan
SagnikPradhan / index.ts
Created April 12, 2020 05:36
Using EventEmitter3 with Typescript
import {EventEmitter} from 'eventemitter3';
interface EventsMap {
// EventName: Params[]
hello: [string];
}
class MyClass extends EventEmitter {
constructor() {
super();
@SagnikPradhan
SagnikPradhan / index.ts
Created April 16, 2020 06:51
Using React as a template engine for Express
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import path from 'path';
import express from 'express'
// Render Function
function renderFn(
filePath: string,
options: object,
callback: (err: Error | null, renderedStr: string) => void,
@SagnikPradhan
SagnikPradhan / status.md
Last active June 16, 2020 15:06
COVID-19 Updates

β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘

β–“ Recovered: 3856687 β–‘ Confirmed: 8134503 And STAY THE FUCK HOME ❀️

@SagnikPradhan
SagnikPradhan / Error
Last active June 1, 2020 06:13
Error while doing trying to install https://github.com/uNetworking/uWebSockets.js with yarn 2
Ξ» yarn add uWebSockets.js@uNetworking/uWebSockets.js#binaries
➀ YN0000: β”Œ Resolution step
➀ YN0013: β”‚ uWebSockets.js@https://github.com/uNetworking/uWebSockets.js.git#commit=1da391f32d5d20a34265c73a029e1e5950c8d45f can't be found in the cache and will be fetched from GitHub
j [HTTPError]: Response code 404 (Not Found)
at i.<anonymous> (D:\Sagnik\Projects\d-zone\.yarn\releases\yarn-2.0.0-rc.33.js:10:403654)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
code: undefined,
timings: undefined
}
➀ YN0013: β”‚ uWebSockets.js@uNetworking/uWebSockets.js#commit=1da391f32d5d20a34265c73a029e1e5950c8d45f can't be found in the cache and will be fetched from the remote repository
@SagnikPradhan
SagnikPradhan / Svelte Config Error
Last active March 21, 2021 13:19
Svelte and Yarn 2 Errors
Initialize language server at d:/Sagnik/Projects/svelte-app
Initialize new ts service at
Trying to load config for d:/Sagnik/Projects/svelte-app/src/App.svelte
Error while loading config
Error: Cannot find module 'svelte-preprocess'
Require stack:
- d:\Sagnik\Projects\svelte-app\svelte.config.js
- c:\Users\A\.vscode\extensions\svelte.svelte-vscode-99.0.32\node_modules\cosmiconfig\dist\loaders.js
- c:\Users\A\.vscode\extensions\svelte.svelte-vscode-99.0.32\node_modules\cosmiconfig\dist\ExplorerBase.js
- c:\Users\A\.vscode\extensions\svelte.svelte-vscode-99.0.32\node_modules\cosmiconfig\dist\Explorer.js
@SagnikPradhan
SagnikPradhan / status.txt
Last active June 17, 2020 09:55
COVID 19 Update
πŸ€’ Confirmed 8.3 M β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘
πŸ˜„ Recovered 4.0 M β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’
😡 Deaths 0.5 M β–“β–“
@SagnikPradhan
SagnikPradhan / LICENSE
Last active June 25, 2020 07:24
Another JS Router
Copyright 2020 Sagnik Pradhan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OT
@SagnikPradhan
SagnikPradhan / config.ts
Last active August 3, 2020 13:52
Simple config manager meant for typescript
import { AppError } from "error";
import yargs from "yargs-parser";
export type AllowedTypes = "string" | "number" | "boolean";
export type Template = Record<
string,
{ type: AllowedTypes; defaultValue?: StringToType<AllowedTypes> }
>;
export type StringToType<T extends AllowedTypes> = T extends "string"
@SagnikPradhan
SagnikPradhan / text-component.ts
Created November 8, 2020 06:30
Component for all text elements
import Head from "next/head";
type TextType =
| "h1"
| "h2"
| "h3"
| "caps"
| "emphasis"
| "strong-emphasis"
| "low-emphasis";