plh

Results 91 issues of plh

add websocket which can separate room to broad message.

enhancement

有个 blacksocket.github.io 在线demo呀

所以session无法记录 非常神奇的一个问题。 我的koa-router配置文件如下 ![image](https://user-images.githubusercontent.com/14355994/39687311-60bba4e4-5200-11e8-9435-d0275f484263.png) ```js // index.js const Api = require('./api.js'); const Upload = require('./upload'); const Auth = require('./auth'); const router = require('koa-router')(); const koaBody = require('koa-body'); router .get('/api', Api)...

it don't work after i do as your tutorial **$ docker service ls Saved file tree to doc-filelist.js Copied JS to doc-script.js Compiled CSS to doc-style.css** open [http://127.0.0.1:5555](http://127.0.0.1:5555) and then...

``` console.log(new** Date().getTime()) function commafy(num){ return num && num .toString() .split(".")[0] .split("").reverse().join("") .replace(/(\d{3})/g, function($1, $2){ return $2 + ','; }).split("").reverse().join("")+(num.split(".")[1] ? "."+num.split(".")[1] : ''); } console.log(commafy('+1234567.123')) console.log(new Date().getTime()) ``` 我的解法,。。。正则真心看不熟悉。。。还有就是原先的答案再没有小数的时候,不会有分隔符了。。bug,,而我的js函数结合正则可以规避这个bug,咳咳咳。。好吧,其实我根据运行前的时间戳和之后的时间戳相减,发现运行速度是一样的,原答案的解法更具hacking,好吧。真的好纠结不懂正则

``` class TodoStore { @observable list = [] @observable fetched = false @action emit = (url) => { this.fetched = true socket.emit(url) } @computed get on(){ socket.on('get list',(json)=>{ this.fetched =...

![image](https://user-images.githubusercontent.com/14355994/57969979-eb919300-79ad-11e9-907d-5e45edeafb39.png) ```py graph = { "A": ["B","C"], "B": ["A", "C", "D"], "C": ["A", "B", "D", "E"], "D": ["B", "C", "E", "F"], "E": ["C", "D"], "F": ["D"], } ``` `DFS` 依靠`stack`后入后出来设计深度优先....

学习

https://user-images.githubusercontent.com/14355994/233860778-e1aad3f3-2b30-493d-8c23-61b85b2b3d79.mov 这样处理的原因是因为, 当你滑到最顶部再 push 元素, 会直接定位到顶部, 需要`scrollIntoView` 到之前的位置. ```ts export function ContentComponent() { const scrollEl = useRef(null); const [distanceToBottom, setDistanceToBottom] = useState(null); // handle scroll event function, when scroll trigger...

react

# 如何自定义一个 hooks 谁都用过 `useState`, `useEffect`, `useReducer`, 但为了更好的了解 react, 下面决定写一个 自定义 hooks.

学习
看书
项目架构
react

### 前言 electron通过钩子函数,原本是直接加载index.html静态资源,但是在开发模式下,非常不便,每次都要重启electron. ### 设想的解决方案 fs的nodejs模块,实际上是基于ftp协议加载文件, 如果是通过http协议加载, 那么连接便是`https://localhost:443`,而我通过nodejs开一个小型服务器.并且,这样就能通过http网络协议连接electron端与react+webpack端沟通了.既然如此,何不利用nodejs - http2协议的服务端主动push功能,来热更新index.html静态资源呢,这非常强大呢. ### http2模块 http2底层实现原理是非常复杂的,了解即可,如果要自己实现,麻烦不说,性能不见得会好. ### http2 - nodejs API ```js const http2 = require('http2'); const fs = require('fs'); const port =...

HTTP