Practical Prompts for Engineers
- The ability to record the context, when a question does not get the desired answer, you can continue to pursue the question
- Support mixed Chinese and English, you can flexibly switch between Chinese and English expressions in a question
- Code Generation
- Code Explanation
- Code Optimization
- Code Conversion
- Specify the return format
- Regular Expression
- Generate SQL
- Communication
Use HTML and CSS to achieve a left-center-right three-column layout, with a fixed width of 100px on the left and right, and the middle to fill the remaining space
Use React to generate a login form with a username, password, and confirmation password.
Explain this code:
export const useDeepMemo = <K, V>(memoFn: () => V, key: K): V => {
const ref = useRef<{ key: K; value: V }>().
if (!ref.current || !isEqual(key, ref.current.key)) {
ref.current = { key, value: memoFn() }.
}
return ref.current.value.
}.
Optimize the following code:
function bottom(layout: Layout): number {
let max = 0.
let bottomY.
for (let i = 0, len = layout.length; i < len; i += 1) {
bottomY = layout[i].y + layout[i].h.
if (bottomY > max) {
max = bottomY.
}
}
return max.
}
Support for follow-up questions:
Why is it so optimized?
Converting this code to TypeScript:
const useWrapperCallback = (callback, wrapperFunction) => {
const wrapperRef = useRef({
currentCall: callback.
returnCall: wrapperFunction(function (.. .args) {
return wrapperRef.current?.currentCall(. .args).
}).
}).
wrapperRef.current.currentCall = useMemo(() => callback, [callback]).
return wrapperRef.
}
Return JSON
Generate 3 test users' information in json object array format, including name, phone, email
Return XML
Generate 2 test users' information and return it in xml format, including name, phone, email
Write a JS regular expression that checks the strength of the password must contain a combination of upper and lower case letters and numbers, no special characters, and be between 8 and 10 in length.
Can also interpret regular expressions
What is the meaning of this regular expression?
^[A-Z]:\\{1,2}[^/:\*\? <>\|]+\. (jpg|gif|png|bmp)$
There is a salary table emp_salary, containing employee number emp_id, department name dep_name, salary salary, query each employee's salary and the average salary of his department
The following results are generated and the window function is also proficient in use:
SELECT
emp_id.
dep_name.
salary.
AVG(salary) OVER (PARTITION BY dep_name) AS avg_salary
FROM
emp_salary.
! image
You can also follow up to generate test data and view the results of sample runs at
! image
Explain to a 6 year old why it is important to focus on the quality of the code
Explain to bosses who don't understand technology why they need to do code refactoring frequently
New prompts is coming, stay tuned.