Skip to content

Instantly share code, notes, and snippets.

View zheeeng's full-sized avatar
🎈
blowing balloons

Zheeeng zheeeng

🎈
blowing balloons
View GitHub Profile
loadPolyfills()
.then(() => /* Render React application now that your Polyfills are ready */)
/**
* Do feature detection, to figure out which polyfills needs to be imported.
**/
function loadPolyfills() {
const polyfills = []
if (!supportsIntersectionObserver()) {
@zheeeng
zheeeng / type.ts
Last active January 21, 2018 09:38
Advanced TS Type
type Readonly<T> = {
readonly [P in keyof T]: T[P];
}
type Partial<T> = {
[P in keyof T]?: T[P];
}
type Nullable<T> = {
[P in keyof T]: T[P] | null;
class Refs extends React.PureComponent<IProps> {
private references: React.ReactInstance[] = []
componentDidMount () {
console.log('references', this.references)
}
setRef = (ref: React.ReactInstance) => {
this.references.push(ref)
}
const { CreateView, CreateComponent } = Buz
const data = {
account: {
userId: 000001,
username: 'Bob',
email: 'Bob@',
avatar: 'https://avatars.com/a-handsome-man',
isLogin: true,
services: ['calendar', 'mailbox', 'game-center']
@zheeeng
zheeeng / Status Code Message
Created January 11, 2018 13:30
Status Code Message
const codeMessage = {
200: '服务器成功返回请求的数据',
201: '新建或修改数据成功。',
202: '一个请求已经进入后台排队(异步任务)',
204: '删除数据成功。',
400: '发出的请求有错误,服务器没有进行新建或修改数据,的操作。',
401: '用户没有权限(令牌、用户名、密码错误)。',
403: '用户得到授权,但是访问是被禁止的。',
404: '发出的请求针对的是不存在的记录,服务器没有进行操作',
406: '请求的格式不可得。',
%YAML 1.2
---
name: HTML
file_extensions:
- html
- htm
- shtml
- xhtml
- inc
- tmpl
@zheeeng
zheeeng / cloudSettings
Last active August 20, 2017 13:05
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-08-20T13:05:44.793Z","extensionVersion":"v2.8.3"}
@zheeeng
zheeeng / filter.js
Created November 14, 2016 07:20
filter function
var isArrayLike = function (arg) {
return arg && typeof arg.length === 'number' && arg.length > -1 && arg.length % 1 === 0 && typeof arg !== 'function'
}
var filter = (function () {
if (Array.prototype.filter) {
return function (arrayLikeList, filter, thisArg) {
return Array.prototype.filter.call(arrayLikeList, filter, thisArg)
}
} else { // Array.prototype.filter fallback
@zheeeng
zheeeng / rAF.js
Created November 9, 2016 07:17 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@zheeeng
zheeeng / 0_reuse_code.js
Created November 7, 2016 01:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console