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
// ==UserScript== | |
// @name copyDmhyAllMagnet.js | |
// @version 0.1.1 | |
// @description 2022/05/05 | |
// @author Julen | |
// @match https://share.dmhy.org/topics/list?* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=dmhy.org | |
// @grant none | |
// ==/UserScript== |
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
// ==UserScript== | |
// @name deleteLeetcodeNodes.js | |
// @namespace manual | |
// @match https://leetcode-cn.com/* | |
// @version 0.3 | |
// @author Julen | |
// @description 2021/12/10 下午3:30:44 | |
// @grant GM_registerMenuCommand | |
// ==/UserScript== |
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
<# | |
.SYNOPSIS | |
Adjust the mouse speed when using Barrier (on Windows) to control another computer. | |
.DESCRIPTION | |
When using Barrier (https://github.com/debauchee/barrier) across two computers of different | |
resolutions/DPIs, the server's mouse speed may be too fast or too slow on the client computer: | |
https://github.com/debauchee/barrier/issues/741. This script monitors Barrier's log file and adjusts | |
the server's mouse speed when the mouse has moved onto the client. | |
Inspired in full by Aaron Jensen's (https://github.com/aaronjensen) script at | |
https://github.com/debauchee/barrier/issues/741#issuecomment-655317497. |
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
interface NewableFunc { | |
new (...args: any): any; | |
} | |
function singleton<T extends NewableFunc>(clazz: T): T { | |
let instance: T | undefined; | |
return new Proxy<T>(clazz, { | |
construct: (Target, argArray) => { | |
if (instance) { | |
return instance; |
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 { CSSProperties, MutableRefObject, RefCallback, useCallback, useMemo, useRef, useState } from 'react'; | |
import { useDrag } from 'react-dnd'; | |
import { transformPxToRemString } from '@/utils/doms'; | |
const initOffset = { x: 0, y: 0 }; | |
const useArbitraryDrag = (): { | |
ref: RefCallback<HTMLElement>; | |
style: CSSProperties; | |
} => { |
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 { useEffect, useRef, useState } from 'react'; | |
const useDelayLoading = (isLoading: boolean, delay = 1500): boolean => { | |
const [loading, setLoading] = useState(false); | |
const timerRef = useRef<number>(); | |
useEffect(() => { | |
const timer = timerRef.current; | |
if (isLoading) { | |
timerRef.current = setTimeout(() => { |
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 { useState } from 'react'; | |
import { getRemNumber } from '@/utils/doms'; | |
import { useEventListener } from 'ahooks/es'; | |
import * as _ from 'lodash'; | |
export function getRemNumber(): number { | |
const fontString = getComputedStyle(document.documentElement).getPropertyValue('font-size'); | |
return Number(fontString.replace(/[^0-9.]/g, '')); | |
} | |
export function transformPxToRemString(length: number, precision = 3) { |
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 { Merge } from 'type-fest'; | |
export type AsyncFunction = (...args: any[]) => Promise<any>; | |
/** | |
* 扩展对象联合类型的每一项 | |
*/ | |
export type ExpandObjectUnion<Union, Item extends Record<string, unknown>> = Union extends unknown | |
? Merge<Union, Item> | |
: never; | |
export type NonNullableAll<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
<# | |
.SYNOPSIS | |
Adjust the mouse speed when using Barrier (on Windows) to control another computer. | |
.DESCRIPTION | |
When using Barrier (https://github.com/debauchee/barrier) across two computers of different | |
resolutions/DPIs, the server's mouse speed may be too fast or too slow on the client computer: | |
https://github.com/debauchee/barrier/issues/741. This script monitors Barrier's log file and adjusts | |
the server's mouse speed when the mouse has moved onto the client. |
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 generateUUID(): string { | |
return new Array(4) | |
.fill(0) | |
.map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)) | |
.join("-"); | |
} |