Skip to content

Instantly share code, notes, and snippets.

View johnsoncheg's full-sized avatar
🎯
Focusing

Infinity johnsoncheg

🎯
Focusing
  • eleme
  • ShangHai
View GitHub Profile
@johnsoncheg
johnsoncheg / chrome 控制台 console
Created April 18, 2017 07:36 — forked from reacher-lu/chrome 控制台 console
chrome 控制台 console
console.warn(‘aaaaaa');
在输出信息前面会有一个带感叹号的黄色三角警告符号。似乎比一般的console信息要友好得多了。虽然图标是黄色的,但输出的文字仍然是黑色
console.error(“adfafasdf”)
信息前面会出现一个带叉的红色圆形图标。
这个效果要比警告信息更友好了,字体颜色成红色了。
@johnsoncheg
johnsoncheg / tmpl-demo.html
Created April 18, 2017 08:00 — forked from wiky/tmpl-demo.html
template lite
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<style>
body{background-color:#f4f4f4;color:#555;width:80%;padding:20px;font-size:16px;font-weight:200;margin:0 auto;font-family:Helvetica Neue,arial,verdana}h1{color:#708090;text-shadow:0 1px 2px #fff;font-size:4em;text-align:center}.subtitle{text-align:center;margin-bottom:60px}h2{text-shadow:0 1px 2px #fff}h2 span{font-weight:200;font-size:14px}a{color:#a80000}.smaller{font-size:.8em}h4{margin:4px 0;font-weight:400;font-size:20px}textarea{font-family: Arial;border:1px solid lightgrey;outline:none;font-size:14px;width:96%;height:310px;font-size: 20px;padding:10px;text-align:left}.templategroup,.datagroup,.functiongroup,.resultgroup{width:48%;margin:4px 2% 4px 0;float:left;min-width:300px;}.function,.result{background:#DDD;height:312px;font-size: 20px;padding:10px;font-size:14px;overflow-y:auto}.definegroup{display:none}.templategroup.withdefs .definegroup{display:block}.temp
@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,点击查看更多

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Binding the same event listeners more than once</title>
</head>
@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>
@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 / 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 / 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 / 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 / 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>