Skip to content

Instantly share code, notes, and snippets.

View zoffyzhang's full-sized avatar
💻
coding

Zoffy Zhang zoffyzhang

💻
coding
View GitHub Profile
@thomaswilburn
thomaswilburn / zip-it.md
Last active April 18, 2024 11:56
Exploring generators and iteration through zip()

Win zip()

I don't often use zip(), but by coincidence this week I ran into it a few times, using both Python and JavaScript. In the former, it's a built-in, but in the latter it's typically provided by a library like D3. And it struck me as kind of a fun warm-up challenge. How would you write this function in modern JavaScript?

Well, let's see how D3 does it. Oh, it's a wrapper around transpose(), here we go...

import min from "./min.js";

function length(d) {
@larsneo
larsneo / viewer.html
Last active July 24, 2024 03:15 — forked from jsprpalm/viewer.html
Pinch zoom implementation for PDF.js viewer
<!-- Goes into viewer.html just before ending </body> -->
<script>
let pinchZoomEnabled = false;
function enablePinchZoom(pdfViewer) {
let startX = 0, startY = 0;
let initialPinchDistance = 0;
let pinchScale = 1;
const viewer = document.getElementById("viewer");
const container = document.getElementById("viewerContainer");
const reset = () => { startX = startY = initialPinchDistance = 0; pinchScale = 1; };
@shenqihui
shenqihui / README.md
Last active April 9, 2024 17:03
前端面试的笔试题

前端面试笔试题说明

出题的意义

  • 初步筛选出面试者,不用来一遍公司才发现不合适,节省面试者的时间。
  • 现场作答,由于面试者没带电脑,不方便作答,没法体现自己的能力。
  • 通过回答了的题目,提前判断出面试者的水平,节省面试的时间。
  • 让面试者充分准备。

Git Cheat Sheet

Commands

Getting Started

git init

or

@jboner
jboner / latency.txt
Last active July 24, 2024 19:52
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