Skip to content

Instantly share code, notes, and snippets.

View MatthewCallis's full-sized avatar
🍖
Hungry Goriya

Matthew Callis MatthewCallis

🍖
Hungry Goriya
View GitHub Profile
@MatthewCallis
MatthewCallis / AI & Coding.md
Last active March 14, 2024 17:59
Using AI to help write better code

AI & Coding

Let's just ask it.

🧔🏻‍♂️ You: How can software engineers make the best use of generative AI technologies?

🤖 ChatGPT: To make the best use of generative AI technologies, software engineers can:

  1. Automate repetitive tasks: Use AI to generate code snippets, documentation, or automate testing and debugging.
  2. Enhance creativity: Leverage AI for design, brainstorming new ideas, or solving complex problems.
@MatthewCallis
MatthewCallis / test-state-setters.tsx
Created February 26, 2024 17:21
React Code Snippets
// Testing State Setters
// const [payload, setPayload] = useState({})
it('can update the number of times to loop', () => {
const mockSetPayload = vi.fn()
const mockPayload = {
timeOfLoop: 0,
amount: 0,
units: 'hours',
exitCondition: {
groups: [],
@MatthewCallis
MatthewCallis / .zprofile
Last active January 21, 2024 22:59
zsh Confugration
eval "$(/opt/homebrew/bin/brew shellenv)"
@MatthewCallis
MatthewCallis / locale_codes.coffee
Last active December 6, 2023 09:25
Country / Language / Locale Code List / Hash / Array
getLanguage: (language_code) ->
key = language_code.toLowerCase().replace(/-/, '_')
isoLangs = [
{ code:"aa", name:"Afar" },
{ code:"ab", name:"Abkhaz" },
{ code:"ae", name:"Avestan" },
{ code:"af", name:"Afrikaans" },
{ code:"ak", name:"Akan" },
{ code:"am", name:"Amharic" },
{ code:"an", name:"Aragonese" },
@MatthewCallis
MatthewCallis / flash.md
Last active December 3, 2023 22:58
Disable Flash EOL Warnings
Disable EOL uninstall warnings:
	Disable auto updates when installing
	Add "EOLUninstallDisable=1" to mmc.cfg in C:\WINDOWS\system32\Macromed\Flash
	(C:\Windows\SysWOW64\Macromed\Flash on 64-bit)

---

Defuse flash player time bomb:
@MatthewCallis
MatthewCallis / useEffectDebugger.ts
Last active August 31, 2023 20:43
useEffectDebugger See what changed in useEffect
// https://stackoverflow.com/questions/55187563/determine-which-dependency-array-variable-caused-useeffect-hook-to-fire
// https://github.com/simbathesailor/use-what-changed/tree/master
// https://dev.to/vsramalwan/ways-to-handle-deep-object-comparison-in-useeffect-hook-1elm
import { toJS } from 'mobx'
import { useEffect, useRef } from 'react'
import type { EffectCallback } from 'react'
export interface Update {
oldValue: any
@MatthewCallis
MatthewCallis / useDebounce.test.ts
Last active August 23, 2023 17:33
Debounce & useDebounce React Hook
import { renderHook } from '@testing-library/react-hooks/dom'
import useDebounce, * as allDebounce from 'hooks/useDebounce'
describe('debounce', () => {
it('calls as expected', () =>
new Promise<void>((done) => {
const callingArgument = 'debounce it!'
const debounceCallback = (value: string) => {
expect(value).toBe(callingArgument)
@MatthewCallis
MatthewCallis / jest-helpers-api.js
Last active August 16, 2023 17:03
Jest Testing Helpers for React Components with Promises
import fetch from 'isomorphic-fetch';
expost const get = async (url, headers = {}) => fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
...headers,
},
});
@MatthewCallis
MatthewCallis / Pull Request - Tips & Strategies.md
Created July 18, 2023 16:46
Pull Request - Tips & Strategies

Pull Requests

Having fellow developers check your code (and checking theirs in turn) helps eliminate mistakes, clean the codebase, and share knowledge across the team. Code review is a purely human communication process. And a good way to approach humans (especially the ones you need to work with) is with empathy. This includes the obvious: politeness, kindness, and respect. But you can go a step further and remember that when you're assigning reviewers to look through your code, you're requesting another person's time and energy. Therefore, it's nice to make the process easier for them, and doing so will probably result in a more efficient code review. So, keeping empathy in mind, let's discuss some practical tips that can make your code reviewers happier.

Before & During Coding

Branch Naming Strategy

The branch name is your first opportunity to give your task context. In case your reviewer decides to check the code out locally, they will need to find that branch among many others. Prefix the br

@MatthewCallis
MatthewCallis / playwright.config.ts
Created January 16, 2023 22:43
Playwright Config
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**