Skip to content

Instantly share code, notes, and snippets.

View johnsoncheg's full-sized avatar
🎯
Focusing

Infinity johnsoncheg

🎯
Focusing
  • eleme
  • ShangHai
View GitHub Profile
;1、域名组
ruleset=✨ AI,https://raw.githubusercontent.com/liandu2024/clash/refs/heads/main/AI.list
ruleset=📘 GitHub,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/refs/heads/master/rule/Clash/GitHub/GitHub.list
ruleset=👯‍♂️ TikTok,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/refs/heads/master/rule/Clash/TikTok/TikTok.list
ruleset=🙋 Telegram,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Telegram/Telegram.list
ruleset=🕊️ Twitter(X),https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Twitter/Twitter.list
ruleset=🗣️ Facebook,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/refs/heads/master/rule/Clash/Facebook/Facebook.list
ruleset=🌳 Amazon,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/refs/heads/master/rule/Clash/Amazon/Amazon.list
ruleset=🍎 Apple,https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Apple/Apple.list
ruleset=Ⓜ️ Microsoft,https://raw.githubusercon
@johnsoncheg
johnsoncheg / object-fit-cover-video.js
Created September 24, 2020 05:05 — forked from dmail/object-fit-cover-video.js
object-fit:cover polyfill on video element using canvas
// http://stackoverflow.com/questions/21961839/simulation-background-size-cover-in-canvas
function drawImageProp(ctx, img, x, y, w, h, offsetX, offsetY) {
if (arguments.length === 2) {
x = y = 0;
w = ctx.canvas.width;
h = ctx.canvas.height;
}
// default offset is center
offsetX = typeof offsetX === "number" ? offsetX : 0.5;
@johnsoncheg
johnsoncheg / vdom_v2.html
Created May 5, 2020 11:43 — forked from dickenslian/vdom_v2.html
你不知道的Virtual DOM(二)
<body>
<style>
body { margin: 0; font-size: 24; font-family: sans-serif }
.li-1 { background: red }
.li-2 { background: green }
.li-3 { background: yellow }
.li-4 { background: purple }
.li-0 { background: gray }
</style>
<script src="compiled.js"></script>
@johnsoncheg
johnsoncheg / SassMeister-input.scss
Created August 11, 2019 08:30 — forked from KittyGiraudel/SassMeister-input.scss
Generated by SassMeister.com.
// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
// -----------------------------------------------------------------------------
// Introduction
// -----------------------------------------------------------------------------
// Here is hacky and experimental solution for cross-scopes extends
@johnsoncheg
johnsoncheg / oneliners.js
Created April 2, 2019 06:34 — forked from mikowl/oneliners.js
👑 Awesome one-liners you might find useful while coding.
// By @coderitual
// https://twitter.com/coderitual/status/1112297299307384833
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// Type this in your code to break chrome debugger in that line.
@johnsoncheg
johnsoncheg / what-forces-layout.md
Created March 16, 2019 07:44 — 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()
@johnsoncheg
johnsoncheg / Events.js
Created March 3, 2019 06:39 — forked from alextaujenis/Events.js
Add custom Events to javascript objects in the browser with a Node.js style syntax
// Add custom Events to javascript objects in the browser with a Node.js style syntax
// https://gist.github.com/alextaujenis/0dc81cf4d56513657f685a22bf74893d
// Copyright 2018 Alex Taujenis
// MIT License
class Events {
constructor () {
this._callbacks = {}
}
@johnsoncheg
johnsoncheg / index.html
Created September 1, 2018 08:53
simple-spa-router
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
<ul>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Binding the same event listeners more than once</title>
</head>
@johnsoncheg
johnsoncheg / listen1_aha_playlist.md
Last active December 28, 2018 12:30
updated by Listen1(http://listen1.github.io/listen1/) at 2018/12/28 下午8:29:56

本歌单由Listen1创建, 歌曲数:2336,歌单数:43,点击查看更多