Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Fucheng Yang yangfch3

🎯
Focusing
  • NetEase
  • Hangzhou in China
View GitHub Profile
@yangfch3
yangfch3 / SoundManager.ts
Last active Nov 8, 2018
[白鹭声音管理器] 白鹭音频接口的封装 #白鹭 #游戏开发
View SoundManager.ts
class SoundManager {
private static instance: SoundManager
private static IS_MUTE_SYMBOL = 'isMute'
private static BGM_VOLUME = 'bgmVolume'
private static EFFECT_VOLUME = 'effectVolume'
static getInstance() {
if (!SoundManager.instance) {
new SoundManager()
@yangfch3
yangfch3 / cycle-await.js
Created Aug 18, 2018
循环与 async-await 搭配使用
View cycle-await.js
/**
* 并行阻塞:
* 一同等待
* 一起爆发式
*/
var arr = [1,2,3]
arr.forEach(async function (value, index) {
await new Promise((resolve, reject) => {
setTimeout(function () {
resolve(true)
@yangfch3
yangfch3 / SceneManager.ts
Last active Dec 30, 2019
[白鹭场景管理] 快捷有序地进行白鹭场景的管理 #白鹭 #游戏开发
View SceneManager.ts
///<reference path="./utils/array.ts" />
/**
* 控制场景的切换
* 与 Main 协同工作
*/
class SceneManager {
private static instance: SceneManager = null
static getInstance() {
@yangfch3
yangfch3 / del-mess-mails.js
Last active Jul 20, 2018
快速删除QQ邮箱、QQ企业邮箱邮件
View del-mess-mails.js
/**
* 点击收件箱,控制台运行代码,删除所有收件箱邮件
* 删除与某个账号的往来邮件:找到并打开与该账号的一封邮件,鼠标 hover 到收件人,点击往来邮件,然后运行下面的代码
*
* 根据网络情况,可以调节下方定时器的间隔
* (顺便发现一个 Bug: Chrome 67.0.3396.99 下 setTimeout 与 setInterval 内无法正常使用便捷选择器 $)
*/
setInterval(function () {
document.getElementById('mainFrame').contentDocument.getElementsByClassName('o_title2')[0].previousSibling.children[0].click();
document.getElementById('mainFrame').contentDocument.getElementById('quick_completelydel').click();
@yangfch3
yangfch3 / xmxx-algorithm.js
Created Jun 23, 2018
消灭星星类游戏核心算法
View xmxx-algorithm.js
const GAME_CONSTS = {
BOARD_WIDTH: 10,
BOARD_HEIGHT: 10,
STAR_COLOR_CODE_START: 1,
STAR_COLOR_CODE_END: 4,
scoreCounter (starNum) {
return starNum * starNum * 5
},
remainScoreCounter (remainNum) {
return remainNum * 20
@yangfch3
yangfch3 / vhost.conf
Last active Aug 23, 2018
Nginx 为 Node.js 反向代理
View vhost.conf
upstream nodejs8000 {
server 127.0.0.1:8000;
keepalive 64;
}
server {
listen 80;
listen 443;
server_name web-dev.youguogame.com;
ssl on;
@yangfch3
yangfch3 / angular-core.html
Last active Aug 23, 2018
Angular核心实现讲解代码
View angular-core.html
<!DOCTYPE html>
<html lang="zh_CN">
<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>Angular Core Implementation</title>
</head>
@yangfch3
yangfch3 / repl-curl.js
Last active Aug 23, 2018 — forked from TooTallNate/bbs.js
使用 repl 模块搭建一个面向 curl 的 SREPL
View repl-curl.js
/**
* Requires node v0.7.7 or greater.
*
* To connect: $ curl -sSNT. localhost:8000
*/
var http = require('http')
, repl = require('repl')
, buf0 = new Buffer([0])
@yangfch3
yangfch3 / repl-client.js
Last active Aug 23, 2018 — forked from TooTallNate/repl-client.js
最简单 REPL WebShell Node.js 实现 - 基于 net 与 repl 模块
View repl-client.js
var net = require('net')
var sock = net.connect(1337)
process.stdin.pipe(sock)
sock.pipe(process.stdout)
sock.on('connect', function () {
process.stdin.resume();
process.stdin.setRawMode(true)
@yangfch3
yangfch3 / sleep.js
Last active Sep 13, 2018
[sleep 函数] #utils
View sleep.js
/**
* @param {Number} sec Sleep second period.
*/
function sleep(sec) {
sec = +sec;
if (isNaN(sec)) {
throw new Error('sleep(): arg "sec" must be a number.');
}
const startTime = Date.now();