zgrbsbf的专栏

私信 关注
书剑若水
码龄9年
  • 331,396
    被访问量
  • 138
    原创文章
  • 26,943
    作者排名
  • 13
    粉丝数量
  • 于 2012-05-20 加入CSDN
获得成就
  • 获得29次点赞
  • 内容获得25次评论
  • 获得40次收藏
荣誉勋章
  • 最近
  • 文章
  • 资源
  • 问答
  • 课程
  • 帖子
  • 收藏
  • 关注/订阅

自己编译个模板

以前自己也写过编译模板的东西,但是时间长就忘记了。。。今天看到了相关的东西,就又动手写了写。const supplies = ['a', 'b'];const wm=123;let template = ` <%= wm %> <!--注释--><ul> <% for(let i=0; i < supplies.length; i...
原创
32阅读
0评论
0点赞
发布博客于 2 年前

前端性能优化 —— 前端性能分析

还有这种操作function performanceTest() { let timing = performance.timing, readyStart = timing.fetchStart - timing.navigationStart, redirectTime = timing.redirectEnd - timing.redirectStart,
转载
252阅读
0评论
0点赞
发布博客于 3 年前

鼠标掠过iframe事件mousemove

在父页面中绑定了mousemove,但是鼠标经过iframe的时候却没有触发事件,只要加上一点css就好了iframe { pointer-events:none; }
原创
3795阅读
3评论
5点赞
发布博客于 4 年前

react使用useContext实现兄弟组件通信

两个兄弟input通信,实现输入同步无useReducer版本<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></sc
原创
620阅读
0评论
0点赞
发布博客于 7 月前

取消fetch请求

const controller = new AbortController();const signal = controller.signal;// API responds after 5s// Note the 'signal' in the second argumentfetch('https://slowmo.glitch.me/5000', { signal }) .then(r => r.json()) .then(response => console.lo
转载
78阅读
0评论
0点赞
发布博客于 7 月前

尺寸大小不固定图片在一个不固定大小的容器中保持原比例水平垂直居中

请注意,是图片居中,不是img标签居中,<style> *{ padding:0; margin:0; } body{ width:100%; height: 100vh; } img{ background: red; width:100%; he
原创
113阅读
0评论
0点赞
发布博客于 7 月前

try catch promise.reject

突发奇想,测试了下面的一段代码,function f() { try{ Promise.reject('我错了'); }catch(e){ console.log('e',e); }}f();结果没有catch,我就不明白了,到底为什么。难道Promise.reject是异步?我问别人,有人告诉我是因为异步,但是我认为不是...
原创
1547阅读
2评论
0点赞
发布博客于 7 月前

You have no right to access this object because of bucket acl.

原创
628阅读
1评论
0点赞
发布博客于 8 月前

svelte与CustomEvent

在svelte中下级给上级发射事件一般是这种形式: import { createEventDispatcher } from "svelte"; const dispatch = createEventDispatcher(); dispatch("myevent", { });而 createEventDispatcher 的源码中使用了一个自定义函数custom_event...
原创
83阅读
0评论
0点赞
发布博客于 2 年前

多出文字显示点点点-webkit-line-clamp

以前以为文字多了显示点点点只能用WTO,但是WTO处理多行不方便,今天学到一个新的:-webkit-line-clamp <style> p { width: 300px; display: -webkit-box; -webkit-box-orient: vertical; ...
原创
55阅读
0评论
0点赞
发布博客于 2 年前

希望nginx不发生301在url后面加斜杠

浏览器访问一个页面,http://abc.com/fanglu-h5,nginx这么配置:server { listen 80; server_name abc.com; location /fanglu-h5 { root /home/ctivity/; index index.html; }}发生301.如下图所示:不想让他这样...
原创
451阅读
0评论
0点赞
发布博客于 2 年前

node.js接收前端上传的文件

打算前端传文件给后端node,前端使用formdata,尝试使用koa的multer包来做,但是老是报错, MulterError: Unexpected field在网上找了半天,不知道怎么直接用node(不用框架和第三方包)从request中解析出来文件,所以自己想了个方法变换一下来做,很简单,特此记录。「Talk is cheap. Show me the code」0 前端代码...
原创
983阅读
1评论
2点赞
发布博客于 2 年前

angular依赖注入providedIn与懒加载的问题循环依赖

1. providedIn: ‘root’The @Injectable() decorator has the providedIn metadata option, where you can specify the provider of the decorated service class with the root injector, or with the injector for...
原创
769阅读
0评论
1点赞
发布博客于 2 年前

javascript中的同步迭代和异步迭代

所谓的迭代,用过es6的兄弟肯定已经接触过了,比如arr是一个数组,**[…arr]**还有for of 循环都是的。我说一说他背后的东西。同步迭代The interfaces for sync iteration ,借助typescript来写:interface Iterable { [Symbol.iterator]() : Iterator;}interface Iter...
原创
650阅读
0评论
0点赞
发布博客于 2 年前

使用node杀死linux进程及子进程们

用linux 写了打包脚本,想要杀死正在跑着的打包程序,但是直接用linux的命令就是杀不死,无奈只能改成node试一试,#! /home/broly/.nvm/versions/node/v10.15.1/bin/nodelet {exec} = require('child_process');let {promisify} = require('util');let exec2 = ...
原创
479阅读
0评论
1点赞
发布博客于 2 年前

javascript深度广度遍历DOM及二叉树以及求深度

console.log('深度'); function d(e) { console.log(e); const ren = e.children; // 如果是二叉树,则 // const ren =[e.left,e.right].filter(ei=>!!ei); if (ren.length) { Array.from(ren...
原创
80阅读
0评论
0点赞
发布博客于 2 年前

Generator + Promise实现async+await的效果

很久以前用koajs 1的时候也看过co库的核心源码,后来不用了,前段时间又涉及到了相关的问题,特地重新学习一下, koajs 1 中如何实现的async await的效果。首先,2个基本知识:Promise.resolve flattens nested layers of promise-like objects (e.g. a promise that resolves to a pr...
原创
181阅读
0评论
0点赞
发布博客于 2 年前

angular中组件changeDetection为ChangeDetectionStrategy.OnPush时的学习

一个angular应用是由组件树组成的,changeDetection是其中比较深的部分,我也不懂哈。angular中changeDetection中的策略有这样的描述:总而言之,对于一个组件而言,2中changeDetection策略,默认的没啥好说的,主要说一下OnPush的情况。如果子组件的属性的变化由输入属性决定,那么这个时候就可以启用OnPush这种变更检测策略,这样输入属性不变的...
原创
2968阅读
0评论
2点赞
发布博客于 2 年前

angular中的RouteReuseStrategy的学习小记

惭愧,看了别人用vue写出了返回不需要刷新的效果才想到在angular中实现,才有了这次的学习。就是想要返回不刷新1. angular中RouteReuseStrategy是这样的:abstract class RouteReuseStrategy { abstract shouldDetach(route: ActivatedRouteSnapshot): boolean abst...
原创
1281阅读
2评论
0点赞
发布博客于 2 年前

javascript和dart中for循环里面异步任务promise和future

最新看dart,对比学习吧。。。要实现的效果,根据一个数组,生成一个定时器,定时器n秒之后返回,串行执行。javascript版本:function getPromise({ milliseconds = 0 } = {}) { return new Promise((resolve) => { setTimeout(() => { ...
原创
491阅读
0评论
0点赞
发布博客于 2 年前

javascript和dart中函数传参数的小对比:位置参数和命名参数

1、 default values for positional parameters1.1、js版本function positional(a,b=9){ console.log('a:',a); console.log('b:',b);}console.log(`一个实参:`);positional(5);console.log(`二个实参:`);positional(...
原创
274阅读
0评论
0点赞
发布博客于 2 年前

部署sentry的过程中遇到的一些问题记录:企业微信邮件、soucemap等

0. 系统环境与安装[root@xxxxxxxxx]# uname -aLinux iz2ze7ki6m0w5zsxd5kc4jz 3.10.0-862.6.3.el7.x86_64 #1 SMP Tue Jun 26 16:32:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux[root@xxxxxxxxx]# lsb_release -aLSB Ve...
原创
1795阅读
0评论
1点赞
发布博客于 2 年前

flex和grid中容器的伪元素::before和::after生成的内容被视为一个子元素项目

一个以前不知道的知识点<style> .grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-rows: 100px 100px; grid-gap: 20px; } .flex { ...
原创
897阅读
0评论
0点赞
发布博客于 2 年前

nodemailer发邮件给腾讯企业邮箱的时候填写密码

这个密码啊,用我自己的腾讯企业邮箱的密码发送不行,可以这么搞定:邮箱设置----微信绑定----安全登录-----客户端专用密码生成一个新的就行了
原创
653阅读
0评论
0点赞
发布博客于 2 年前

More Unicode Patterns

反正就是要实现下面的类似效果,反正我之前不知道怎么做。
原创
69阅读
0评论
0点赞
发布博客于 2 年前

Require Function Parameters 和 Get Query String Parameters

Require Function ParametersBeing able to set default values for function arguments was an awesome addition to JavaScript, but check out this trick for requiring values be passed for a given argument:...
转载
200阅读
0评论
0点赞
发布博客于 2 年前

Fading out siblings on hover in CSS

原文连接:https://www.trysmudford.com/blog/fade-out-siblings-css-trick/要实现下面这样的效果:通常,会把hover事件加在card1,card2,card3上,但是通过加在父元素上也可以实现。初始代码如下: <style> .parent { display: flex; heigh...
原创
64阅读
0评论
0点赞
发布博客于 2 年前

javascript中Rest/Spread与Object.assign的不同

ES6中的Rest/Spread使用的很广泛了,比如简单的(浅)复制一个数组:const arr1 = [10, 20, 30];// 复制一下const copy = [...arr1];console.log(copy); // [10, 20, 30]再比如给一个函数传递参数,参数需要一个个地传递,现在参数都在一个数组里面:const arr = [10, 20,...
原创
180阅读
0评论
0点赞
发布博客于 2 年前

简单学习rxjs中map、concatAll、concatMap、mergeAll、mergeMap、switchAll、switchMap

1、mapmap和javascript中的数组的map方法类似,不过这里为了结合下面的demo,我先用map做一个我们不想要的效果: const getData = (param) =&gt; { return of(`return: ${param}`).pipe( delay(Math.random() * 1000) ) }; from([1, ...
原创
5376阅读
0评论
3点赞
发布博客于 2 年前

rxjs中的throttle、throttleTime、debounce、debounceTime、audit、audtiTime

1、debounceTimeEmits a value from the source Observable only after a particular time span has passed without another source emission.大意是,只有在指定的时间间隔内没有产生另外的数据的时候,之前产生的数据才能被observable发射出来。marble diag...
原创
3790阅读
0评论
0点赞
发布博客于 2 年前

学习CSSOM

通过element.style访问或者设置行内样式 div { width: 100px; height: 100px; background-color: rgb(255, 255, 0); } // 下面是div的结构 &amp;amp;amp;amp;lt;div&amp;amp;amp;amp;gt; 我是div里面的内容哦&amp;amp;amp;amp;lt;/div&amp;amp;amp;amp;
原创
302阅读
0评论
1点赞
发布博客于 2 年前

angular开发项目文件系统打开后base路径和background图片路径找不到的问题

1、删掉base标签,也不要动态写入2、背景图片改成相对路径,我发现这样会直接编译成base64格式的 background: url(…/…/…/assets/apply_cash_bg.png)
原创
573阅读
0评论
0点赞
发布博客于 3 年前

nginx rewrite导致post问题

问题背景开始的时候前端用的3000端口发的post请求到node,node做了检测要求必须用post,不能用get,这个时候前端请求的接口是xxxx:3000/servers, 但是前端是用nginx部署在81端口的,这导致请求老是发2次,看起来不好看。尝试解决把前端请求的接口改成xxxx:81/api/servers ,用nginx做一次转发,开始是这么写的nginx的配置: locat...
原创
4886阅读
0评论
0点赞
发布博客于 3 年前

mongo 4 中事务的简单学习

我也的mongo的版本是4.0.4这是一个新增的功能,以前不支持事务1. run-rs与replica set事务操作如果连接的mongo不是副本集的话,会报错:Transaction numbers are only allowed on a replica set member or mongos所以还要想办法弄个副本集出来,为了方便,使用了run-rs这个npm包,开启副本集...
原创
5198阅读
0评论
0点赞
发布博客于 3 年前

mongodb设置用户名和密码并用node连接

我用的mongo的版本是4.0.41、设置用户名和密码1.1 设置admin库的用户名密码&gt; show dbsadmin 0.000GBconfig 0.000GBlocal 0.000GBxxxx 0.000GB&gt; use adminswitched to db admin&gt; db.createUser({ user: "admin", pw...
原创
1925阅读
0评论
0点赞
发布博客于 3 年前

魔法CSS(1)——消失的list-style

来源:https://segmentfault.com/a/1190000016969667?utm_medium=hao.caibaojian.com&amp;utm_source=hao.caibaojian.com&amp;share_user=1030000000178452&lt;ul&gt; &lt;li&gt; &lt;p&gt;啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊...
转载
89阅读
0评论
0点赞
发布博客于 3 年前

学习CSS Scroll Snapping与scroll-snap-align

假如有个Web页面是一块一块的,如下图所示:我们希望可以一块一块的滚动,比如当前一个块滚出去了一部分并且后一个块滚进来一部分的时候,实现后一个块自动滚入或者前一个块回弹到初始位置这种效果,以前的时候用js需要写比较复杂的判断逻辑,后来有了一个css scroll snap这个方法,可以比较方便的实现想要的效果了,基本够用。基本页面css代码:ul { max-height: ...
原创
943阅读
0评论
1点赞
发布博客于 3 年前

自定义html5中的details元素

html5中的details的功能很好,但是默认的样式不好看…尝试修改。::-webkit-details-marker伪元素修改 summary前面的三角形summary的::before和::after伪类制作一个 + - 表示的开关使用details的open属性选择器在开关之间进行却换下面是样式文件: ::-webkit-details-marker { ...
原创
940阅读
0评论
1点赞
发布博客于 3 年前

html的dialog标签元素

以前的时候为了在页面上做出dialog效果往往很复杂,还要写遮罩层,用CSS 写 好多代码,不过刚刚知道html中原生也支持dialog。标准用法 &lt;dialog open&gt; &lt;h1&gt;你好&lt;/h1&gt; &lt;/dialog&gt;可以通过改变open属性,来显示或者隐藏,如上图所示。也可以使用dialog的show方法或者close方法...
原创
1654阅读
1评论
1点赞
发布博客于 3 年前

win10通过samba实现在主机中开发虚拟机中编译

因为我是进行前端开发的,所谓的编译是指的是编译angular项目公司的平台基于angular搭建了前端开发环境,开发的时候要开启一个类似angular中ng start的命令,所有的一切麻烦都是这个命令引起的。公司开发的不支持windows系统,而我使用的是win10,不想换mac,于是我就开始了折腾。。。尝试1:使用win10的linux子系统wsl那好啊,反正win10里面可以使用...
原创
529阅读
0评论
0点赞
发布博客于 3 年前

pngquant failed to build, make sure that libpng-dev is installed

sudo apt-get install libpng-dev npm install -g pngquant-bin 如果还不行,再加上: sudo apt-get install -y build-essential libpng-dev
原创
14884阅读
4评论
1点赞
发布博客于 3 年前

angular使用class-interface获取父组件和祖先组件

在angular中,并没有现成的方法获取父组件,但是: because every component instance is added to an injector’s container, you can use Angular dependency injection to reach a parent component. 那么,如果父组件能在依赖注入中把自己当作一个服务注入,后代就能...
原创
1359阅读
0评论
1点赞
发布博客于 3 年前

angular动态组件与内容投影二

不是我的原创,也不是不是我的原创,是在理解原文的基础上修改而来的,还对某些api进行了升级可以使用容器的createComponent方法来创建组件,但是这个方法还可以有甚多别的参数,比如传递服务参数和内容投影参数,这次就学习下。如我们有一个组件AdvComponent,希望当鼠标放上的时候动态创建一个组件TooltipComponent,TooltipComponent中还包括一个内容投...
原创
1055阅读
0评论
0点赞
发布博客于 3 年前

angular中动态创建组件(一)

最近做东西用到了大量动态组件相关的知识,先总结一下一种比较简单的。已经有了一个组件,AppComponent,也有一个将要动态创建的组件MsgComponent,@Component({ selector: 'msg', template: ` &amp;amp;lt;h3&amp;amp;gt;{{type}}&amp;amp;lt;/h3&amp;amp;gt; `})export class MsgComponent ...
原创
5237阅读
1评论
0点赞
发布博客于 3 年前

angular中服务b依赖服务a如何export

1.服务b依赖与服务a的一般情况一个模块中的一个一个组件,AbComponent,其中需要注入服务BService。import {Component} from '@angular/core';import {BService} from './b.service';@Component({ template: ''})export class AbComponent {...
原创
821阅读
0评论
0点赞
发布博客于 3 年前

angular中使用viewchild访问DOM、子组件和指令的学习

angular中的viewchild提供了访问从组件中访问模板中书写的DOM、子组件和指令的功能。0. 基础知识ViewChild Property decorator that configures a view query. The change detector looks for the first element or the directive matching...
原创
2275阅读
0评论
0点赞
发布博客于 3 年前

angular input binding 输入型绑定 Content Projection 内容投影

通过输入型绑定可以把把数据从父组件传到子组件。官网的demo比较简单,我试的时候发现父组件不仅可以传递一个普通的属性给子组件,还可以是函数的运行结果,而且这个函数的结果还是不断的变化的。好神奇。在这里设计2个组件,父组件中在input框中输入值,传递给子组件,同时还传递一个对象和一个函数的运行结果。父组件的主要代码:parentSimple = '123';parentObject ...
原创
909阅读
1评论
0点赞
发布博客于 3 年前

angular属性绑定绑定函数,插值表达式插函数,ngIf绑定函数

以前认为angular属性绑定的时候只能绑定属性,官网上也没说能绑定函数,看同事代码的时候被惊呆了,可以绑定函数,而不仅仅是属性,可以绑定函数,而不仅仅是属性,可以绑定函数,而不仅仅是属性,整理一下相关的用法。没想到angular里面还可以这样。import {Component} from '@angular/core';@Component({ templateUrl: './fun...
原创
2551阅读
1评论
0点赞
发布博客于 3 年前

clip-path的学习和简单使用

遇到一个情况,图片太长需要截短一些,开始用了clip,后来发现这个属性已经从CSS标准里面删除了,然后看到了clip-path,发现这个比较强大一些。 我用的图片的大小是600*774clip-path裁剪出圆形 clip-path:circle(40% at 200px 200px);效果如下: 40%是半径,at后面的参数是圆心。clip-path 裁...
原创
1205阅读
0评论
1点赞
发布博客于 3 年前

Element dimensions

offset dimensionsall of the visual space that an element takes up on the screen. including all padding, scrollbars , and borders ( but not including margins ). client dimensionsthe space occ...
原创
78阅读
0评论
0点赞
发布博客于 3 年前

angular中的HostBinding与HostListener

水平浅,各位看官不要见怪 In Angular, the @HostBinding() function decorator allows you to set the properties of the host element from the directive class. In Angular, the @HostListener() function decorator...
原创
1167阅读
0评论
0点赞
发布博客于 3 年前

记录使用es6模块的一次错误以及与commonjs规范中模块的区别

先看commonjs规范中的代码: a102.js中代码:function fun(){ console.log('fun');}// export {fun}setTimeout(fun,1000)exports.fun=fun;a101.js中代码:let fun=require('./a102').fun;fun=function(){ console.l...
原创
319阅读
0评论
0点赞
发布博客于 3 年前

HTML attribute vs. DOM property

The distinction between an HTML attribute and a DOM property is crucial to understanding how Angular binding works.Attributes are defined by HTML. Properties are defined by the DOM (Document Object ...
转载
129阅读
0评论
0点赞
发布博客于 3 年前

Professional JS for Web Developers (third edition) 随手笔记(1)前4章

2 JavaScript in HTMLdeferred scriptsthe purpose of defer is to indicate that a script won’t be changing the structure of the page as it executes. Setting the defer attribute on a Asynchronous ...
原创
146阅读
0评论
0点赞
发布博客于 3 年前

Channel Messaging与structured clone

才疏学浅,以前没听过structured clone(结构化克隆)这个词语,最近才看到。Channel Messaging API ,允许附着在同一个文档上的两个运行在不同上下文的脚本直接通信。window下的postMessagepostMessage这个东西以前也用过,比如下面这个demo所示的用法:我用的webstormindex.html嵌套一个iframe,在inde...
原创
180阅读
0评论
0点赞
发布博客于 3 年前

学习service worker之一:两种更新

下面把学习的过程中遇到的问题和感悟记录如下: 我用的webstorm一个页面,引入了index.js,index.js的代码如下:navigator.serviceWorker .register('./sw.js') .then(function (reg) { console.log('Service Worker Registered')...
原创
2466阅读
0评论
0点赞
发布博客于 3 年前

popstate

今天测试一个h5中的popstate事件,虽然我很久之前就对这个新属性有所学习, https://blog.csdn.net/zgrbsbf/article/details/25297359 无奈今天还是犯了几个小错误,记录如下:错误:https://developer.mozilla.org/en-US/docs/Web/Events/popstate 这篇文章中说, ...
原创
768阅读
0评论
0点赞
发布博客于 3 年前

chrome 66 让事件侦听器的断点更好用

使用的是angular 5开发的时候如果使用了一个js库或者前端框架,调试的时候想添加事件监听,但是断点会停在这些库或者框架里面,不是我们想要的效果,比如下面的例子: ‘添加’按钮上面绑定了一个click事件, 先设置click的断点,然后点击”添加”,停下了,如下图2: 但是停在了angular的框架里面,我想让他暂停在我写代码的地方,怎么做到呢: 在图1的右侧的箭头...
原创
554阅读
0评论
0点赞
发布博客于 3 年前

Destructuring解构javascript与python

python版的:a, (b, [c, d]) = (1, [2, iter((3, 4))])print(a, b, c, d)head, *tail=(1,2,3)print(head,tail)js版的:let [a, [b, [c, d]]] = [1, [2, [3, 4]]];console.log(a, b, c, d);let [head, ......
原创
278阅读
0评论
0点赞
发布博客于 3 年前

深入浅出node.js第9章玩转进程摘录

9.1 服务模型的变迁9.1.1 石器时代:同步9.1.2 青铜时代:复制进程9.1.3 白银时代:多线程9.1.4 黄金时代:事件驱动9.2 多进程架构node提供了child_process模块,我们再将经典的示例代码存为worker.js文件,如下:let http=require('http');http.createServer(fu...
原创
119阅读
0评论
0点赞
发布博客于 3 年前

node.js私有连智能合约开发学习1

使用的win101、安装geth1.1 启动一个私有链geth --rpc --rpcport "8545" --rpcapi "eth,web3,personal,net" --rpccorsdomain * console 2&gt;&gt;test.log --dev如下图所示: 参数解析:–rpc:激活节点上的RPC–rpcapi:配置什么...
原创
453阅读
0评论
0点赞
发布博客于 3 年前

win10 小娜cortana搜索网页使用自定义浏览器

看下面: https://www.makeuseof.com/tag/force-cortana-use-chrome-google-windows-10/
原创
5497阅读
0评论
0点赞
发布博客于 3 年前

Fatal: Unable to attach to remote geth: no known transport for URL scheme "c"

我的系统是win10,geth的版本是 1.8.2-stable-b8b9f7f4按照http://www.cnblogs.com/huyouhengbc/p/5922093.html 的示例,尝试写智能合约的时候,C:\Users\myname&gt;geth attachFatal: Unable to attach to remote geth: no known transpo...
原创
1666阅读
0评论
2点赞
发布博客于 3 年前

深入浅出node.js第4章异步编程摘录

4.1函数式编程4.2异步编程的优势与难点4.2.1 优势node带来的最大特性莫过于基于事件驱动的非阻塞I/O模型,这是他的灵魂所在。 在第3章中,我们讨论过node实现异步I/O的原理。利用事件循环的方式,js线程就像一个分配任务和处理结果的大管家,io线程池里的各个io线程都是小二,负责完成分配来的任务,小二与管家互不依赖,所以可以保持整体的高效率。缺点是管家无法承担过...
原创
111阅读
0评论
0点赞
发布博客于 3 年前

深入浅出node第3章异步I/O摘录

3 异步I/O3.1 为什么要异步I/O3.1.1 用户体验//消费时间为mgetData('from_db')//消费时间为ngetData('from_remote_api')getData('from_db',function(re){//消费时间m});getData('from_remote_api',function(re){//消费时间n...
翻译
214阅读
0评论
0点赞
发布博客于 3 年前

https建立安全连接,tls握手协商过程的疑问

查看了很多讲解https的东西,最后总结如下:The client sends a “Client hello” message to the server, along with the client’s random value(RAlice) and supported cipher suites.该过程为明文。The server responds by sending a “...
原创
796阅读
0评论
0点赞
发布博客于 3 年前

学习koa

koa的版本是2.5.0源demo来自http://koajs.com 第一次写这种东西,最起码让我自己看懂吧!最原始的简单的node的http服务器就像下面这样: var http = require('http');//create a server object:http.createServer(function (req, res) { res.wr...
原创
125阅读
0评论
0点赞
发布博客于 3 年前

pm2开机重启node程序

上次linux服务器宕机,node程序没重启,看到网上说啥的都有,亲自测试了一下: node的版本是9.6.1,pm2的版本是2.10.1首先启动node程序 然后pm2 save,输出类似下面的东西[PM2] Saving current process list...[PM2] Successfully saved in /root/.pm2/dump.pm2最后pm2 ...
原创
3267阅读
0评论
0点赞
发布博客于 3 年前

yum update错误Couldn't resolve host

Loaded plugins: fastestmirror, securitySetting up Update ProcessDetermining fastest mirrorshttp://xxx.com:8050/Centos/6/base/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolv...
原创
322阅读
0评论
0点赞
发布博客于 3 年前

nginx中rewrite常用全局变量

摘抄自nginx高性能web服务器详解 变量 说明 $args 存放了请求url中的请求指令。比如http://www.myweb.name/server/source?arg1=value1&amp;arg2=value2中的arg1=value1&amp;arg2=value2 $content_length 存放请求头中的Content-length...
原创
950阅读
0评论
0点赞
发布博客于 3 年前

第三方app微信登录

Created with Raphaël 2.1.2人人超级游戏超级游戏微信微信代理层代理层登录请求授权,scope,state...确认?确认吊起,code请求人的信息,带code请求access_token(code,appid,secert,grant_type=authorization_code)返回access_token,openid请求人的信息(access_token,openi
原创
367阅读
0评论
0点赞
发布博客于 3 年前

node访问某个ip下的某个server

看前人的项目,实现的是一个访问某个ip的某个server的功能,他们用了privoxy和node来实现的,如果纯用node的话,可以使用http.request方法,这样就不用安装别的东西了。下面的这个就是访问127.0.0.1上的abc.com的一个demo。let querystring=require('querystring')let http=require('http');
原创
199阅读
0评论
0点赞
发布博客于 3 年前

javascript中的marotask与microtask与事件循环

setTimeout(function(){ console.log('定时器开始啦') });new Promise(function(resolve){ console.log('马上执行for循环啦'); for(var i = 0; i &amp;amp;lt; 10000; i++){ i == 99&amp;amp;amp;&amp;amp;amp; resolve(); ...
原创
308阅读
0评论
0点赞
发布博客于 3 年前

positive definite matrix

positive definite matrixA positive definite matrix is a symmetric matrix with all positive eigenvalues. Note that as it’s a symmetric matrix all the eigenvalues are real, so it makes sense to talk a
转载
1672阅读
0评论
1点赞
发布博客于 3 年前

rsync的@ERROR: Unknown module xxx 错误

搞了好几个小时@ERROR: Unknown module 'xxx'rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]原因如下:rsyncd.conf中的对应项目的hosts allow属性写错了,那你也应该提示host被禁止啊,为什么提示unkno
原创
9112阅读
0评论
0点赞
发布博客于 3 年前

javascript与python的生成器(Generators)实例

斐波那契数列先来js版的function* fibon(n) { let a = b = 1; for(let i=1;i<= n;i++) { yield a; [a, b] = [b, a + b]; }}for(let v of fibon(10)){ console.log(v);}再来py版的def fibon(n): a = b = 1
原创
149阅读
0评论
0点赞
发布博客于 3 年前

javascript与python的rest 参数实例

先来js版的不定参数function test_var_args(f_arg,...argv) { console.log('first normal arg:',f_arg); for(let arg of argv){ console.log("another arg through *argv:", arg); }}test_var_args('yasoob', 'py
原创
269阅读
0评论
0点赞
发布博客于 3 年前

named capture groups

const pattern = /(?\d{4})-(?\d{2})-(?\d{2})/u;const result = pattern.exec('2017-12-15');// result.groups.year === '2017'// result.groups.month === '12'// result.groups.day === '15'参考文献:https
转载
179阅读
0评论
0点赞
发布博客于 4 年前

安装nginx同时安装redis2-nginx-module模块

安装rediswget http://download.redis.io/releases/redis-3.2.9.tar.gztar xzf redis-3.2.9.tar.gzcd redis-3.2.9make下载nginx及其redis模块wget -c https://nginx.org/download/nginx-1.10.1.tar.gz  接下...
原创
2817阅读
0评论
0点赞
发布博客于 4 年前

判断横竖屏的一个小方法

var mql = window.matchMedia("(orientation: portrait)");function onMatchMeidaChange(mql){    if(mql.matches) {        // 竖屏    }else {        // 横屏    }}onMatchMeidaChange(mql);mql.ad
转载
144阅读
0评论
0点赞
发布博客于 4 年前

// Error: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on

// Error: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about
转载
149阅读
0评论
0点赞
发布博客于 4 年前

mongodb的aggregate实例1

好不容易写的,得记录一下,免得找不到了[ { $match: { "from": 'h5player', 'code': {$in: ['init']} } }, { $group: { "_id": { code: '$code', 'cost': { $switch:
原创
134阅读
0评论
0点赞
发布博客于 4 年前

迁移mongodb数据库 版本3.0.6

因为a服务器要关闭了,但是上面有个mongodb,要把他迁移到b服务器上。两个机器上的moongodb版本都是3.0.6假设a的ip和端口是是a.a.a.a:a  ,要迁移的a的数据库中的一个是jscss在b服务器上执行下面的命令1、./mongodump -h  a.a.a.a:a -d jscss -o /abc/bak     这句话就把a上面的jscss数据库备份到了b的/
原创
239阅读
0评论
0点赞
发布博客于 4 年前

closures and variables

There is one notable side effect of this scope-chain configuration. The closure always gets the last value of any variable from the containing function.Remember that the closure stores a reference to
转载
83阅读
0评论
0点赞
发布博客于 4 年前

closures

Closures are functions that have access to variables from another function's scope. This is often accomplished by creating a function inside a function:function createComparisonFunction(propertyName
转载
88阅读
0评论
0点赞
发布博客于 4 年前

execution context and scope

The concept of execution context, referred to as context for simplicity, is of the utmost importance in JavaScript. The execution context of a variable or function defines what other data it has acces
转载
114阅读
0评论
0点赞
发布博客于 4 年前

the constructor pattern

function sayName(){alert(this.name);}function Person(name,age){this.name=name;this.age=age;this.sayName=sayName;}var person1=new Person('nic',29);To create a new instance of Pers
转载
75阅读
0评论
0点赞
发布博客于 4 年前

内部使用的解析require

RegExp.escape = function (s) {return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');};let hh=['','-','=','+',"{",'[','(','*',"~","/","%",">","var fs = require('fs');var file = './code.js';var
原创
161阅读
0评论
0点赞
发布博客于 4 年前

chrome64的Local Overrides

这个功能就是为了对付在开发者工具中修改了东西后一刷新什么都没了的尴尬,这么操作:以调试youku的代码为例:在开发者工具中打开下面的面板:sources-->overrides-->setup overrides选择完了本地的存放目录后还需要把下面的这个勾选上才能起作用选择一个一个文件,然后修改一下,之后得按下ctrl+s
原创
2222阅读
0评论
0点赞
发布博客于 4 年前

chrome64滚动链及overscroll-behavior

overscroll-behavior的三个属性:auto:默认的情况contain:阻止滚动链none:和上一个一样,并且能阻止浏览器过渡滚动导致的Android 炫光或 iOS 回弹(Android overscroll glow or iOS rubberbanding)另外,js判断浏览器是否支持某个css属性,CSS.supports正在滚动的元素:doc
原创
441阅读
0评论
0点赞
发布博客于 4 年前

chrome64新增的Performance Monitor

chrome64中新增了一个可以多角度实时查看页面性能的开发者工具,可以这么打开:用它检测一下国内的这几个主流的视频网站的首页cpu usage的数据都是变来变去的,估计是因为各家都有大量的定时器吧。DOM 结点的数量爱奇艺的最少,但是他的JS heap size并不是按照比例最小的。以前以为爱奇艺是性能最好的,现在一看也未必啊
原创
3145阅读
0评论
1点赞
发布博客于 4 年前

element traversal

childElementCount:  returns the number of child elements (excludes text nodes and comments);firstElementChild: points to the first child that is an element.Element-only version of firstChildlastEl
转载
76阅读
0评论
0点赞
发布博客于 4 年前

javascript从jQuery中借鉴的DOM操作

用$e表示jQuery选中的元素,e表示原生js选中的元素1、在元素js中,删除一个元素往往这么干:e.parentNode.removeChild(e);就是得绕一圈,从父元素中将其删除,在JQuery中,可以直接这样:$e.remove(); 后来原生js引入了这个方法,直接这么干了:e.remove()2、insert as the new fir
原创
124阅读
0评论
0点赞
发布博客于 4 年前

Reading Property Attributes

It's also possible to retrieve the property descriptor for a given property by using the ES5 Object.getOwnPropertyDescriptor() method.This method accepts two arguments:the object on which the property
转载
116阅读
0评论
0点赞
发布博客于 4 年前

Types of Properties--Accessor Properties

Accessor properties do not contain a data value.Instead ,they contain a combination of a getter function and a setter function(thought both are not necessary).When an accessor property is read from,th
转载
134阅读
0评论
0点赞
发布博客于 4 年前

Types of Properties--Data Properties

ECMA-262 fifth edition describes characteristics of properties through the use of internal-only attributes.These attributes are defined by the specification for implementation in JavaScript engines, a
转载
105阅读
0评论
0点赞
发布博客于 4 年前

javascript中的原型与继承6--class的继承

先来一个老的继承function SuperType(name) {}function SubType(name,age) {}SubType.prototype=Object.create(SuperType.prototype);console.log(SuperType.prototype.__proto__==Object.prototype
原创
141阅读
0评论
0点赞
发布博客于 4 年前

javascript中的原型与继承5--寄生混合继承(Parasitic Combination Inheritance)

接着这篇  http://blog.csdn.net/zgrbsbf/article/details/78643523混合继承优缺点,就是SuperType的构造函数调用了两次。解决之。第二次的调用不可避免,我们从第一次入手。SubType.prototype=new SuperType();将它替换成SubType.prototype=Object.create(
原创
223阅读
0评论
0点赞
发布博客于 4 年前

javascript中的原型与继承3-混合继承(Combination Inheritance)

混合继承,又叫做伪古典继承(pseudoclassical inheritance),他就是把原型链和构造函数窃取结合在了一起,使用原型链继承属性和方法,使用构造函数窃取来得到实例属性。//例子来源于Professional JavaScript  for Web Developers,third edition ,Volume 1的209页function SuperType(name)
原创
251阅读
0评论
0点赞
发布博客于 4 年前

javascript中的原型与继承4--原型继承Prototypal Inheritance(Object.create)与寄生继承(Parasitic Inheritance)

在2006年的时候,一个叫做Douglas Crockford的哥们发明了一个新的继承方式,这种方式不需要定义构造函数。他是这么做的//210页function object(o) {function F() {}F.prototype=o;return new F();}//essentially,object() performs a shadow copy of
原创
129阅读
0评论
0点赞
发布博客于 4 年前