Neuxs 6P的意外掉电故障

去年12月起,大量Nexus6P用户遇到了在电池仍有足够电量(60%-15%)时掉电并关机的情况。从上周开始,我的手机也毫无预兆地出现了同样的问题,而且比网上大多遇到同样问题的用户更严重,意外掉电发生时的电量为50%-80%不等。

原因

在问题最初爆发时,在Reddit上就有大量用户在讨论,分析如下:

Reading through the battery issue threads, I’ve seen a few arguments about whether the early shutdown problem is due to a hardware or a software problem, so I figured it might be useful to add a bit of information about how the battery system works.
In short, the phones are probably shutting down early because the performance of the battery doesn’t match the calibration of the fuel gauge software.
The idle (no-load) voltage of a li-ion cell ranges between about 4.2V when fully charged and about 3.3V when discharged. These values vary a bit from one phone model to another, but not by much. If that was all there is to it, it would be very easy to have a reliable battery gauge, but there’s another factor:
All batteries have a certain internal resistance, and the internal resistance dictates how the battery responds when you draw power from it. When you draw current from a battery, the output voltage will sag, and it’ll recover when you stop drawing current. So the phone may show a 75% charge level and the battery may be sitting at 4.0V. You start the camera app and because the camera is relatively power-hungry, the voltage drops to 3.8V. You close the camera app and the voltage recovers to 4.0V. The higher the internal resistance, the larger the voltage drop.
The internal resistance and the resulting voltage drop is a potential problem because these phones need a certain minimum voltage to function. Even if there’s still plenty of juice inside the battery, if the momentary voltage drop is too severe, the voltage will drop below the minimum threshold and the phone will shut off.
There are several factors that have an influence on the internal resistance:
State of charge. The internal resistance goes up when the cell is discharged.
Health of the battery. Old cells have a higher internal resistance than new ones.
Temperature. The colder it is, the higher the internal resistance.
This is also why some Samsung phones won’t let you use the camera when the battery is at 5% or lower. There’s still juice in the battery, but power-hungry loads like the camera would cause an excessive voltage drop at this state of charge, and the phone would shut off prematurely.
When calculating the percentage, the fuel gauge system makes certain assumptions about the internal resistance and how the battery will perform under load, and if the predictions don’t match the reality, the phone will shut down even though the fuel gauge may still be showing 25%. It expects a small voltage drop, but the battery can’t cope with the current draw, the output voltage dips below the minimum operating voltage of the device and it shuts off.
If you’re out of warranty, a new battery would probably cure the problem since it’s going to have a lower resistance. If you want to mitigate the problem a bit, keep the phone warm and turn down the brightness of the screen.

JavaScript代码同步化

我最近一直在写js。在这期间,我在群里提的最多的问题就是

函数a在函数b执行之前就执行了,我应该怎么办?

我有一个用python写的网易云音乐的下载器,我最近在试图把它用nodejs重写一遍。
它的逻辑非常简单。但是我写了一半就写不下去了,因为一层一层的回调嵌套,代码已经成了>形。

js一个重大的特点就是异步非阻塞,但是在一些情况下,下一步的操作需要依赖上一步的执行结果。这样就会有回调中再回调的情况出现。 当业务逻辑一复杂,回调的嵌套越来越多,可读性就会变差,维护起来也会很困难,这就是回调地狱。
node有很多第三方的模块用来将异步调用同步化,来解决这个问题。

使用scrapy构建爬虫

新建一个scrapy项目

scrapy startproject spider

scrapy会初始化一个项目,项目文件包括:

  • items.py定制需要储存的文件的域,类似于orm
  • pipelines.py管道
  • settings.py设置相关参数
  • spider文件夹 定制爬虫

scrapy爬虫的组成

scarpy抓取一个页面的大致流程:

  1. 下载器下载HTTP响应内容
  2. 下载器传给执行回调函数进行解析
  3. 解析后调度器进行过滤,查重等等
  4. 将数据传给管道,作进一步处理

ubuntu升级内核及开启BBR TCP拥塞控制

最近了解到了BBR这个东西。BBR是Google开发的一种TCP拥塞控制算法。很多人反映境外的VPS用上BBR之后,速度得到了明显的提升。
如果有兴趣了解一些原理上的东西,可以参考这里:Linux Kernel 4.9 中的 BBR 算法与之前的 TCP 拥塞控制相比有什么优势?
从Linux内核4.9起,BBR已经被整合进Linux内核中,所以直接升级内核到4.9以上的版本并开启BBR模块即可。
只有KVM和Xen架构的VPS可以自行升级内核,因为OpenVZ无法进行内核层级的操作。

PHP获取微信小程序的带参数二维码

最近公司的一款产品需要用到微信小程序的带参数的二维码。虽然微信提供了现成的API,但是整个过程中有非常多的坑。
微信的官方文档:获取二维码 · 小程序

获取Access Token

获取二维码的接口需要用到应用的Access Token。只需要向微信的提供的接口发送AppIDAppSecret即可获得Access Token。每个Access Token的有效期为7200秒,我们的方案是获取到Access Token之后将其写入Redis并设置7200秒的过期时间。

Google Daydream View开箱体验

在今年10月初的Made by Google 发布会上,Google发布了早在6月的I/O大会上就提及了的Daydream VR平台。

购买

10月中旬,Daydream 已经上线包括Google Store、Verizon、BestBuy在内的美国各大线上平台。
我10月中旬在Google Store下单了一台Slate颜色的Daydream View。11月中旬从位于Mira Loma的Google仓库发货,经过4天的运输到达转运公司仓库,再经过大约10天的国际转运,清关,国内转运等等流程,在11月26号到达我的手中。
总共的花费大约是标价79刀 + 税6刀 + 运费80软妹币。

开箱

包裹和国际运单
%e6%97%a0%e6%a0%87%e9%a2%98
Daydream包装
619a2bc4993684296d809ccbc05cad53
Daydream View本体和控制器
78f61fe1cccfa249d76ba104c6f59035
Daydream控制器上有一个可点击的触控板,一个APP按钮,一个Home按钮,和音量键。使用USB C接口充电。
f65ef181fef66865d80632448fae948e

Laravel 学习笔记

安装

composer global require "laravel/installer"

Laravel 可执行文件位于$HOME/.composer/vendor/bin
使用laravel new创建新项目

laravel new blog

配置

目录权限

Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run.

Application Key

.env配置文件中设置 Application Key,它应该有32 个字符长。
使用

php artisan key:generate

生成一个key。

美化链接

Laravel自带.htaccess文件,需要开启Apache的mod_rewrite模块
– nginx配置

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

使用Composer

Composer 是 PHP 的一个依赖管理工具。它允许你申明项目所依赖的代码库,它会在你的项目中为你安装他们。

安装

curl -sS https://getcomposer.org/installer | php

让 composer 可以在全局进行调用

mv composer.phar /usr/local/bin/composer

将官方数据源修改为国内镜像

composer config -g repo.packagist composer https://packagist.phpcomposer.com