Skip to content

Instantly share code, notes, and snippets.

@V-Tom
V-Tom / WebSocket.server.js
Created September 26, 2018 09:50
Simple WebSocket on Node.js
const http = require('http')
const crypto = require('crypto')
// 当前请求数据状态
let STATE = {
fin: null,
opcode: null,
masked: null,
dataIndex: null,
maskingKey: null,
@V-Tom
V-Tom / koa.lite.js
Last active October 30, 2019 06:33
koa lite
'use strict'
const http = require('http')
const Emitter = require('events')
module.exports = class KoaLite extends Emitter {
constructor() {
super()
this.middleware = []
}
// Run from the dev tools console of any Youtube video
// Accurate as of June 12, 2016
var videoUrls = {};
ytplayer.config.args.url_encoded_fmt_stream_map.split(',').forEach(function (item) {
var obj = {};
item.split('&').forEach(function (param) {
param = param.split('=');
obj[param[0]] = decodeURIComponent(param[1]);
});