Skip to content

Instantly share code, notes, and snippets.

View OlaoluwaM's full-sized avatar
🧠
Always learning

Olaoluwa Mustapha OlaoluwaM

🧠
Always learning
View GitHub Profile
@OlaoluwaM
OlaoluwaM / grokking_to_leetcode.md
Last active May 16, 2022 09:48 — forked from tykurtz/grokking_to_leetcode.md
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

@OlaoluwaM
OlaoluwaM / kitty.conf
Created January 25, 2022 17:55 — forked from sts10/kitty.conf
My config file for Kitty Terminal Emulator
# vim:fileencoding=utf-8:ft=conf:foldmethod=marker
#: Fonts {{{
#: kitty has very powerful font management. You can configure
#: individual font faces and even specify special fonts for particular
#: characters.
font_family JetBrains Mono Medium
bold_font JetBrains Mono Bold
@OlaoluwaM
OlaoluwaM / Example.tsx
Created August 14, 2021 09:49 — forked from stolinski/Example.tsx
Route Transitions with Framer Motion
const FakeComponent = () => {
return (
<AnimatedRoutes exitBeforeEnter initial={false}>
<RouteTransition exact path="/some-route">
<NewUsers />
</RouteTransition>
<RouteTransition exact path="/yo" >
<Users />
</RouteTransition>
</AnimatedRoutes>
@OlaoluwaM
OlaoluwaM / depVersionUpdate.mjs
Last active May 12, 2021 09:09
A script that auto updates dependencies defined in your template.json file for those who have custom CRA templates
#!/usr/bin/env node
import fsPromise from 'fs/promises';
import { exec } from 'child_process';
import { promisify } from 'util';
const promisifiedExec = promisify(exec);
const normalize = str => (str === '' ? false : true);
@OlaoluwaM
OlaoluwaM / react-toastify-test-example.js
Last active October 7, 2020 23:48
React Toastify test snippet example
jest.useFakeTimers()
test('should inform user of task completion', () => {
const { getByRole } = render(<App />)
jest.advanceTimersByTime(1000); // You can vary the time depending on how long you have set the toast in question to be visible for
const toast = getByRole('alert') // Toasts generated by the library have a role of alert
expect(toast).toBeInTheDocument();
})
@OlaoluwaM
OlaoluwaM / async-test-example-with-act.js
Created October 4, 2020 23:18
Async test example with act function
test('should let user know their input was invalid or incorrect', async () => {
const {findByPlaceholderText, findByTestId} = render(<AuthComp />) // Or whatever you call you authentication component
const inputElement = await findByPlaceholderText('Age') // any query function prefixed with findBy* is asynchronous
await act(async () => {
fireEvent.input(inputElement, {target: {value: 12}})
})
const validationErrorElement = await findByTestId('validation-error');
@OlaoluwaM
OlaoluwaM / async-test-example.js
Last active October 4, 2020 23:16
async test example
test('should...', async () => {
await act(async () => {
fireEvent.input(inputElement, {target: {value: 123}})
})
})
@OlaoluwaM
OlaoluwaM / act-example.js
Last active October 4, 2020 23:14
act example snipper
test('should do.....', () => {
/*Rest of the test*/
act(() => {
// Event will cause state update and rerender in controlled input component
fireEvent.input(inputElement, {target: {value: '123'}})
// 'act' will make sure updates are applied to the DOM
})
// So our assertion work with with updated UI