Skip to content

Instantly share code, notes, and snippets.

View manavm1990's full-sized avatar
🏠
Working from home

Manav Misra manavm1990

🏠
Working from home
View GitHub Profile
@manavm1990
manavm1990 / spinner.html
Created October 8, 2022 19:03
Tailwind Spinner
<main className="flex h-screen items-center justify-center">
<div className="border-gray mr-3 h-48 w-48 animate-spin rounded-full border-4 border-t-4 border-t-blue-300" />
</main>
const WINNING_INDICES = [
[0, 1, 2],
[0, 3, 6],
[0, 4, 8],
[1, 4, 7],
[2, 5, 8],
[2, 4, 6],
[3, 4, 5],
[6, 7, 8],
];
import { render, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import App from "./App";
import renderer from "react-test-renderer";
const setup = () => {
render(<App />);
return screen.getByRole("table");
};
@manavm1990
manavm1990 / UserContext.jsx
Last active May 9, 2022 13:38
Memoized UserContext
import PropTypes from "prop-types";
import React from "react";
export const UserContext = React.createContext();
export default function UserContextProvider({ children }) {
const [currentUser, setCurrentUser] = React.useState(
JSON.parse(localStorage.getItem("user"))
);
@manavm1990
manavm1990 / Validation.cs
Last active April 5, 2022 20:26
Demo methods to share with student for validating stuff from Console
static class ConsoleIo
{
internal static string PromptRequired(string message)
{
var res = PromptUser(message);
while (string.IsNullOrEmpty(res))
{
View.DisplayHeader("Input required❗");
res = PromptUser(message);
}
@manavm1990
manavm1990 / github-proxy-client.js
Created March 11, 2022 16:01 — forked from DavidWells/github-proxy-client.js
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
async function getRepo() {
@manavm1990
manavm1990 / reversed.cs
Created February 15, 2022 12:43
Reverse Sentence
string pangram = "The quick brown fox jumps over the lazy dog";
string[] words = pangram.Split(' ');
foreach (string word in words)
{
char[] chars = word.ToCharArray();
Array.Reverse(chars);
string wordReversed = new string(chars);
Console.Write($"{wordReversed} ");
}
@manavm1990
manavm1990 / curry.js
Created December 6, 2021 11:00
Curry 🇮🇳 Fxn
const curry =
(fn) =>
// Rest into an array
(...args) =>
// If we have enough arguments, call the function
args.length >= fn.length
? // Spread array into arguments
fn(...args)
: curry(
/**
@manavm1990
manavm1990 / index.js
Created December 5, 2021 14:34
Fxn. I Wrote To Sort Through 🏦 Transactions Data
const results = JSON.parse(data)
.map(
({
"Transaction date": date,
Description: description,
Amount: amount,
}) => ({
date,
description,
amount,
@manavm1990
manavm1990 / buidPipeline.js
Created November 25, 2021 14:33
As seen in the 📖 Composing Software by Eric Elliott
const buildPipeline =
(...fns) =>
(x) =>
fns.reduce((accV, fxn) => fxn(accV), x);