This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Declare shortcuts and types */ | |
const fieldMap = { | |
a: { | |
name: 'address', | |
type: String | |
}, | |
s: { | |
name: 'approved', | |
type: Boolean, | |
relation: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function useLocalStorage() { | |
const get = key => localStorage.getItem(key); | |
const set = (key, value) = localStorage.setItem(key, value); | |
return [get, set]; | |
} | |
const Example = () => { | |
const [getLocalStorage, setLocalStorage] = useLocalStorage(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useCallback, useEffect, useRef, useState } from 'react' | |
// Types to be shared with frontend and backend | |
interface ApiResponseInfo { | |
code: number | |
message: string | |
[key: string]: unknown | |
} | |
interface ApiResponseCommon { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { act, renderHook } from "@testing-library/react-hooks"; | |
import { useArray } from "./useArray"; | |
describe("useArray", () => { | |
describe("props", () => { | |
it("should have initial state", () => { | |
const { result } = renderHook(() => | |
useArray({ | |
initialState: ["a", "b", "c"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InternalError extends Error {} | |
type Predicate<T> = (item: T) => boolean; | |
function single<T>(array: T[], predicate?: Predicate<T>) { | |
const items = predicate ? array.filter(predicate) : array; | |
if (items.length !== 1) { | |
throw new InternalError("Array does not contain exactly one item"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export enum TextInputTypes { | |
Raw, | |
Parameter, | |
} | |
export type Primitive = string | number | boolean; | |
export interface TextInputObject<Type extends TextInputTypes> { | |
type: Type; | |
value: Primitive; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("withRetry", () => { | |
it("should retry if when condition is true", async () => { | |
const fn = jest | |
.fn() | |
.mockImplementationOnce(() => { | |
throw new Error("Should throw"); | |
}) | |
.mockImplementationOnce(() => 1); | |
let retryCount = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
START_DATE=$(date -v -$(($(date '+%u') + 6))d '+%Y-%m-%d') | |
END_DATE=$(date -v -$(date '+%u')d '+%Y-%m-%d') | |
GIT_LOG=$(git log --since="$START_DATE" --until="$END_DATE" --pretty=format:"%h %s" --no-merges) | |
[ -z "$GIT_LOG" ] && { echo "No commits found."; exit 1; } | |
PROMPT="In less than 200 characters, summarize the following git commit history to answer the question 'What did you get done this week?'. Answer in the style of Elon Musk. The reader is in a hurry, so make sure it's easy to digest quickly. Start with 'This week'. ':\n$GIT_LOG" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"type": "object", | |
"required": ["mcpServers"], | |
"properties": { | |
"mcpServers": { | |
"type": "object", | |
"minProperties": 1, | |
"additionalProperties": { | |
"type": "object", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
goal: address PR comments | |
- get PR comments | |
```bash | |
# Find PR for current branch | |
gh pr list --head $(git branch --show-current) | cat | |
# Get inline comments (most important) | |
gh api repos/:owner/:repo/pulls/PR_NUMBER/comments --jq '.[] | {author: .user.login, body: .body, path: .path, line: .line}' | cat |