Vue.js notes

缩写

Vue 为 v-bind 和 v-on 这两个最常用的指令,提供了特定简写

v-bind 缩写

1
2
3
4
5
6
7
8
<!-- 完整语法 -->
<a v-bind:href="url">...</a>

<!-- 缩写 -->
<a :href="url">...</a>

<!-- 动态参数的缩写 (2.6.0+) -->
<a :[key]="url"> ... </a>

v-on 缩写

1
2
3
4
5
6
7
8
<!-- 完整语法 -->
<a v-on:click="doSomething">...</a>

<!-- 缩写 -->
<a @click="doSomething">...</a>

<!-- 动态参数的缩写 (2.6.0+) -->
<a @[event]="doSomething"> ... </a>

vue-devtools

1
2
Vue.config.devtools = true;
... new Vue({

Git branch best practices

Git Flow

A successful Git branching model
https://nvie.com/posts/a-successful-git-branching-model/

GitHub Flow

GitHub Flow
http://scottchacon.com/2011/08/31/github-flow.html

GitLab Flow

GitLab Flow
https://about.gitlab.com/blog/2014/09/29/gitlab-flow/

One Flow

GitFlow considered harmful
https://www.endoflineblog.com/gitflow-considered-harmful

ref

English Phrases With Kids

texts below are from © Common English Phrases to Use at Home & With Kids

Chores

Tidy up your room

Could you tidy up your room, please?

Make the bed

Sweetie, can you make your bed before we leave?

Get dressed

Honey, I think it’s time to get dressed – we have to go in an hour!

Learning

You have to be ready for school in… minutes!

You’re off school for a week

Isn’t it great Jenny you don’t have to get up early in the morning? You’re off school for a week!

Eating

What’s for dinner?

Who’s cooking tonight?

Put the kettle on!

Take a few more bites!

Please Harry, just take a few more bites and then you’re free to go!

Playing

Close your eyes and count till ten!

this is what you tell your kids when you’re playing “hide and seek” with them.

Want a piggyback ride?

let’s say, for argument’s sake, your daughter loves when you’re running around the house with her up on your back. Well, guess what? It’s called “piggyback” in English, and here’s how you propose the activity to your child: “Want a piggyback ride?”

Go easy on him (her)

imagine two children playing and one of them getting a bit physical with the other. It’s not really a fight situation but you’re still a bit concerned that someone might get hurt – so this is how you tell the child to calm down a bit and not be so aggressive.

That’s my boy (girl)!

this is how you praise your child for having done a great job or having shown good results in some sports game.

Common, you can do it!

are you not so sure how to encourage your child during a competition? Well, learn this phrase and use it!

You beat me again!

and this is what you’d say when your child has beaten you in some game. Well, we all know only too well that sometimes we allow our kids to beat us in order to make them feel good about themselves, so this phrase will definitely come in handy for you in such situations.

Gotcha!

are you chasing your kids around pretending to be the Big Bad Wolf? Or maybe you’re just playing “hide and seek”? Then this is the typical exclamation you can use when catch or find someone.

Sleeping

It’s time to brush your teeth!

is it getting too late and it’s time for the kids to get ready for the bed? This phrase is typically used to tell them to go to the bathroom and start brushing their teeth.

Let me tuck you in!

“tucking in” is the process of putting the blanket edges in between the child’s body and the bed thus “wrapping” them tightly and making sure they feel safe and sound. And this is how you tell your child you’re going to do it: “Let me tuck you in!”

Sleep tight!

just another version of “Sleep well!”

Sleep in

“sleeping in” means sleeping longer than usually, typically it’s understood you sleep till you wake up without an alarm. Let’s say, your kid doesn’t have to get up early the following morning, so this is what you might say: “Honey, you can sleep in tomorrow, the school is off for a few days because of the bad weather!”

Time to get up!

your daughter or son will hate you for saying this, but what other option have you got? If they have to get up for school or a trip, it just has to be said!

Rise and shine!

this is an English idiomatic expression, and you use it when waking up someone in the morning. The meaning of this phrase is “wake up and feel great!”

Sleep well?

and this is how you ask the question “Did you sleep well?” in conversational English. Basically you just drop the first two words and make it shorter.

Worrying

Are you warm enough?

this is what my granny always used to ask me, and it’s something you can also ask your child when you’re a bit worried if they’re dressed appropriately.

Are you hurt?

if your child, or anyone else for that matter, seems in distress and you want to make sure they haven’t gotten themselves injured, this is the right question to ask.

Where are you hurt?

this question means “Which body part is hurting?”

Where did you get hurt?

and this question means “Where were you when you got hurt?”

Scolding

Be nice to your (mom, sister, etc.)

if you’re witnessing a child behaving a bit inappropriately towards someone, this is the remark you may want to use.

Where are your manners?

imagine your teenage son burping or indeed – farting – at the dinner table, for example. Now, this kind of behavior would merit a response such as: “Where are your manners?”

Don’t do that, it’s not nice!

this is what’s typically said to small children when you don’t want them to do something that’s not socially acceptable.

How dare you speak to me like that?!

if your child is verbally abusive towards you, you may be left with no other option but to say such a thing. Yes, we should stay calm on all occasions, but sometimes we also lose our cool, so this phrase will come in handy in such situations.

Orders

Hurry up!

this is a very simple way of telling someone to make it quicker.

Get ready!

“get ready” is a typical English collocation and is used to prompt the other person to ready themselves for something. It’s simple enough, but still worth learning because some of us may find it hard to use the right verb with the word “ready.”

Compliments

Good job!

you can tell this to your child when he gets a good grade or made something go.

You’re doing this well!

while your child is performing a new task.

Wow! That’s a huge leap forward!

when your child improved a lot in a class or in a task

Basic English phrases

texts below are from © Basic phrases

1

Here are some basic English phrases which you can use in everyday conversation, as well as some common words you will see on signs.

  • yes
  • no
  • maybe or perhaps
  • please
  • thanks
  • thank you
  • thanks very much
  • thank you very much

2

The following are some polite ways you can reply to someone who thanks you:

  • you’re welcome
  • don’t mention it
  • not at all

Saying hello and goodbye

3

Here are some different ways to greet people:

  • hi (quite informal)
  • hello
  • good morning (used before noon)
  • good afternoon (used between noon and 6pm)
  • good evening (used after 6pm)

4

The following expressions, on the other hand, are some different things you can say when saying goodbye:

  • bye
  • goodbye
  • goodnight
  • see you!
  • see you soon!
  • see you later!
  • have a nice day!
  • have a good weekend!

Getting someone’s attention and apologising

5

  • excuse me (can be used to get someone’s attention, to get past someone, or to apologise)
  • sorry

6

If someone apologises to you, you can reply using one of the following expressions:

  • no problem
  • it’s OK or that’s OK
  • don’t worry about it

7 Making yourself understood

  • do you speak English?
  • I don’t speak English
  • I don’t speak much English
  • I only speak very little English
  • I speak a little English
  • please speak more slowly
  • please write it down
  • could you please repeat that?
  • I understand
  • I don’t understand

8 Other basic phrases

  • I know
  • I don’t know
  • excuse me, where’s the toilet?
  • excuse me, where’s the Gents?
  • excuse me, where’s the Ladies?

9 Things you might see

  • Entrance
  • Exit
  • Emergency exit
  • Push
  • Pull
  • Toilets
  • WC
  • Gentlemen (often abbreviated to Gents)
  • Ladies
  • Vacant
  • Occupied or Engaged
  • Out of order
  • No smoking
  • Private
  • No entry

Senior physicists on superstring theory

楊振寧

The party is over.

高能物理盛宴已過。

超弦理论提不出任何可观测的物理量供实验检验。

就科學的規範而言,超弦理論還不如地心說。今天,我們認為地心說是不正確的,但是地心說完全是依據科學的範式提出來的,也能解釋許多現象。而弦理論,為了統一四種力,弦理論不得不引入十一維時空,其合理性還不如地心說。

Sheldon Lee Glashow

It’s something that began to develop in the ‘80s, grew in the ‘90s, and today attracts many of the best and brightest physicists. It’s called superstring theory and it is, so far as I can see, totally divorced from experiment or observation. If not totally divorced, pretty well divorced. They will deny that, these string theorists. They will say, “We predicted the existence of gravity.” Well, I knew a lot about gravity before there were any string theorists, so I don’t take that as a prediction.

The string theorists have a theory that appears to be consistent and is very beautiful, very complex, and I don’t understand it. It gives a quantum theory of gravity that appears to be consistent but doesn’t make any other predictions. That is to say, there ain’t no experiment that could be done nor is there any observation that could be made that would say, “You guys are wrong.” The theory is safe, permanently safe. I ask you, is that a theory of physics or a philosophy?

There is today a disconnect in the world of physics. Let me put it bluntly. There are physicists, and there are string theorists. Of course the string theorists are physicists, but the string theorists in general will not attend lectures on experimental physics. They will not be terribly concerned about the results of experiments. They will talk to one another.

Freeman Dyson on String Theorists, Birds and Frogs

I would like to say a few words about string theory. Few words, because I know very little about string theory. I never took the trouble to learn the subject or to work on it myself. But when I am at home at the Institute for Advanced Study in Princeton, I am surrounded by string theorists, and I sometimes listen to their conversations. Occasionally I understand a little of what they are saying. Three things are clear. First, what they are doing is first-rate mathematics. The leading pure mathematicians, people like Michael Atiyah and Isadore Singer, love it. It has opened up a whole new branch of mathematics, with new ideas and new problems. Most remarkably, it gave the mathematicians new methods to solve old problems that were previously unsolvable. Second, the string theorists think of themselves as physicists rather than mathematicians. They believe that their theory describes something real in the physical world. And third, there is not yet any proof that the theory is relevant to physics. The theory is not yet testable by experiment. The theory remains in a world of its own, detached from the rest of physics. String theorists make strenuous efforts to deduce consequences of the theory that might be testable in the real world, so far without success.

My colleagues Ed Witten and Juan Maldacena and others who created string theory are birds, flying high and seeing grand visions of distant ranges of mountains. The thousands of humbler practitioners of string theory in universities around the world are frogs, exploring fine details of the mathematical structures that birds first saw on the horizon. My anxieties about string theory are sociological rather than scientific. It is a glorious thing to be one of the first thousand string theorists, discovering new connections and pioneering new methods. It is not so glorious to be one of the second thousand or one of the tenth thousand. There are now about ten thousand string theorists scattered around the world. This is a dangerous situation for the tenth thousandand perhaps also for the second thousand. It may happen unpredictably that the fashion changes and string theory becomes unfashionable. Then it could happen that nine thousand string theorists lose their jobs. They have been trained in a narrow specialty, and they may be unemployable in other fields of science.

Why are so many young people attracted to string theory? The attraction is partly intellectual. String theory is daring and mathematically elegant. But the attraction is also sociological. String theory is attractive because it offers jobs. And why are so many jobs offered in string theory? Because string theory is cheap. If you are the chairperson of a physics department in a remote place without much money, you cannot afford to build a modern laboratory to do experimental physics, but you can afford to hire a couple of string theorists. So you offer a couple of jobs in string theory, and you have a modern physics department. The temptations are strong for the chairperson to offer such jobs and for the young people to accept them. This is a hazardous situation for the young people and also for the future of science. I am not saying that we should discourage young people from working in string theory if they find it exciting. I am saying that we should offer them alternatives, so that they are not pushed into string theory by economic necessity.

Finally, I give you my own guess for the future of string theory. My guess is probably wrong. I have no illusion that I can predict the future. I tell you my guess, just to give you something to think about. I consider it unlikely that string theory will turn out to be either totally successful or totally useless. By totally successful I mean that it is a complete theory of physics, explaining all the details of particles and their interactions. By totally useless I mean that it remains a beautiful piece of pure mathematics. My guess is that string theory will end somewhere between complete success and failure. I guess that it will be like the theory of Lie groups, which Sophus Lie created in the nineteenth century as a mathematical framework for classical physics. So long as physics remained classical, Lie groups remained a failure. They were a solution looking for a problem. But then, fifty years later, the quantum revolution transformed physics, and Lie algebras found their proper place. They became the key to understanding the central role of symmetries in the quantum world. I expect that fifty or a hundred years from now another revolution in physics will happen, introducing new concepts of which we now have no inkling, and the new concepts will give string theory a new meaning. After that, string theory will suddenly find its proper place in the universe, making testable statements about the real world. I warn you that this guess about the future is probably wrong. It has the virtue of being falsifiable, which according to Karl Popper is the hallmark of a scientific statement. It may be demolished tomorrow by some discovery coming out of the Large Hadron Collider in Geneva.

Roger Penrose

he calls string theory a “fashion”, quantum mechanics “faith”, and cosmic inflation a “fantasy”.

So when I heard that string theory – to which I had been distinctly attracted, partly because of its early use of Riemann surfaces – had moved itself in the direction of requiring all those extra spatial dimensions, I was horrified, and far from being tempted by the romantic attractions of a higher-dimensional universe. I found it impossible to believe that nature would have rejected all those beautiful connections with Lorentzian 4-space – and I still do.
Fashion, Faith, and Fantasy in the New Physics of the Universe

Web developer tools

Chrome DevTools

Dark Theme

a built-in dark theme

Selection Mode

cmd + shift + c

Store as global variable

right click on an object in the console and press “store as global variable”. This stores the object as a global variable accessible in the console called temp1 which you can then work with using JavaScript.

Simulate Element Pseudo State

clicking the :hov icon in the upper-right corner of the Styles panel

Prettify CSS and JavaScript

After opening a minified file in the “Sources” tab, you can click the brackets logo in the lower left corner of the file, and DevTools will “prettify” the code.

Alt + Up / Alt + Down

When debugging CSS, you can select a property and use the up/down keys to tweak it’s value. By default, the arrow keys adjust values by +/- 1. However, by holding the alt key, you can use the arrow keys to adjust values finely in steps of 0.1, which is particularly useful when working with fractional values.

Conversely, you can hold shift to adjust values in steps of 10.

Preserve Log

Preserve log is a checkbox that lets you persist logs between page refreshes.
When this option is enabled, a new type of “Navigation” log appears in the console to show page refreshes or navigation events to different pages.

Network + Log Filters

Code Coverage

go to the “Coverage” tab. Press “record” and then start using your app. When you’re done, Chrome will show you the exact code that ran during your session.

Quick file switching

Ctrl + P

Search source code

Ctrl + Shift + F

Go to line number

Ctrl + O

entered :375:18 to go to line 375, column 18.

Copy image as data URI (base64 encoded)

In the Network panel click on an image and then right click on it to have the option to Copy image as data URI.

hard refresh

A hard refresh is a way of clearing the browser’s cache for a specific page, to force it to load the most recent version of a page.

  • Hold down Ctrl and click the Reload button.
  • Or, Hold down Ctrl and press F5.
  • just open the Chrome Dev Tools by pressing F12. Once the chrome dev tools are open, just right click on the refresh button and a menu will drop down. This menu gives you the option of doing a hard refresh, or even clearing the cache and do a hard refresh automatically.

Firefox Developer Tools

View browser style

Browser Styles consist of two types: the default style a browser assigns for every element, and the browser-specific styles (the ones with the browser prefix).

  1. Developer > Inspector.
  2. Click the “Computed” tab in the right section.
  3. Check the “Browser styles” checkbox.

Hide CSS style from the page

To remove any CSS style (inline, internal or external) applied on a webpage, just click on the eye symbol of the listed stylesheets in the “Style Editor“ tab. Click it again to revert to the original view.

hard refresh

  • Hold the Ctrl key and press the F5 key.
  • Or, hold down Ctrl and ⇧ Shift and then press R.

ref

Chrome

Firefox

Quantum Theory

Anyone who is not shocked by quantum theory has not understood it.
Niels Bohr

I think I can safely say that no one understands quantum mechanics.
Richard Feynman

but it is certainly the case that, though we know how to do the sums, we do not understand the theory as fully as we should. We shall see in what follows that important interpretative issues remain unresolved. They will demand for their eventual settlement not only physical insight but also metaphysical decision.
Quantum Theory: A Very Short Introduction, John Polkinghorne


Arts & Culture: Poetry Takes on Quantum Physics
https://physics.aps.org/articles/v11/103

World Lines: A Quantum Supercomputer Poem, by Amy Catanzano

What can the quantum world do for business?
https://physicsworld.com/a/what-can-the-quantum-world-do-for-business/

So every time we turn off our mobile phones, USB sticks, memory drives or data centres, all the stored data doesn’t get wiped. Quantum mechanics delivers again.

And every time you write data onto NAND Flash, you’re using one of the most surprising and successful predictions of quantum mechanics. I’m referring to barrier penetration, or tunnelling, which allows a low-energy particle to penetrate a high potential-energy barrier.

What Has Quantum Mechanics Ever Done For Us?
https://www.forbes.com/sites/chadorzel/2015/08/13/what-has-quantum-mechanics-ever-done-for-us/#31c890740468

February 29

by Jane Hirshfield

An extra day—

Like the painting’s fifth cow,
who looks out directly,
straight toward you,
from inside her black and white spots.

An extra day—

Accidental, surely:
the made calendar stumbling over the real
as a drunk trips over a threshold
too low to see.

An extra day—

With a second cup of black coffee.
A friendly but businesslike phone call.
A mailed-back package.
Some extra work, but not too much—
just one day’s worth, exactly.

An extra day—

Not unlike the space
between a door and its frame
when one room is lit and another is not,
and one changes into the other
as a woman exchanges a scarf.

An extra day—

Extraordinarily like any other.
And still
there is some generosity to it,
like a letter re-readable after its writer has died.

LeetCode - Algorithms - 405. Convert a Number to Hexadecimal

Problem

405. Convert a Number to Hexadecimal

Java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class Solution {
public String toHex(int num) {
char hex[]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
String hexdec_num="";
if (num==0)
return "0";
else if (num>0) {
int rem;
while(num>0)
{
rem = num%16;
hexdec_num = hex[rem] + hexdec_num;
num = num/16;
}
return hexdec_num;
}
else {
num = ~num;
String s = "";
for (int i = 0; i < 8; i++) {
int n = 15 - num % 16;
s += hex[n];
num /= 16;
}
char[] charArr = s.toCharArray();
for(int i=charArr.length-1;i>=0;i--)
hexdec_num+=charArr[i];
return hexdec_num;
}
}
}

Submission Detail

  • 100 / 100 test cases passed.
  • Runtime: 11 ms, faster than 8.70% of Java online submissions for Convert a Number to Hexadecimal.
  • Memory Usage: 37.7 MB, less than 8.33% of Java online submissions for Convert a Number to Hexadecimal.

ref