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