Skip to content

Instantly share code, notes, and snippets.

View adeleke5140's full-sized avatar
💭
crafting software

Kenny adeleke5140

💭
crafting software
View GitHub Profile
@adeleke5140
adeleke5140 / custom-vscode.css
Created April 19, 2024 22:44
vscode vtuber logo
.editor-group-watermark > .letterpress{
background-image: url("https://github.com/Aikoyori/ProgrammingVTuberLogos/blob/main/VSCode/VSCode.png?raw=true");
opacity: 0.9
}
@adeleke5140
adeleke5140 / index.ts
Last active December 27, 2023 22:09
Styling React Select
const MultiSelect = ({
options,
inputId,
name,
inputPlaceholder,
...rest
}: MultiSelectProps) => {
return (
<Select
{...rest}
@adeleke5140
adeleke5140 / example.jsx
Created December 7, 2023 23:49
Custom hook to get and use a container for React portals
const Notifications = () => {
const { container, ref } = useModalParent<HTMLDivElement>();
return (
<div ref={ref}>
// rest of code
<Popover.Portal container={container}>
// rest of code
</Popover/>
</div>
)
@adeleke5140
adeleke5140 / axios.ts
Last active November 8, 2023 13:30
Access and Refresh Token feature with Axios in NextJS
import axios, { CreateAxiosDefaults } from 'axios'
import { refreshToken as refreshTokenAdapter} from './session'
export const getJSONContentHeaders = () => {
"Content-Type": "application/json",
Accept: "application/json"
}
@adeleke5140
adeleke5140 / blob.ts
Created November 2, 2023 19:55
Conversion between js formats
const blob = b64toBlob(imageSrc.replace(/^data:image\/jpeg;base64,/, ""));
const file = new File([blob], "profile.jpeg", { type: "image/jpeg" });
const blobURl = URL.createObjectURL(file);
@adeleke5140
adeleke5140 / reademe.md
Last active October 31, 2023 12:49
Dependency Injection in React

Dependency Injection in ReactJS

This is a conversation on the DI pattern in ReactJS.

This article from the folks at 8th Light is great. The author explains how it makes component very easy to test. It encourages unit testing rather than integration testing.

In essence:

It also allows for substitution of a dependency with a mock, or fake, during testing.

@adeleke5140
adeleke5140 / convertImage.ts
Created October 30, 2023 13:18
An API route to convert a base64 encoded image ans save it to a jpeg file.
import { writeFileSync } from "fs";
import { join } from "path";
import { NextApiRequest, NextApiResponse } from "next";
export default async (req: NextApiRequest, res: NextApiResponse) => {
try {
if (req.method === "POST") {
const base64 = req.body.image;
const cleanBase64Data = base64.replace(/^data:image\/jpeg;base64,/, ""); // Remove the data URI prefix
const binaryData = Buffer.from(cleanBase64Data, "base64");
@adeleke5140
adeleke5140 / CustomLink.tsx
Created October 22, 2023 01:36
Navbar Links
@adeleke5140
adeleke5140 / Avatar.tsx
Created September 26, 2023 16:51
A Generic avatar component
import { classNames } from 'utils'
type Size = 'small' | 'medium' | 'large'
type AvatarProps = {
size?: Size
src?: string
alt?: string
}
@adeleke5140
adeleke5140 / index.css
Created September 2, 2023 12:59
styling the react date picker
/*
Styles for the React date picker input
*/
/* .react-datepicker-wrapper {
width: 100%;
}
.react-datepicker__input-container {