Skip to content

Instantly share code, notes, and snippets.

View eczn's full-sized avatar
Star

eczn* eczn

Star
View GitHub Profile
@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 / 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
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; 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 / workers.js
Created July 12, 2023 12:23 — forked from Papersman/workers.js
mikan_cloudflare_workers
/*
* https://github.com/netnr/workers
*
* 2019-10-12 - 2022-05-05
* netnr
*
* https://github.com/Rongronggg9/rsstt-img-relay
*
* 2021-09-13 - 2022-05-29
* modified by Rongronggg9
@eczn
eczn / gist:808b6e0edea8118bbee8c73f757b35e7
Last active July 18, 2023 22:23 — forked from lomomike/gist:770dd7df03bb951fac4e
linux 内核代码里利用宏实现的链表 list,值得观赏/收藏
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/slab.h>
struct birthday {
int day;
int month;
int year;
@eczn
eczn / y-combinator.ts
Created February 5, 2021 09:43 — forked from forivall/y-combinator.ts
Typescript Y-Combinator
// my brain decided to ask the question: yknow, i want you to think about the y combinator --
// like, what is it. like what the fuck girl, cmon, you have a comp sci degree, you should know this, and understand it and shit
// and so i was like fiiiiiiiiiiiiiiine gosh, lets see if typescript can handle the typing, and play around with it
// so i looked up a javascript implementation, and played with the type defintion until it
// matched up and then i was like oh: thats what the type definition of the functions in it are.
// i get it now. that's pretty cool. the main interesting thing is a the inner function that takes itself
// and returns the function initially passed to the outer function. neato.
@eczn
eczn / git-set-unset-proxy.sh
Last active August 12, 2023 07:37 — forked from laispace/git 设置和取消代理
git 设置和取消代理
# 设置
git config --global https.proxy http://127.0.0.1:1080
git config --global http.proxy https://127.0.0.1:1080
# 取消
git config --global --unset http.proxy
git config --global --unset https.proxy
# 删除 npm proxy 配置
npm config delete proxy