Skip to content

Instantly share code, notes, and snippets.

View dancerphil's full-sized avatar
🌱
working on agents.dancerphil.com

Cong Zhang dancerphil

🌱
working on agents.dancerphil.com
View GitHub Profile
!function(){"use strict";const e=()=>{const e=document.querySelector("#pxf-trade-auction-extranet").contentDocument,t=e.createElement("style");t.innerText=".el-table__header input, .el-table__body input { display: block; width: 50px; }",e.head.appendChild(t);const n=[...e.querySelectorAll(".el-form-item")][1].querySelector(".el-form-item__content"),r=e.querySelector(".el-table__header"),l=e.querySelector(".el-table__body"),c=[...r.querySelectorAll("tr")],a=[...l.querySelectorAll("tr")],o=e=>{const t=[...e.querySelectorAll("td")],n=t[2],r=t[3],l=t[7],c=t[4].querySelector("span span"),a=l.querySelector("span span"),o=n.querySelector("input"),i=r.querySelector("input"),u=Number(o.value),s=Number(c?.innerText),d=Number(i.value),p=u>Number(a?.innerText);a&&(a.style.background=p?"yellow":"unset");const m=""!==i.value&&d<s;c&&(c.style.background=m?"yellow":"unset")},i=()=>{a.forEach(o)};a.forEach((t=>{const n=[...t.querySelectorAll("td")][2],r=e.createElement("input");r.setAttribute("class","min-input"),r.addEventLi
@dancerphil
dancerphil / elec.js
Last active December 27, 2023 14:19
const handleSetup = () => {
const iframe = document.querySelector('#pxf-trade-auction-extranet');
const iframeDocument = iframe.contentDocument;
const d = iframeDocument;
const styleElement = d.createElement('style');
styleElement.innerText = '.el-table__header input, .el-table__body input { display: block; width: 50px; }';
d.head.appendChild(styleElement);
const func = () => {
throw new Error('error')
}
const asyncFunc = async () => {
throw new Error('async error')
}
const promiseFunc = () => {
return Promise.reject(new Error('promise reject'))
import natural from 'natural';
const tfidf = new natural.TfIdf();
const NGramsZH = natural.NGramsZH;
const intention = {
'新建分支': ['新建分支'],
'查找代码库': ['代码库'],
'搜索卡片': ['卡片'],
'跳转流水线': ['跳转流水线'],
import {useEffect} from 'react';
const createEventListenerHook = <K extends keyof DocumentEventMap>(type: K) => {
type Listener = (e: DocumentEventMap[K]) => void;
const listeners = new Set<Listener>();
const handleDocumentEvent = (e: DocumentEventMap[K]) => {
listeners.forEach(listener => {
listener(e);
});
};
@dancerphil
dancerphil / browserslist-inspect.js
Last active August 20, 2021 08:47
browserslist-inspect
import browserslist from "browserslist";
import UAParser from "ua-parser-js";
import {mapValues, groupBy, uniq} from 'lodash';
const map = {
"and_chr" : 'Chrome',
"and_ff": 'Firefox',
"and_qq": 'QQ',
"and_uc": 'UCBrowser',
"android": 'Android',
const createCallback = <T>(obj: T) => {
const setValue = <K extends keyof T>(key: K, value: T[K]) => {
obj[key] = value;
}
return setValue
}
interface Obj {
num: number;
type Reducer<S, A> = (state: S, action: A) => S;
type ReducerWithoutAction<S> = (state: S) => S;
type Dispatch<T> = (value: T) => void;
type DispatchWithoutAction = () => void;
type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
function useReducer<R extends ReducerWithoutAction<any>>(reducer: R): DispatchWithoutAction
const Component = () => {
const [count, increase] = useReducer(v => v + 1, 0);
const handleClick = useCallback(
() => {
// TS2554: Expected 1 arguments, but got 0.
increase();
},
[]
);
return <>{count}<button onClick={handleClick}>Click Me</button></>;