Firebase deploy default vpcConnector vpc-Connector gcloud vpc

oooxxxoooxxx: vpc Connector name aaabbbaaabbb: your firebase project Firebase deploy default vpcConnector vpc-Connector node_modules\firebase-tools\lib\gcp\cloudfunctions.js _createFunction const data ADD vpcConnector: ‘oooxxxoooxxx’, Failed gcloud VPC VPC_CONNECTOR=dosportsapi-redis01 projects/aaabbbaaabbb/locations/us-central1/connectors/oooxxxoooxxx gcloud beta functions deploy api \ --runtime nodejs10 \ --trigger-http \ --region us-central1 \ --vpc-connector $VPC_CONNECTOR \ --egress-settings private-ranges-only \ --memory 2048MB

2020-07-23 · 1 min · 47 words · Me

[轉]同程鳳凰快取系統基於Redis的設計與實踐

https://www.luoow.com/dc_tw/104458719

2020-07-17 · 1 min · word · Me

[轉]基于Minio和Thumbor搭建独立图片服务

https://www.datayang.com/article/78

2020-07-14 · 1 min · word · Me

javascript How does the double exclamation (!!) work in javascript?

https://stackoverflow.com/questions/784929/what-is-the-not-not-operator-in-javascript https://stackoverflow.com/questions/29312123/how-does-the-double-exclamation-work-in-javascript value !value !!value false true false true false true null true false undefined true false 0 true false -0 true false 1 false true -5 false true NaN true false '' true false ‘hello’ true false

2020-07-08 · 1 min · 38 words · Me

aws FortiGate VM public / private vm Can't OutGoing. SG need setting correct.

1. aws https://www.fortinet.com/content/dam/fortinet/assets/solutions/aws/FortiGate-AWS-Engineering-Reference-Document-Q4-2015.pdf 2. https://geekdudes.wordpress.com/2018/07/18/install-fortigate-amazon-ec2-instance/ 3. https://geekdudes.wordpress.com/2018/08/19/creating-static-route-in-aws-ec2-fortigate-instance/ Many documents forget SG(security group) 1. FortiGate VM SG need Inbound rules: All traffic All All 10.0.0.0/16 2. Private VM SG need Inbound rules: All traffic All All 10.0.0.0/16 Setting finish. First fortigate cmd: execute ping Private VM private ip. Need success. Second in private vm cmd: ping FortiGate Lan ip. Need success. Don’t forgate Check “Ping” option. ping 10.0.1.1. Need success. Now ping 8.8.8.8 Must success. ...

2020-07-07 · 1 min · 126 words · Me

node.js express.js sequelize redis cache

http://liu-xin.me/2017/03/24/%E8%AE%A9%E5%86%99%E5%85%A5%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84%E6%95%B0%E6%8D%AE%E8%87%AA%E5%8A%A8%E5%86%99%E5%85%A5%E7%BC%93%E5%AD%98/``` const to = require(‘await-to-js’).default; const Redis = require(‘ioredis’); const redis = new Redis(ooxxooxx); function Cache() {} Cache.get = async function(key) { const [err, res] = await to(redis.get(key)); if (err) {console.error(‘REDIS::Cache::get]’, err); return null;} return JSON.parse(res); }; Cache.set = async function(key, value) { value = JSON.stringify(value); const [err] = await to(redis.set(key, value)); if (err) {console.error(‘REDIS::Cache::set]’, err); } }; // // sequelize.query // async function CacheSequelizeQuery(sequelize, sql, params, redisKey) { const cacheData = await Cache.get(redisKey); if (cacheData) return cacheData; // not empty return cache data ...

2020-07-03 · 1 min · 153 words · Me

node.js redis special delete del

https://github.com/luin/ioredis``` const Redis = require(‘ioredis’); const redis = new Redis(); const delScript = local all_keys = {}; local keys = {}; local done = false; local cursor = "0" repeat local result = redis.call("SCAN", cursor, "match", KEYS[1], "count", KEYS[2]) cursor = result[1]; keys = result[2]; for i, key in ipairs(keys) do all_keys[#all_keys+1] = key; end if cursor == "0" then done = true; end until done for i, key in ipairs(all_keys) do redis.call("DEL", key); end return true; ; ...

2020-07-02 · 1 min · 97 words · Me

javascript functions parm default value

https://stackoverflow.com/questions/6600868/set-default-value-of-javascript-object-attributes``` // default num: 0, unit: ‘pics’ function items(op) { const { num, unit } = Object.assign({}, { num: 0, unit: ‘pics’}, op); }

2020-06-30 · 1 min · 24 words · Me

mysql virtual colume alert

ALTER TABLE `user` ADD `last name` VARCHAR(50) AS ( case `name` when admin then 0 else CONCAT(`name`, 'user') end ) ;

2020-06-24 · 1 min · 21 words · Me

vs code vscode remote ssh Error: EACCES: permission denied

vscode remote ssh Error: EACCES: permission denied https://github.com/microsoft/vscode/issues/48659 1. make sure that sudo -u newuser -i works in a regular ssh session without requesting a password 2. remove “-o RemoteCommand=none” and “bash” from extension.js like so``` sed -i s/"-o RemoteCommand=none"/""/ ~/.vscode/extensions/ms-vscode-remote.remote-ssh-*/out/extension.js sed -i s/“bash”/""/ ~/.vscode/extensions/ms-vscode-remote.remote-ssh-*/out/extension.js 3\. create an ssh config entry with a RemoteCommand like this one: Host pi-for-newuser Hostname pi User pi RemoteCommand sudo -u newuser -i [![](https://1.bp.blogspot.com/-FXedlr85sQM/Xuw5z-9I5kI/AAAAAAAAZso/-0XXb2R1LWI7qAlYkZvN31GjVuKov9e_gCK4BGAsYHg/w625-h483/dddddd.jpg)](https://1.bp.blogspot.com/-FXedlr85sQM/Xuw5z-9I5kI/AAAAAAAAZso/-0XXb2R1LWI7qAlYkZvN31GjVuKov9e_gCK4BGAsYHg/s1606/dddddd.jpg) Get Problem: mesg: ttyname failed: Inappropriate ioctl for device [https://unix.stackexchange.com/questions/48527/ssh-inside-ssh-fails-with-stdin-is-not-a-tty](https://unix.stackexchange.com/questions/48527/ssh-inside-ssh-fails-with-stdin-is-not-a-tty) RequestTTY Yes RemoteCommand sudo -i ...

2020-06-19 · 1 min · 84 words · Me

firebase functinos cookie only __session

https://firebase.google.com/docs/hosting/manage-cache?hl=zh-cn#using_cookies 将 Firebase 托管与 Cloud Functions 或 Cloud Run 搭配使用时,Cookie 通常会从传入的请求中剥离出来。这是实现高效的 CDN 缓存行为所必需的。只有特别指定的 __session Cookie 可以传入应用执行过程中。 __session Cookie(如果存在)会自动成为缓存键的一部分,也就是说,使用不同 Cookie 的两个用户绝不会收到彼此的已缓存响应。只有在您的应用根据用户授权提供不同的内容时,您才能使用 __session Cookie。

2020-06-18 · 1 min · 22 words · Me

firebase functions cold start use Express.js node.js get problem

System on firebase functions always have problems that code start. https://medium.com/@siriwatknp/cold-start-workaround-in-firebase-cloud-functions-8e9db1426bd3 So google office https://firebase.google.com/docs/functions/networking const http = require('http'); const functions = require('firebase-functions'); // Setting the `keepAlive` option to `true` keeps // connections open between function invocations const agent = new http.Agent({keepAlive: true}); exports.function = functions.https.onRequest((request, response) => { req = http.request({ host: '', port: 80, path: '', method: 'GET', agent: agent, // Holds the connection open after the first invocation }, res => { let rawData = ''; res.setEncoding('utf8'); res.on('data', chunk => { rawData += chunk; }); ... Two line let me confused. Not only me. const agent = new http.Agent({keepAlive: true}); agent: agent, // Holds the connection open after the first invocation Some guy same me. ...

2020-06-17 · 2 min · 217 words · Me

undefined

新增說明文字 https://www.youtube.com/watch?v=MgLc95nBeNE [ ](https://www.youtube.com/watch?v=MgLc95nBeNE)

2020-06-15 · 1 min · 4 words · Me

mysql json mariadb

最近寫mysql 發現 原來 mysql 在json內容時,也有支援一些操作 https://www.cnblogs.com/chuanzhang053/p/9139624.html https://medium.com/micheh/%E5%9C%A8-mysql-%E4%BD%BF%E7%94%A8-json-5796a65701ad 再加上 mysql 還有另一個譆能 虛疑欄位 GENERATED ALWAYS AS http://blog.changyy.org/2017/09/mysql-json-mysql-57.html 基本上可以把json內的某欄位值當成 virutal colume, 直接輸出 覺得這樣可以玩出很多變化 https://www.cnblogs.com/waterystone/p/5626098.html

2020-06-15 · 1 min · 21 words · Me

nodejs node.js console.log util.format ...args for logging log

For logging mulit args with “%O”``` const util = require(‘util’); function d(…args) { if (typeof (console) !== ‘undefined’) { console.log(’[Logging]’, util.format(…args)); } }

2020-06-12 · 1 min · 23 words · Me

[轉]網站使用體驗三大核心指標 – LCP, FID, CLS

https://www.darrenhuang.com/core-web-vitals-lcp-fid-cls.html?fbclid=IwAR2-n-h0j-BR73sD4Vsino1ObtjDyVe3xkhNcs7xmtcn14Kk84rWO-06lPs 瀏覽器插件 這是官方出的Chrome挿件,能夠在瀏覽時即時回報該網頁的LCP, FID, CLS。

2020-06-03 · 1 min · 5 words · Me

nodejs express cache redis

https://sematext.com/blog/expressjs-best-practices/``` const express = require(’express’) const app = express() const redis = require(‘redis’) ​ const redisClient = redis.createClient(6379) ​ async function getSomethingFromDatabase (req, res, next) { try { const { id } = req.params; const data = await database.query() ​ // Set data to Redis redisClient.setex(id, 3600, JSON.stringify(data)) res.status(200).send(data) } catch (err) { console.error(err) res.status(500) } } ​ function cache (req, res, next) { const { id } = req.params ​ redisClient.get(id, (err, data) => { if (err) { return res.status(500).send(err) } ...

2020-05-18 · 1 min · 126 words · Me

[轉]140 favorite JavaScript utilities in single line of code! No more!

https://1loc.dev/

2020-05-14 · 1 min · word · Me

vs code 無法使用eslint

In personal setting.json for vs code``` “eslint.workingDirectories”: [ { “mode”: “auto” } ],

2020-05-06 · 1 min · 13 words · Me

[轉]Junior Vs Senior Code - How To Write Better Code

https://www.youtube.com/watch?v=g2nMKzhkvxw

2020-05-03 · 1 min · word · Me