Skip to content

Instantly share code, notes, and snippets.

@YoringChen
YoringChen / gzip.js
Created November 20, 2024 10:02 — forked from asidko/gzip.js
Encode and decode base64 GZIP with pure JavaScript. Works in all modern browsers.
// Paste the following example to browser console
// Comppreses string to GZIP. Retruns a Promise with Base64 string
const compress = string => {
const blobToBase64 = blob => new Promise((resolve, _) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result.split(',')[1]);
reader.readAsDataURL(blob);
});
@YoringChen
YoringChen / git_revision.js
Created June 21, 2022 16:22 — forked from wosephjeber/git_revision.js
Get branch and commit names from Node (synchronously)
const { execSync } = require('child_process');
function executeGitCommand(command) {
return execSync(command)
.toString('utf8')
.replace(/[\n\r\s]+$/, '');
}
const BRANCH = executeGitCommand('git rev-parse --abbrev-ref HEAD');
const COMMIT_SHA = executeGitCommand('git rev-parse HEAD');
@YoringChen
YoringChen / what-forces-layout.md
Created December 25, 2018 13:22 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@YoringChen
YoringChen / pc-header.html
Last active November 7, 2018 07:59 — forked from laozhu/pc-header.html
pc端头部meta大全
<html lang="zh-Hans">
<head>
<meta charset="utf-8">
<title>西祠胡同</title>
<!-- 页面信息 -->
<meta name="description" content="西祠胡同(www.xici.net),是国内首创的网友“自行开版、自行管理、自行发展”的开放式社区平台,致力于为各地用户提供便捷的生活交流空间与本地生活服务平台。">
<meta name="keywords" content="南京西祠胡同,xici,南京生活社区,南京论坛,花嫁,亲子,汽车,旅游,摄影,房产,家居,财富">
<meta name="author" content="Xici Dev Team">
<meta name="copyright" content="西祠胡同">
<!DOCTYPE html> <!-- 使用 HTML5 doctype,不区分大小写 -->
<html lang="zh-cmn-Hans"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
<!-- 声明文档使用的字符编码 -->
<meta charset='utf-8'>
<!-- 优先使用 IE 最新版本和 Chrome -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<!-- 页面描述 -->
<meta name="description" content="不超过150个字符"/>
<!-- 页面关键词 -->