Skip to content

Instantly share code, notes, and snippets.

View jishanshaikh4's full-sized avatar
🌿

Jishan Shaikh jishanshaikh4

🌿
View GitHub Profile
async function jsonFetch<T>(
url: string,
options: RequestInit = {}
): Promise<T> {
// Set the default headers correctly
const headers: HeadersInit = new Headers(options.headers);
headers.set('Accept', 'application/json');
headers.set('Content-Type', 'application/json');
return fetch(url, {
@jishanshaikh4
jishanshaikh4 / index.md
Created June 29, 2022 00:32 — forked from ericandrewlewis/index.md
C++ Pointer Tutorial

C++ Pointer Tutorial

Because pointers can be ugh

"Regular" variables (not pointers)

To understand a pointer, let's review "regular" variables first. If you're familiar with a programming language without pointers like JavaScript, this is what you think when you hear "variable".

When declaring a variable by identifier (or name), the variable is synonymous with its value.

@jishanshaikh4
jishanshaikh4 / npm-packages.md
Last active June 25, 2022 02:18 — forked from NyashaNziramasanga/npm-packages.md
Common NPM packages - Reference

Useful Node Packages

List of useful node packages

A Node Web framework

npm i express --save
@jishanshaikh4
jishanshaikh4 / promise_monad.md
Created June 19, 2022 19:37 — forked from VictorTaelin/promise_monad.md
async/await is just the do-notation of the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing

@jishanshaikh4
jishanshaikh4 / regex.md
Last active June 15, 2022 17:50 — forked from cobalt88/Regex URL.md
an example of cmmmon reget
@jishanshaikh4
jishanshaikh4 / tailwind-webpack-setup.md
Created June 15, 2022 03:50 — forked from bradtraversy/tailwind-webpack-setup.md
Setup Webpack with Tailwind CSS

Webpack & Tailwind CSS Setup

Create your package.json

npm init -y

Create your src folder

Create a folder called src and add an empty index.js file. The code that webpack compiles goes in here including any Javascript modules and the main Tailwind file.

@jishanshaikh4
jishanshaikh4 / currency-code.ts
Created June 15, 2022 03:48 — forked from g4rcez/currency-code.ts
Typing the locale and currency in NumberFormat
// https://www.currency-iso.org/dam/downloads/lists/list_one.xml
export type CurrencyCode =
| "AFN"
| "EUR"
| "ALL"
| "DZD"
| "USD"
| "EUR"
| "AOA"
| "XCD"
@jishanshaikh4
jishanshaikh4 / ConfirmDialog.tsx
Last active May 26, 2022 21:12 — forked from lucivaldo/ConfirmDialog.tsx
Provider to provide confirmation dialog functionality globally in React applications (not tested)
import { faCheck, faTimes, faWarning } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
Box,
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
Backdrop,
@jishanshaikh4
jishanshaikh4 / torhasher.py
Created May 17, 2022 07:20 — forked from james-see/torhasher.py
create a hashed password for control port setting in torrc HashedControlPassword line easily with this (python2)
import os, binascii, hashlib
#supply password
secret = 'your password here you want to use' # all you need to change!
#static 'count' value later referenced as "c"
indicator = chr(96)
#used to generate salt
rng = os.urandom
import math
from moviepy.editor import concatenate, ImageClip
import os
import platform
import subprocess
import random
import torch
# pip install pytorch-pretrained-biggan
from pytorch_pretrained_biggan import (BigGAN, truncated_noise_sample, convert_to_images)
import numpy as np