Skip to content

Instantly share code, notes, and snippets.

View stormslowly's full-sized avatar
🎯
Focusing

pshu stormslowly

🎯
Focusing
  • Hangzhou, Zhejiang, China
View GitHub Profile
@stormslowly
stormslowly / gist:bd99e62abdc8a979635beaa0c942e6c4
Created May 9, 2025 08:50
rspsack-input-system-benchmark
| Name | Base (nativeFS) | Current | Change |
| -------------------------------------------------------------------- | --------------- | --------------- | -------- |
| 10000_big_production-mode_disable-minimize + exec | 20.6 s ± 8.13 s | 21.1 s ± 7.65 s | +2.49 % |
| 10000_development-mode + exec | 1.1 s ± 11 ms | 1.55 s ± 51 ms | +41.91 % |
| 10000_development-mode_hmr + exec | 661 ms ± 3.7 ms | 659 ms ± 12 ms | -0.29 % |
| 10000_production-mode + exec | 1.76 s ± 24 ms | 2.24 s ± 36 ms | +27.51 % |
| arco-pro_development-mode + exec | 1.3 s ± 51 ms | 1.74 s ± 66 ms | +33.88 % |
| arco-pro_development-mode_hmr + exec | 376 ms ± 1.3 ms | 384 ms ± 2 ms | +2.20 % |
| arco-pro_production-mode + exec
function fn_r {
# $# 命令参数个数, $* 参数列表
if [ $# -eq 0 ]; then
SCRIPT=$(jq -r '.scripts | keys[]' package.json | \
fzf --preview-window=down:10%:wrap \
--no-mouse \
--preview 'jq -r --arg script {} ".scripts[\$script]" package.json')
if [ -n "$SCRIPT" ]; then
history -s "r $SCRIPT"
if command -v atuin >/dev/null 2>&1; then
@stormslowly
stormslowly / main.rs
Created March 21, 2024 09:43
swc_css_parser_memory_leak_example
use swc_core::common::{FileName, SourceMap};
use swc_core::common::input::StringInput;
use swc_core::common::sync::Lrc;
use swc_core::css::parser::{parser, lexer};
fn main() {
let cm = Lrc::<SourceMap>::default();
let fm = cm.new_source_file(
FileName::Custom("test.css".into()),
@stormslowly
stormslowly / main.rs
Created October 18, 2023 10:10
hash a stylesheet of swc
use std::hash::{Hash, Hasher};
use swc_common::{FileName, SourceMap};
use swc_common::input::StringInput;
use swc_common::sync::Lrc;
use std::borrow::Borrow;
fn main() {
let cm: Lrc<SourceMap> = Default::default();
let fm = cm
@stormslowly
stormslowly / machine.js
Last active December 26, 2019 02:02
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
import generate from "@babel/generator";
import {parse} from "@babel/parser";
import traverse from "@babel/traverse";
import {identifier, isIdentifier, isMemberExpression, memberExpression} from "@babel/types";
import * as fs from 'fs'
const file = process.argv[2]
const ast = parse(fs.readFileSync(file, 'utf-8’)) // 解析得到 ast
traverse(ast, {
CallExpression(path) { // 当遍历到“调用表达式”时进入此回调
if (isMemberExpression(path.node.callee) && // 被调用的函数来自一个成员表达
@stormslowly
stormslowly / collapse
Created March 1, 2019 04:32
time collapse using ffmpeg
#!/usr/bin/env node
const files = process.argv.slice(2)
const cmds = files.map(f =>
`ffmpeg -i ${f} -filter:v "setpts=PTS/30" -crf 20 -r 30 -an -threads 1 -y -vcodec libx264 ${f}.collapse.flv`)
console.log(cmds.join('\n'))
@stormslowly
stormslowly / benchmark.js
Created July 19, 2017 16:51
generate array contains 1 to 1e7
console.time("Array.push");
const array = [];
for (var i = 0; i < 1e7; i++) array[i] = i;
console.timeEnd("Array.push");
console.time("new Array.push");
const array1 = new Array(1e7);
for (var i = 0; i < 1e7; i++) array1[i] = i;
console.timeEnd("new Array.push");
[alias]
st = status
ci = commit
co = checkout
dt = difftool
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen%cr %C(bold blue)<%an>%Creset'
lp = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen%cr %C(bold blue)<%an>%Creset'
ca = commit -a
[color]
ui = auto
@stormslowly
stormslowly / nginxproxy.md
Created January 6, 2017 03:43 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers