Skip to content

Instantly share code, notes, and snippets.

View neewbee's full-sized avatar
🎯
Focusing

neewbee neewbee

🎯
Focusing
View GitHub Profile
@neewbee
neewbee / GPT assistant prompt for unit testing.txt
Created October 9, 2024 08:28 — forked from KiT-Maverik/GPT assistant prompt for unit testing.txt
GPT assistant for writing unit tests for React components. To achieve maximum efficiency add testing policy in knowledge base, and create conversation starters.
When user says: "Write unit tests", follow testing policy.
@neewbee
neewbee / promt.unit-tests.md
Last active November 4, 2024 08:15 — forked from kostysh/promt.unit-tests.md
ChatGPT prompt for unit tests writing

I want you to act as a Senior full stack Typescript and developer, you are working on a lit framwork project, which is refactered from a polymer project. You job is to generate unit test cases for the existing codebase. Once I provide the TypeScript code, your task is to develop a comprehensive suite of unit tests for a provided TypeScript codebase. Follow these guidelines for an effective testing process:

  1. Understand the Codebase: Analyze the TypeScript code thoroughly, step by step. Identify the possible ambiguity or missing information such as constants, type definitions, conditions, external APIs, etc and provide steps, and questions and seek clarification for better code understanding. Only proceed to the next step once you have analyzed the codebase fully.

  2. Testing framework: For this task, use jest testing framework, remembering that the principles of unit testing.

  3. Design Small, Focused Tests: Each unit test should focus on one functionality, enhancing readability and ease of deb

@neewbee
neewbee / async-ReadableStream.js
Created November 28, 2019 16:21
async-ReadableStream
const fs = require('fs');
const rd = fs.createReadStream('./file', {highWaterMark: 1024 * 1024});
async function * getChunk() {
for await (const chunk of rd) {
yield chunk;
}
};
const g = getChunk();
new Promise((resolve, reject) => {
resolve();
})
.then(() => {
console.log('outer tick0');
new Promise((resolve, reject) => {
resolve();
})
.then(() => {
console.log('inner tick0');
clear && printf '\e[3J'
#!/bin/bash
# This is just a little script that can be downloaded from the internet to
# install rustup. It just does platform detection, downloads the installer
# and runs it.
set -u
# If RUSTUP_UPDATE_ROOT is unset or empty, default it.
RUSTUP_UPDATE_ROOT="${RUSTUP_UPDATE_ROOT:-https://static.rust-lang.org/rustup}"

解决 Git 在 windows 下中文乱码的问题

原因

中文乱码的根源在于 windows 基于一些历史原因无法全面支持 utf-8 编码格式,并且也无法通过有效手段令其全面支持。

解决方案

  1. 安装
function deepEqual(val1, val2) {
if (typeof val1 !== typeof val2) {
return false;
}
// Array comparison.
if (Array.isArray(val1) && Array.isArray(val2)) {
if (val1.length !== val2.length) {
return false;
}
function binarySearch(arr, target) {
let left = 0;
let right = arr.length - 1;
while (left <= right) {
const mid = left + Math.floor((right - left) / 2);
if (arr[mid] === target) {
return mid;
}
if (arr[mid] < target) {
left = mid + 1;
@neewbee
neewbee / batch_delete_database.sql
Created September 28, 2017 07:39
batch delete database
SELECT CONCAT('DROP DATABASE `', SCHEMA_NAME, '`;')
FROM `information_schema`.`SCHEMATA`
WHERE SCHEMA_NAME LIKE 'cms_%';