Google书签同步慢的问题
1. SwitchyOmega 中的auto switch模式中添加规则
域名通配符 *.google* 你的代理
保存后,重启浏览器
2. 打开谷歌浏览器,输入 chrome://sync-internals/
先点击 Stop Sync(Keep Data),然后再点击 Request Start
或者再点击一下 Trigger GetUpdates
Later equals never , just do now !
1. SwitchyOmega 中的auto switch模式中添加规则
域名通配符 *.google* 你的代理
保存后,重启浏览器
2. 打开谷歌浏览器,输入 chrome://sync-internals/
先点击 Stop Sync(Keep Data),然后再点击 Request Start
或者再点击一下 Trigger GetUpdates
数据量太大,使用TP6中chunk分块批量处理数据,而且需要使用多字段分组后批量处理。
使用 mysql 原生查询后,发现分组后的数据量有132298 rows。
1 |
select goods_id,goods_type,stu_id from kk_stu_node_progress where goods_type = 6 group by goods_id,goods_type,stu_id order by stu_id; |
使用chunk进行批量处理,发现一共处理了130398 rows。一共少处理了1900 行数据。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$total = Db::table('table_name')->field('concat_ws(",",goods_id,goods_type,stu_id) as kk') ->where('goods_type', 6) ->group('goods_id,goods_type,stu_id') ->select() ->toArray(); $total = array_column($total, 'kk'); Db::table('table_name')->field('goods_id,goods_type,stu_id')->where('goods_type', 6) ->group('goods_id,goods_type,stu_id')->chunk(100, function ($nodes) use (&$total) { foreach ($nodes as $node) { $value = $node['goods_id'] . ',' . $node['goods_type'] . ',' . $node['stu_id']; $total = array_diff($total, [$value]); file_put_contents(app_path('..') . 'data-1.txt', json_encode($node) . PHP_EOL, FILE_APPEND); } }, 'stu_id', 'asc'); file_put_contents(app_path('..') . 'data-1-diff.sql', json_encode($total) . PHP_EOL, FILE_APPEND); |
查看 chunk 源码,并打印关键逻辑
可以看出,chunk中的第二次开始查询下一批数据时,是根据 $lastId 来进行了排序后查找,chunk 这个方法,传入的分组条件,也就是 $column ,最好是一个确定唯一的条件。默认会使用主键。像这样如果多字段group by后,存在多个部分字段重复的情况,也就不建议使用 chunk 方法了。
1 2 3 4 5 6 7 8 9 10 11 12 |
$total = Db::table('table_name')->field('goods_id,goods_type,stu_id') ->where('goods_type', 6) ->group('goods_id,goods_type,stu_id') ->select() ->toArray(); while (!empty($total)) { //每次取出100个 $_sub = array_splice($total, 0, 100); foreach ($_sub as $node) { //处理数据 } } |
DNS污染
Step1. 查看 raw.githubusercontent.com ip地址,通过 https://www.ipaddress.com/ 来查看
Step2. 修改本地Hosts 文件,199.232.96.133 raw.githubusercontent.com
js中加密代码如下:
1 2 3 4 5 6 7 8 |
function encrypt(src, cryptoKey) { var key = window.CryptoJS.enc.Utf8.parse(cryptoKey); var encPassword = window.CryptoJS.AES.encrypt(src, key, { mode: window.CryptoJS.mode.ECB, padding: window.CryptoJS.pad.Pkcs7 }); return encPassword.ciphertext.toString().toUpperCase(); } |
php中相应代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/** * 加密字符串 */ function encrypt($data, $key) { $chiperRaw = openssl_encrypt($data, 'AES-128-ECB', $key, OPENSSL_RAW_DATA); return strtoupper(bin2hex($chiperRaw)); } /** * 解密字符串 */ public function decrypt($string, $key) { return openssl_decrypt(hex2bin($string), 'AES-128-ECB', $key, OPENSSL_RAW_DATA); } |
特别注意 bin2hex 、hex2bin 这个函数,
hex2bin() 函数把十六进制值的字符串转换为 ASCII 字符。
bin2hex() 函数把 ASCII 字符的字符串转换为十六进制值。
Happy new year,2020!
错误:MY_SOME_SIMPLME
正确:MY-SOME-SIMPLME
Nginx会将带有下划线的header头给清除掉
1 2 3 4 5 6 7 8 9 |
// Provide the body as a string. $response = $http->request('POST', $api . '?' . $build_query_data, [ 'headers' => ['Content-Encoding' => 'gzip'], 'body' => gzencode(json_encode($query)) ]); $result = json_decode($response->getBody(), true); $statusCode = $response->getStatusCode(); |
本地使用 homestead 开发,没怎么关过电脑,总是合上电脑就走,vagrant 也一直在运行,可能是由于电脑休眠的时候导致系统时间不一致。
查看电脑系统时区,date -R,发现确实与当前时间不一致
解决办法:重启vagrant
近期评论