Skip to content

Instantly share code, notes, and snippets.

View songlairui's full-sized avatar
🌴
On vacation

lary songlairui

🌴
On vacation
  • Bytedance
  • ShenZhen
View GitHub Profile
@songlairui
songlairui / nodejs-tcp-example.js
Created February 3, 2019 12:37 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@songlairui
songlairui / mpvue-template-compiler--build.js
Created December 20, 2018 06:32
mpvue slot scoped 支撑
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var deindent = _interopDefault(require('de-indent'));
var he = _interopDefault(require('he'));
var babel = _interopDefault(require('babel-core'));
var prettier = _interopDefault(require('prettier'));
@songlairui
songlairui / nes-client-mp.js
Last active November 3, 2018 15:53
hapijs/nes 提供了浏览器端的基于浏览器 websocket(hybi-13) 的api , 在小程序中使用client,需要先模拟这个WebSocket
import WebSocket from './websocket'
export default factory()
// below copy from https://github.com/hapijs/nes/blob/master/lib/client.js
function factory() {
// Utilities
const version = '2'
const ignore = function() {}
@songlairui
songlairui / ssh-port-forward.md
Last active September 5, 2018 14:17
ssh端口转发
@songlairui
songlairui / wrap-setTimeoutLoop-to-promise.js
Created August 31, 2018 02:59
将setTimeout的轮询包裹成Promise
const cache = {
resolve: null
}
let timerId
function finish(b) {
console.warn('---------finish-------')
if (cache.resolve) {
console.warn('---------cache.resolve-------', b)
@songlairui
songlairui / build.js
Created August 19, 2018 17:46
通过修改全局require的方式,更改自己期望require的文件。临时性trick
// 临时修复mpvue-loader 1.0.15复制node_modules目录的bug
module.constructor.prototype.require = function (modulePath) {
if (
modulePath === './modules/transform-require' &&
this.id.indexOf('mpvue-loader/lib/template-compiler/index.js') > -1
) {
modulePath = path.resolve(__dirname, 'utils', 'fixRequire.js')
}
return this.constructor._load(modulePath, this)
}
@songlairui
songlairui / fake-npm-link.sh
Created August 18, 2018 12:55
同步开发目录的webapp到paas-cli/node_modules目录下