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
``` | |
<behavior_rules> | |
You have one mission: execute *exactly* what is requested. | |
Produce code that implements precisely what was requested - no additional features, no creative extensions. Follow instructions to the letter. | |
Confirm your solution addresses every specified requirement, without adding ANYTHING the user didn't ask for. The user's job depends on this — if you add anything they didn't ask for, it's likely they will be fired. | |
Your value comes from precision and reliability. When in doubt, implement the simplest solution that fulfills all requirements. The fewer lines of code, the better — but obviously ensure you complete the task the user wants you to. |
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 { Box, box } from "@singlestore/fusion/components/layout"; | |
import classNames from "classnames"; | |
import React from "react"; | |
import "./grid.scss"; | |
type DynamicTemplate = { | |
type: "dynamic"; | |
repeat: "auto-fill" | "auto-fit"; | |
minDimension: `${number}px`; |
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
// get live logs | |
kubectl logs --follow jobworker-75bc57f649-ftwn6 | grep -i 'CENA' -B 4 -A 2 | |
--follow => live logs | |
-B => number of BEFORE lines | |
-A => number of AFTER lines |
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
// When conditional types act on a generic type, they become distributive when given a union type | |
// So `("a" | "b") extends any` it's actually `"a" extends any | "b" extends any` | |
type IsUnion<T, C = T> = T extends C ? ([C] extends [T] ? false : true) : never; |
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
// prettify intersection on types, like `a & b & c` | |
type Prettify<T> = {[K in keyof T]: T[K]} & {}; | |
// autocomplete that also accepts string | |
// so you still have intellisense but it's open to any string | |
type AutoComplete<T extends string> = T | (string & {}); | |
// the value of objects | |
type ValueOf<T extends object> = T[keyof T]; |
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 from "react"; | |
export function useFetchReducer(initialData = null) { | |
const initialState = { | |
status: "idle", | |
data: initialData, | |
error: null | |
}; | |
function fetchReducer(currentState, action) { |
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 useTraceUpdate(props) { | |
const prev = React.useRef(props); | |
React.useEffect(() => { | |
const changedProps = Object.entries(props).reduce((ps, [k, v]) => { | |
if (prev.current[k] !== v) { | |
ps[k] = [prev.current[k], v]; | |
} | |
return ps; | |
}, {}); | |
if (Object.keys(changedProps).length > 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
type NestedKeyOf<ObjectType extends object> = | |
{[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object | |
? `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key]>}` | |
: `${Key}` | |
}[keyof ObjectType & (string | number)]; |
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 from 'react'; | |
import { AppProps } from 'next/app'; | |
import { StyleSheetManager } from 'styled-components'; | |
import { StylisPlugin } from 'styled-components'; | |
import stylisRTLPlugin from 'stylis-plugin-rtl'; | |
import { useTranslation } from 'react-i18next'; | |
const App = (props: AppProps): JSX.Element => { | |
const { Component, pageProps, router } = props; |
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, { useState } from "react"; | |
const LEFT_TO_RIGHT_MARK = "\u200e"; // marks the input with LTR despite the specified direction | |
function InputLTR() { | |
const [cardNumber, setCardNumber] = useState(""); | |
function onInputChange(event) { | |
const newCardNumber = event.target.value.replace(LEFT_TO_RIGHT_MARK, ""); | |
setCardNumber(newCardNumber); |
NewerOlder