Week 32, 2019

Do email exactly twice a day

I’ve disabled most of notifications of my Apps on iPhone and Mac. I feel relieved and more productive. Further, I disabled the email notification as Marc Andreessen suggested 1:

Once first thing in the morning, and once at the end of the workday. Allocated half an hour or whatever it takes, but otherwise, keep your email client shut and your email notifications turned off.

When you do process email, do it like this: First, always finish each of your two daily email sessions with a completely empty inbox. Second, when doing email, either answer or file every single message until you get to that empty inbox state of grace. Third, emails relating to topics that are current working projects or pressing issues go into temporary subfolders of a folder called Action. Fourth, aside from those temporary Action subfolders, only keep three standing email folders: Pending, Review, and Vault.

Every once in a while, sweep through your Action subfolders and dump any of them that you can into Vault.

I don’t quite understand the meaning of the Vault subfolder. Marc use Vault as an archive folder I guess. Anyway, skip Vault.

Start to Test Firestore rules

Assume that you have initialized your firebase project. If not, read this article first. Learning how to test Firebase rules is pretty straightforward. First, check out the official guide. Then go to firebase/quickstart-nodejs to try the quick start project. Finally, watch the video titled Testing Firestore Security Rules With the Emulator.

The above resources are detailed and precise, so I will not repeat them. The following are some details of Firebase rules I find useful.

Do not use the web-based Firestore Security Rules Simulator. It is very annoying and not convenient.

The object request.resources contains the data is like if the request is succeed. So that, don’t assume that the request resource data only contains the updated key like this:

function only_title_can_updated() {
        return request.resource.data.keys().size() == 1 &&

The same reason, you can check if the data is changed by comparing request.resource with resource.

function user_id_can_not_be_change() {
	return request.resource.data.userId == resource.data.userId;

Sometimes, the npm test doesn’t catch up with the changes to the file. So if the test result doesn’t make sense to you. Try to restart the test or save the file again to trigger the test will save you time.

One tutorial on AngularFirebase (link is here) saying that you can load testing data before Firestore rules. However, this is not working base on my test:

const setup = async (auth, data) => {
  const projectId = `rules-spec-${Date.now()}`;
  const app = await firebase.initializeTestApp({
  const db = app.firestore();

  await db.doc('collection_name/item_id').set({attr: 'preloaded data'}); 
  // FirebaseError: 7 PERMISSION_DENIED: No matching allow statements

  await firebase.loadFirestoreRules({
    rules: fs.readFileSync('firestore.rules', 'utf8')
  return db;

Haven’t find any other information of preloading data for Firestore rules testing. Will post if founded.

Week 31, 2019

The Problem with Educational Policy

The problem with educational policy is that it is hardly influenced by scientific considerations derived from the topics taught, and almost entirely determined by extra-scientific circumstances such as the combined expectations of the students, their parents and their future employers, and the prevailing view of the role of the university: is the stress on training its graduates for today’s entry-level jobs or to providing its alumni with the intellectual bagage and attitudes that will last them another 50 years? – Dr. Edsger W. Dijkstra 1988 1

A 3x5 index card

I’m gonna to try this:

Each night before you go to bed, prepare a 3x5 index card with a short list of 3 to 5 things that you will do the next day. Use the back of the 3x5 card as your Anti-Todo List to record what you have done in that day. – Marc Andreessen 2

Incorrect config file for javascript-eslint in flycheck

When using flycheck in Emacs, javascript-eslint can not be enabled because of the incorrect config file. The output of M-x flycheck-verify-setup is as follows:

Syntax checkers for buffer NavBar.js in rjsx-mode:

  javascript-eslint (disabled)
    - may enable:  Automatically disabled!
    - executable:  Found at /usr/local/bin/eslint
    - config file: missing or incorrect

The reason for this is that the command eslint --print-config no longer works when given a directory 1 if the ESLint version is 6, which is considered an error in flycheck.

$ eslint --print-config .
Oops! Something went wrong! :(
ESLint: 6.1.0.

Downgrading to ESLint v5 fixed this issue.

$ npm install -g eslint@5

Then javascript-eslint checker can be enabled:

Syntax checkers for buffer NavBar.js in rjsx-mode:

  javascript-eslint (disabled)
    - may enable:  yes
    - executable:  Found at /usr/local/bin/eslint
    - config file: found

If not, try eslint --print-config . again to find the error. In my case, I am using eslint-config-airbnb in a project, so it is still broken until I installed all required config and plugin packages globally.

$ eslint --print-config .        
Error: Cannot find module 'eslint-config-airbnb'

However, it is best to force javascript-eslint to use the local ESLint if it exists. This can be done by adding a new hook 2.

(defun my/use-eslint-from-node-modules ()
  (let* ((root (locate-dominating-file
                (or (buffer-file-name) default-directory)
          (and root
               (expand-file-name "node_modules/.bin/eslint"
    (when (and eslint (file-executable-p eslint))
      (setq-local flycheck-javascript-eslint-executable eslint))))

(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)

The above issue has been fixed in the master branch of flycheck 3. Hopefully, they can release a new version soon.

Week 30, 2019




Niche market

A nice market is a subset of the market on which a specific product is focused. The market niche defines the product features aimed at satisfying specific market needs, as well as the price range, production quality and the demographics that it is intended to target. It is also a small market segment. 2