This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FILE SPACING: | |
# double space a file | |
sed G | |
# double space a file which already has blank lines in it. Output file | |
# should contain no more than one blank line between lines of text. | |
sed '/^$/d;G' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We first get a list of file with suffix | |
# and then use `cut` utility to split the | |
# full filename into a name and suffix using | |
# dot as delimiter. | |
cut -f1 -d'.' <<<$(ls *.*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In most case, if a command takes a file name as a command line arg, we can also use the content of | |
the file as the standard input of a command, the two ways have the same effect. | |
For example, a directory contains the following files: | |
example1.txt | |
example2.txt | |
example3.txt | |
example4.txt | |
example5.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assumme that we have already installed babel-cli command using `npm install --global babel-cli`. | |
1. Configuration .babelrc, the basic format of this file is shown as the following: | |
{ | |
"presets": [], | |
"plugins": [] | |
} | |
2. Install some plunins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm run-script <command> [--silent] [-- <args>...] alias: npm run | |
Given the following package.json snippet: | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"build": "babel src -d dist", | |
"run": "node dist/main.js" | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There are two kinds of statements: | |
1. Rulesets (or rules) that, as seen, associate a collection of CSS declarations to a condition described by a selector. | |
2. At-rules that start with an at sign, '@', followed by an identifier and then continuing up the end of the statement, | |
Rulesets are the main building blocks of a style sheet, which often consists of only a big list of them. | |
But there is other information that a Web author wants to convey in the style sheet, like the character set, | |
other external style sheets to import, font face or list counter descriptions and many more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
action是一个对象,其中type属性是必须的,同时可以传入一些属性的数据。 | |
action可以用actionCreactor进行创造,actionCreactor是一个函数,例如: | |
function addTodo(text) { | |
return { | |
type: ADD_TODO, | |
text | |
} | |
} | |
dispatch就是把action对象发送出去, 结合Action Creator发送动作的代码可以这样写 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Babel compiles JSX down to React.createElement() calls. | |
const element = ( const element = React.createElement( | |
<h1 className="greeting"> 'h1', -----> element | |
Hello, world! {className: 'greeting'}, -----> props of the element | |
</h1> 'Hello, world!' -----> children(include element and text node) | |
); ); | |
也就是说在jsx文件中类似<li>{number}</li>的不要将其看成是html结构而是对React.createElement的调用 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###Arrow functions do not have this, arguments or other special names bound at all### | |
when the object is being created the name this is found in the enclosing scope. | |
name="YMJ" | |
var person = { | |
name: "ymj", | |
shout: () => console.log("my name is ", this.name) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Array.reduce | |
有初始值: | |
If an initialValue was provided in the call to reduce, then previousValue will be equal to initialValue | |
and currentValue will be equal to the first value in the array. | |
没有初始值: | |
If no initialValue was provided, then previousValue will be equal to the first value in the array | |
and currentValue will be equal to the second | |
一般数值的用法: |
OlderNewer