[Notes] The Ultimate Guide to handling JWTs on frontend clients (GraphQL)

The Ultimate Guide to handling JWTs on frontend clients (GraphQL)
— Read on blog.hasura.io/best-practices-of-using-jwt-with-graphql/

So far, this is the best article I have read that explains and answers questions on JWT (both server and client.)

That’s why it’s also really important not to store JWT on the client, say via cookies or localstorage. Doing so you make your app vulnerable to CSRF & XSS attacks, by malicious forms or scripts to use or steal your token lying around in cookies or localstorage.

So memory only? For cookies, with HttpOnly and Secure, there should be no concern about XSS or man-in-the-middle. Yes, chance of CSRF is still there. So you need anti-forgery. For example, keeping an anti-forgery token in localstorage (since value in localstorage won’t be sent automatically with each request.)

So it really depends on the balance of security vs. cost to keep it absolutely secure.

A very good point has been made in this SO thread.

This is a painful discussion on the Internet. Our short (and opinionated answer) is that backend developers like using JWTs because a) microservices b) not needing a centralized token database.

Indeed yes, the two most important benefits.

This token is issued as part of authentication process along with the JWT. The auth server should saves this refresh token and associates it to a particular user in its own database, so that it can handle the renewing JWT logic.

The refresh token is sent by the auth server to the client as an HttpOnly cookie and is automatically sent by the browser in a /refresh_token API call.

Persisting JWT token in localstorage (prone to XSS) < Persisting JWT token in an HttpOnly cookie (prone to CSRF, a little bit better for XSS) < Persisting refresh token in an HttpOnly cookie (safe from CSRF, a little bit better for XSS).

[Notes] Our journey to type checking 4 million lines of Python

https://blogs.dropbox.com/tech/2019/09/our-journey-to-type-checking-4-million-lines-of-python/

Gradually migrating using mypy.

Once your project is tens of thousands of lines of code, and several engineers work on it, our experience tells us that understanding code becomes the key to maintaining developer productivity. 

Type comments were also handy for Python 2 support, which has no built-in notion of type annotations:

[Notes] Azure Cosmos DB update for August 2019

https://channel9.msdn.com/Shows/Azure-Friday/Azure-Cosmos-DB-update-for-August-2019

Azure Cosmos DB is getting more and more powerful. Now Apache Spark can be enabled. It comes with Jupyter Notebooks. You can work directly on the data. So there is no need to copy the data around. Spark worker can be auto-scaled up and down with your DB. Aggregation query performance improvement is fantastic, both faster and cost less.

[Notes] World AI Conference, Elon Musk vs. Jack Ma

如果谁要“鸡同鸭讲”的官方解释,你就播这个视频给他看。哈哈。

我觉得吧这两个马老板放在一个论坛上就是笑话。

马斯克讨论的是广义的人工智能,指的是输入输出信号处理那个层面的。马云说的是当前的某种人工智能或者由当前的人工智能延伸出去的更智能的人工智能,执着于是不是动物,有没有一个心脏,跑得快不快。

E: Can chimpanzees really understand human? …we just like strange aliens. They mostly just care about other chimpanzees…if the difference is only that small, it will be really amazing. probably is much much greater.

E: We are already a cyborg. Because we are so well integrated with our phones, internet, the phone is almost like an extension of yourself. If you forgot your phone, it’s like missing limb.

J: It’s so hard to predict the future. 99.99% of the predictions that human being had about the future are all wrong…they are right by accident.

E: You can think of humanity as biological boatloader of digital super intelligence.

J: when human understand ourselves better, then we can improve the world better…but I feel what I am excited about AI is AI is to understand people, the inside of human beings.

J: …at that time, we will have a lot of jobs that nobody wants to do, so we need AI, robots to…

下面这一幕真的很搞笑。马斯克开始凝视远方,嘟哝道

E: we are gonna figure out this neuralink situation; otherwise we will be left behind…we don’t have much time.
J: we don’t have much time? For what?
E: we don’t have much time to solve neuralink.
J: ug….(甩手并作不屑状)

马斯克正在跟三体人对话。马云突然觉得这神经病怎么不好好说人话?!哈哈哈。。。

有时候我在考虑一个格局问题,当然只能猜想,站在人类财富的最高峰,中外最有钱的那群人,每日心心念念的事情,每天贪早摸黑的目标,在格局上有没有区别,如果有,又有着什么样的区别?盖茨投身于没有经济效益的贫困地区的疫苗;贝索斯建万年大钟;马斯克星际移民。。。都是一些笨事傻事蠢事。然而,美,永远是由距离产生的。这些离他们自身那么遥远的事,或许是他们认为的最美的事。

J: educate people on…creative things that let people live like a human being…we need to change the education…and don’t worry. I will change it.

E: current education is really slow, low bandwidth.

另外,用逻辑去自圆其说。马斯克用了各种论证方法,现场完胜。可能跟中西教育的不同有关,因为外国教育重视正确的论证过程,而国内重视正确的结论;也可能跟是不是卖百货有关,因为我觉得马云和贝索斯在现场论证中常出现逻辑问题。

E: biggest problem the world will face is population collapse (accelerating collapse).

J: I agreed.

什么原因担心人口问题,两人没有继续深入,我倒是很好奇?

J: when we love someone or something, we don’t need a reason, we just love. But we hate someone or something, there is a logic behind it. When there is a logic, AI can do better.

E: it’s a good thing that we eventually die…it’s good to have this life cycle.

[Notes] 6 Lessons we learned when debugging a scaling problem on GitLab.com

https://about.gitlab.com/2019/08/27/tyranny-of-the-clock/

The first step is to look for critical filters to dramatically reduce the area to troubleshoot. Such as type of logs, which server, etc.

Wireshark statistics tools could be super helpful.

If usage pattern aligns with some timing cadence, think scheduled jobs.

If the incoming rate exceeds the limit (measured every millisecond) the new connections are simply delayed. The TCP client (SSH in this case) simply sees a delay before the TCP connection is established, which is delightfully graceful, in my opinion. 

Why? Rate limiting should be used for defensive needs, where it prevents from handling the unexpected requests. But in this case, those requests are expected and expect to be processed.

When you choose specific non-default settings, leave a comment or link to documentation/issues as to why, future people will thank you.

That applies to all things non-default, such as “magic numbers,” workarounds, tricks, possible valid values, etc.

[Notes] In praise of slow thinking in the internet age

https://qz.com/1179304/in-praise-of-slow-thinking-and-socratic-ignorance/

It is good not to settle into a set of opinions. It is a mistake to put forth effort and obtain some understanding and then stop at that.

Avoid forming opinions if it is not a domain that you have put in a lot of effort. If before making your opinion public, all you have done is Google online and read a handful of articles, then it is just a piece of “opinion.” It worths almost nothing to the world or others. Whatever happening in Hongkong now, and whatever fire Trump is playing, I found myself know very little.

Obama, who was a voracious reader as a young man, committed to reading a book—not news—for an hour a day during his eight-year presidency, he told the New York Times.

See from now on, if I can stop reading news, except the news from the domain that I am working. Instead, read books and non-news articles.

[Notes] How to Read Less News But Be More Informed, According to a Futurist

https://qz.com/1222019/stop-reading-the-latest-news-if-you-want-to-be-better-informed/

He’s not trying to catch up but to check and see which of the many headlines turned out to be relevant a few weeks or a month later. 

Watson advises that we randomly pick up books and magazines, and strike up conversations with strangers.

Watson especially recommends perusing weekend editions of quality newspapers.

…relevant information makes its way to us, and that much of what we fuss over daily is just stuff that will soon be forgotten.

A great read. My actions just now:
Removed 80% RSS feeds.
Disabled Retweets for all followings.
Unsubscribed/marked as spam except must have emails.
Turned off notifications for most of the apps.
Check personal email three times a day. (morning, noon, and evening)

[Notes] Unique Leadership Concepts You Need to Know (from training notes by Maddy)

When an individual tends to jump into parent mode (critical or over nurturing) they create an opportunity for an individual to act like a child (dependent, whiney or rebellious) or vice versa. But adult (rational) behavior creates adult behavior.
For Example: A manager might say “I asked you to be done with that by Wednesday and now it’s Thursday. I’m really frustrated now” (parent) and a direct report might respond with “I’m sorry but it wasn’t my fault” (child).

Great insight. I have been leading/managing teams by following my gut feeling. But verifying the “correctness” of my approaches by the results is not a reliable approach. Theories like the above provide reasoning of why I should be saying/doing some things while not saying/doing some other things.