This file contains 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 getArr(size: number) { | |
const result: number[][] = []; | |
(function loop(arr: number[] = []) { | |
if (arr.length < size) { | |
loop([...arr, 0]); | |
loop([...arr, 1]); | |
} else { | |
result.push(arr); | |
} | |
})(); |
This file contains 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
<input pattern="[0-9]*" /> |
This file contains 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
{ | |
"FormattingOptions": { | |
"NewLinesForBracesInLambdaExpressionBody": false, | |
"NewLinesForBracesInAnonymousMethods": false, | |
"NewLinesForBracesInAnonymousTypes": false, | |
"NewLinesForBracesInControlBlocks": false, | |
"NewLinesForBracesInTypes": false, | |
"NewLinesForBracesInMethods": false, | |
"NewLinesForBracesInProperties": false, | |
"NewLinesForBracesInAccessors": false, |
This file contains 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 polygonArea(points: { x: number; y: number }[]) { | |
let i = 0; | |
let s = 0; | |
while (points[i + 1]) { | |
const p1 = points[i]; | |
const p2 = points[i + 1]; | |
s += p1.x * p2.y - p2.x * p1.y; | |
i += 1; | |
} | |
return Math.abs(s / 2); |
This file contains 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
// yarn add fs-extra glob | |
const { promisify } = require('util'); | |
const glob = promisify(require('glob')); | |
const fse = require('fs-extra'); | |
const path = require('path'); | |
async function replace(ext, newExt) { | |
const pattern = path.resolve(__dirname, `**/*.${ext}`); | |
const filenames = await glob(pattern); |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Ansi 0 Color</key> | |
<dict> | |
<key>Alpha Component</key> | |
<real>1</real> | |
<key>Blue Component</key> | |
<real>0.20312860608100891</real> |
This file contains 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
// 基于 ctx, 类型好友的 js HTTP 设计尝试 | |
type IncomingMessage = object; | |
type Prettier<T> = T extends object ? { [K in keyof T]: T[K] } : T; | |
type Middle = (ctx: BaseCtx) => unknown; | |
type BaseCtx = { readonly _: IncomingMessage }; | |
type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T; | |
type NextCtx<T extends Middle> = Awaited<ReturnType<T>>; | |
type KV<P> = P extends `${infer K}=${infer V}` ? { [k in K]: VType<V> } : {}; |
OlderNewer