Skip to content

Instantly share code, notes, and snippets.

View eczn's full-sized avatar
Star

eczn* eczn

Star
View GitHub Profile
@eczn
eczn / 手动覆盖 VSCode 主题的配色.md
Created November 27, 2024 07:44
手动覆盖 VSCode 主题的配色

有时候对主题各方面都感觉很好,但是有一两个地方的颜色感觉还是不太好,此时又不想太麻烦可以通过 vscode 的 workbench.colorCustomizations 项进行覆盖配置:

"workbench.colorCustomizations": {
    "[Popping and Locking]": { // ⬅️ 用中括号括起来 主题名字
        "tab.border": "#484a5c",
        "tab.activeBackground": "#484a5c",
        "tab.activeBorder": "#ed0a0a"
    }
},
@eczn
eczn / latency.txt
Created June 9, 2024 15:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@eczn
eczn / mac-disable-swap.md
Created May 16, 2024 14:20
mac 禁用 swap 交换

参考自 https://github.com/digoal/blog/blob/master/202212/20221207_01.md 这里备份记录一下


第零步:关闭 SIP

SIP 会导致你即使是 root 用户也会出 operation not permitted 的情况出现,尤其是操作一些系统底层的时候(比如 nvram、系统目录/服务等)

关闭方式(只测了我的 m1 mac,需要进入恢复模式):

  1. 关机
@eczn
eczn / GetOptimizationStatus.md
Created May 15, 2024 05:24 — forked from justjavac/GetOptimizationStatus.md
V8 %GetOptimizationStatus

%GetOptimizationStatus return a set of bitwise flags instead of a single value, to access the value, you need to take the binary representation of the returned value. Now, for example, if 65 is returned, the binary representation is the following:

(65).toString(2).padStart(12, '0');
// 000001000001

Each binary digit acts as a boolean with the following meaning:

@eczn
eczn / gist:6232302380fe5defffb0f4cca00a283b
Created May 15, 2024 05:07 — forked from totherik/gist:3a4432f26eea1224ceeb
v8 --allow-natives-syntax RuntimeFunctions
Per https://code.google.com/p/v8/codesearch#v8/trunk/src/runtime.cc
%CreateSymbol
%CreatePrivateSymbol
%CreateGlobalPrivateSymbol
%NewSymbolWrapper
%SymbolDescription
%SymbolRegistry
%SymbolIsPrivate
@eczn
eczn / lexer.mbt
Last active May 3, 2024 04:32
parser combinator 词法解析器
enum Token {
Value(Int)
LParen;
RParen;
Plus;
Minus;
Multiply;
Divide;
} derive(Debug)
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial
; on http://skilldrick.github.io/easy6502/ that I created as an exercise for myself
; to learn a little bit about assembly. I **think** I understood everything, but I may
; also be completely wrong :-)
@eczn
eczn / scale-canvas.ts
Created January 19, 2024 09:59 — forked from callumlocke/scale-canvas.ts
How to fix a canvas so it will look good on retina/high-DPI screens.
/*
UPDATED for 2023 - Now much simpler. The old tricks are no longer needed.
The following code makes an 800×600 canvas that is always as sharp as possible for the device.
You still draw on it as if it's the logical size (800×600 in this case), but everything just
looks sharper on high-DPI screens. Regular non-sharp screens are not affected.
*/
const width = 800
@eczn
eczn / createSignal.tsx
Created January 5, 2024 07:04
createSignal for react
import React from 'react';
/** createSignal for react */
export function createSignal<S>(
initialState: S
): [() => S, (nextState: S) => void] {
const forceRender = useForceRender();
const stateRef = React.useRef<S>(initialState);
const stateRefGetter = (): S => stateRef.current;
@eczn
eczn / units.tsx
Last active September 12, 2023 04:53
bytes storage units fomatter
export enum Units {
B = 1,
KB = 1 * 1024,
MB = 1 * 1024 * 1024,
GB = 1 * 1024 * 1024 * 1024,
TB = 1 * 1024 * 1024 * 1024 * 1024,
}
const UnitsName = ['B', 'KB', 'MB', 'GB', 'TB'];