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 setTimeout(callback, delay, ...args) { | |
const id = setTimeout._nextId++; | |
const start = Date.now(); | |
function loop() { | |
queueMicrotask(() => { | |
if (!setTimeout._timers[id]) return; | |
if (Date.now() - start >= delay) { | |
delete setTimeout._timers[id]; | |
callback(...args); | |
} else { |
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
package main | |
import ( | |
"fmt" | |
"github.com/valyala/fasthttp" | |
"log" | |
"net/http" | |
"os" | |
"strings" | |
"time" |
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
#!/bin/sh | |
usage() { | |
echo "usage: go-mini-build <package-name> [output-path]" | |
} | |
file_size() { | |
echo $(ls -lh "$1" | awk '{print $5}') | |
} |
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
* { | |
margin: 0; | |
padding: 0; | |
} | |
body { | |
min-width: 200px; | |
max-width: 900px; | |
margin: 0 auto; | |
padding: 20px; |
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
<div class="xxx" zz="{"e;a"e;:1}"> | |
<text>hello</text> | |
<a>dsds</a> | |
ok | |
<x> | |
<y>z</y> | |
</x> | |
</div> |
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
// 价值一百个亿的 AI 核心代码 | |
// Do What The Fuck You Want To Public License | |
open System | |
let replace (oldstr : string) (newstr : string) (text : string) = | |
text.Replace(oldstr, newstr) | |
let ask() = | |
Console.Write("> ") | |
Console.ReadLine() |
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
// 从页面获取所有链接URL | |
// http://www.msj1.com/archives/2868.html | |
console.log( | |
"list=%s", | |
JSON.stringify( | |
Array.from(document.querySelector("#content table").querySelectorAll("tr")) | |
.map(tr => tr.querySelector("td a")) | |
.filter(a => a) | |
.map(a => a.href) | |
) |
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
// 高精度定时器,interval为毫秒 | |
function myTimer(callback, interval) { | |
function getTime() { | |
return process.uptime() * 1000; | |
} | |
let previous = getTime(); | |
setInterval(function() { | |
const now = getTime(); | |
if (now - previous >= interval) { | |
previous = now; |
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
{ | |
"name": "cookie example", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"dependencies": { | |
"connect-redis": "^3.3.3", | |
"cookie-parser": "^1.4.3", | |
"express": "^4.16.2", | |
"express-session": "^1.15.6" |
NewerOlder