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 fs from "node:fs/promises"; | |
| import path from "node:path"; | |
| import process from "node:process"; | |
| import { TextDecoder } from "node:util"; | |
| const docsDir = path.join(process.cwd(), "site", "content", "zh", "docs"); | |
| async function listFiles(dir) { | |
| const out = []; | |
| const entries = await fs.readdir(dir, { withFileTypes: true }); |
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 autocorrect from "autocorrect-node"; | |
| import fs from "node:fs/promises"; | |
| import path from "node:path"; | |
| import process from "node:process"; | |
| const docsDir = path.join(process.cwd(), "site", "content", "zh", "docs"); | |
| async function run() { | |
| const entries = await fs.readdir(docsDir, { withFileTypes: true }); | |
| for (const entry of entries) { |
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 autocorrect from "autocorrect-node"; | |
| import fs from "node:fs/promises"; | |
| import path from "node:path"; | |
| import process from "node:process"; | |
| const docsDir = path.join(process.cwd(), "site", "content", "zh", "docs"); | |
| async function run() { | |
| const entries = await fs.readdir(docsDir, { withFileTypes: true }); | |
| for (const entry of entries) { |
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 filesize from 'filesize' | |
| import crypto from 'crypto' | |
| function testIt(buffer: Buffer) { | |
| console.log("========") | |
| console.log(`原始 buffer 长度`, filesize.filesize(buffer.byteLength)); | |
| const stringified = JSON.stringify(buffer) | |
| if (stringified.length < 200) { | |
| console.log(`原始数据`, buffer); | |
| console.log(`序列化结果:`, stringified); |
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
| const { js } = require('@ast-grep/napi'); | |
| const MagicString = require('magic-string').default; | |
| /** | |
| * Replace the local variable name of the import statement | |
| */ | |
| exports.replaceImportDefault = (source, pkgName, expectLocalName) => { | |
| const magic = new MagicString(source); | |
| const ast = js.parse(source); // 1. parse the source |
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
| # one or the other, NOT both | |
| [url "https://github"] | |
| insteadOf = git://github | |
| # or | |
| [url "[email protected]:"] | |
| insteadOf = git://github |
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 love.conf(t) | |
| t.title = "L\195\150VE " .. love._version .. " (" .. love._version_codename .. ")" | |
| -- t.gammacorrect = true | |
| -- t.modules.audio = false | |
| -- t.modules.sound = false | |
| -- t.modules.joystick = false | |
| -- t.window.resizable = true | |
| -- t.window.highdpi = true | |
| t.window.width, t.window.height = 1280, 720 | |
| t.window.fullscreen = true |
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
| # 1g.txt zero | |
| dd if=/dev/zero of=1g.txt bs=1M count=1000 | |
| # 10m.txt random | |
| dd if=/dev/random of=10m.txt bs=1M count=10 |
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
| package main | |
| import ( | |
| "flag" | |
| "io" | |
| "log" | |
| "net" | |
| "net/http" | |
| "strings" | |
| ) |
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
| #!/usr/bin/env tsx | |
| import { config } from 'dotenv'; | |
| config(); | |
| import { context as createContext, Plugin } from 'esbuild'; | |
| import ts from 'typescript'; | |
| import { build } from 'esbuild'; | |
| import mri from 'mri'; |
NewerOlder