Skip to content

Instantly share code, notes, and snippets.

View yangfch3's full-sized avatar
🎯
Focusing

Fucheng Yang yangfch3

🎯
Focusing
  • NetEase
  • Internet
View GitHub Profile
@yangfch3
yangfch3 / sublime-scopes.txt
Last active August 29, 2016 07:54 — forked from iambibhas/scopes.txt
Sublime Text 2: Snippet scopes
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
@yangfch3
yangfch3 / HTML-tags.md
Created March 14, 2016 05:48 — forked from yisibl/HTML-tags.md
常用的 HTML 头部标签

常用的 HTML 头部标签

详细介绍参见原文:yisibl/blog#1

<!DOCTYPE html> <!-- 使用 HTML5 doctype,不区分大小写 -->
<html lang="zh-cmn-Hans"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
    <meta charset='utf-8'> <!-- 声明文档使用的字符编码 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 优先使用 IE 最新版本和 Chrome -->
@yangfch3
yangfch3 / pull-my-github-star-list.js
Last active March 6, 2020 15:07
拉取你的 github star 列表
const fs = require('fs'),
child_exe = require('child_process');
let page = 1,
perPage = 20;
function autoCrawl() {
child_exe.exec(`curl https://api.github.com/users/yangfch3/starred?page=${page} --silent`, function (err, stdout, stderr) {
let data = stdout,
dataArr = JSON.parse(data),
@yangfch3
yangfch3 / js-oop-example.js
Last active December 17, 2016 14:57
一段讲解使用 JS 实现 OOP 的代码实例
function inheritPrototype(subType, superType) {
if (Object.create) {
// 利用 Object.create 的特性实现 __proto__ 指针的正确指向,完美
subType.prototype = Object.create(superType.prototype);
subType.prototype.constructor = subType;
} else {
function F() {}
F.prototype = superType.prototype;
var prototype = new F();
prototype.constructor = subType;
@yangfch3
yangfch3 / ex-console.js
Last active December 19, 2017 11:43
一段原生 console 对象增强示例代码
var console = function() {
// 存储旧 console 地址
var oldConsole = window.console;
// 增强函数用到的一些配置
var colors = ["#eaeaea", "#b7b7b7"];
var index = 1;
window.newConsole = {
wc: oldConsole
@yangfch3
yangfch3 / .eslintrc.js
Last active June 30, 2021 04:51
eslint-config 文件配置说明
{
// 继承,可以继承多个
// 如安装了 eslint-config-airbnb
// 就可以在 extends 这里引用 airbnb/base, 这样就相当于预设了 airbnb/base 的规则
// 常用的预设:"eslint:recommended" "airbnb/base" "stanard"(需先安装 eslint-config-standard)
// 当然,除了 eslint-config-xxx 提供了一系列预设,插件(eslint-plugin-xxx)也能提供预设用于继承
// 例如,当你安装了 eslint-plugin-react 时,就可以在 extends 这里指定 "plugin:react/recommended"
// 当然,也可以指定一个具体的 eslint 配置文件 path/to/file 继承
"extends": [
"airbnb/base"
@yangfch3
yangfch3 / eslint-comments.js
Last active September 26, 2016 02:45
eslint-comments 使用注释进行 eslint 短时特异性配置
/* eslint-env node, mocha */
var str1 = "你可以使用注释为文件指定 eslint 的环境 ↑";
/* global var1: true, var2: false */
var str2 = "你可以使用注释说明这两个变量是全局变量,并声明是否能被重写";
/* eslint eqeqeq: 0, curly: 2, "plugin1/rule1": 2 */
var str3 = "你可以使用注释让这些规则对你的文件进行特异性配置";
/* eslint-disable */ /* eslint-disable no-alert, no-console */
@yangfch3
yangfch3 / fake-xml-http-request.js
Last active October 25, 2016 07:42
xmlHttpRequest 的重写
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
global.FakeXMLHttpRequest = factory()
}(this, function () { 'use strict';
/**
* Minimal Event interface implementation
*
* Original implementation by Sven Fuchs: https://gist.github.com/995028
@yangfch3
yangfch3 / CommandJS-circle-require.js
Last active October 12, 2016 03:42
CommandJS 循环依赖实例讲解
/**
* 一段代码分析 CommandJS 的循环依赖
*
* 一句话概括:出现循环依赖时,循环依赖的后者只会获取前者已执行部分的 exports
*/
// a.js
exports.done = false;
var b = require('./b.js'); // 2. 出现 require,自身暂停执行,开始执行 b.js
@yangfch3
yangfch3 / ES6-module-circle-import.js
Last active October 12, 2016 04:12
ES6 模块循环依赖
/**
* ES6 模块循环依赖时
* 代码的运行过程与 CommonJS 一致
* 不同的是变量引用的处理不同
* ES6加载的变量,都是动态引用其所在的模块。只要引用存在,代码就能执行。
*/
/**
* module-a.js
*/