ls
ls
> Javascript 完全套用了 Java 的位运算符,包括按位与`&`、按位或`|`、按位异或`^`、按位非`~`、左移``和用0补足的右移`>>>`。 > 这套运算符针对的是整数,所以对 Javascript 完全无用,因为 Javascript 内部,所有数字都保存为双精度浮点数。如果使用它们的话,Javascript 不得不将运算数先转为整数,然后再进行运算,这样就降低了速度。而且"按位与运算符"`&`同"逻辑与运算符"`&&`,很容易混淆。 上面的一段文字来源于一篇比较老的博文[http://www.ruanyifeng.com/blog/2010/01/12_javascript_syntax_structures_you_should_not_use.html](http://www.ruanyifeng.com/blog/2010/01/12_javascript_syntax_structures_you_should_not_use.html)。说的并没太错,但是却没有告诉我们到底会降低多少速度,“"按位与运算符"`&`同"逻辑与运算符"`&&`,很容易混淆”,真的容易混淆吗?(博主是自己很钦佩的一个前辈,自己接下来主要是想分享一些 JS 可能不常用的技巧(理解了以后就常用了:p)) ## 到底会慢多少? 先拿一个位运算左移`> 2 } console.timeEnd('>>2'); ``` 结果:我的浏览器是 Chrome,MBP15(13年),发现循环10000000次也仅相差不到 5ms。而且你发现多刷新一次,发现直接整数乘法或除法和左移右移谁快谁慢是不确定的,反正相差无几。 ``` *2: 29.870ms 2: 27.841ms...
# 光源 ## 各种光源 Three.js 提供了以下一系列光源,每种光源都有其特殊的行为和用途。 | 光源名称 | 描述 | |---|---| | AmbientLight ['æmbɪənt] (环境光) | 这是最基础的光源,它的颜色会添加到整个场景和所有对象的当前颜色上 | | PointLight (点光源) | 空间中的一个点,朝所有的方向发射的光线 | | SpotLight (聚光灯光源) | 这种光源有聚光效果,类似手电筒...
参考:[https://medium.com/webpack/webpack-3-official-release-15fd2dd8f07b](https://medium.com/webpack/webpack-3-official-release-15fd2dd8f07b) ## Scope Hoisting Scope Hoisting 译为 作用域提升,它是 Webpack 3 最大的一个新功能。曾经的 Webpack 是将每一个模块(每一个被 import 或者 require 的那个东西)bundle 到每一个一个独立的闭包函数里。这会导致 bundle 的文件里,每一个模块最外层都会有一些其特殊的闭包包装,导致文件体积增大,同时它也会让 JS 在浏览器执行变慢(因为多了一层函数的包装)。  Webpack 3 可以如此开启 Scope Hoisting ```js module.exports...
[图像颜色提取](https://codepen.io/zhaojun/post/cc) [https://aframe.io/docs/0.5.0/introduction/entity-component-system.html](https://aframe.io/docs/0.5.0/introduction/entity-component-system.html)
# 更新 URL.createObjectURL 🐂 https://developer.mozilla.org/zh-CN/docs/Web/API/URL/createObjectURL --- 业务有个需求,要做图片预览上传,过去都是客户端上传给后端,后端返回`url`前端进行预览,现在其实可以不依赖后端做预览,最后在上传,这主要依赖`FileReader`和`FormData`这两个对象和 JavaScript 处理二进制的能力。 OK,Show code~,以下代码已注释掉具体业务逻辑和实现,如果需要了解 API 细节,可以请参考: - [https://developer.mozilla.org/en-US/docs/Web/API/FileReader](https://developer.mozilla.org/en-US/docs/Web/API/FileReader) - [https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData) - [https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob) - [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) ## 监听表单文件变化 文件表单的样式主要通过让它后面,通过别的DOM来美化它。 ``` html ``` ``` js input.on('change',...
HTTPS
https://certbot.eff.org/#ubuntuxenial-nginx ``` server { listen 443 ssl; server_name blog.lishengcn.cn; root /home/ubuntu/blog; ssl_certificate /etc/letsencrypt/live/lishengcn.cn/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/lishengcn.cn/privkey.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL; location /api { rewrite ^.+api/?(.*)$ /$1 break;...
[Mobdux: Combining the good parts of MobX and Redux](https://medium.com/@cameronfletcher92/mobdux-combining-the-good-parts-of-mobx-and-redux-61bac90ee448) [The State of CSS 2017](http://ryanogles.by/css/javascript/2017/05/25/the-state-of-css.html?utm_source=frontendfocus&utm_medium=email) [Node.js 8: util.promisify()](http://2ality.com/2017/05/util-promisify.html) [Node.js Child Processes: Everything you need to know](https://medium.freecodecamp.com/node-js-child-processes-everything-you-need-to-know-e69498fe970a) [Reducing our Redux code with...
https://github.com/GoogleChrome/ui-element-samples http://cizixs.com/2016/12/12/restful-api-design-guide https://segmentfault.com/p/1210000008684553?utm_source=weekly&utm_medium=email&utm_campaign=email_weekly http://mp.weixin.qq.com/s/6DPJbLZI06H5h08zGEFYOA
https://www.twilio.com/blog/2017/02/send-messages-when-youre-back-online-with-service-workers-and-background-sync.html http://blog.webkid.io/image-processing-in-javascript/ https://csswizardry.com/2017/02/base64-encoding-and-performance-part-2/ https://medium.com/web-on-the-edge/manifoldjs-is-becoming-pwa-builder-to-simplify-building-progressive-web-apps-49bff31f9380#.jzsfkjcjj
http://blog.csdn.net/leonzhouwei/article/details/8447643 > 原因是 Excel 以 ANSI 格式打开,不会做编码识别。 ## 解决方法 ```js function downloadCSV(fileName, content) { let a = document.createElement('a'); let file = URL.createObjectURL((new Blob(['\uFEFF' + content], { type: 'text/csv;charset=utf-8' }))); a.href...