Skip to content

Commit ae1763f

Browse files
committedJul 28, 2019
Add all the files
1 parent 75b29ea commit ae1763f

22 files changed

+337
-0
lines changed
 

‎Github_flavoured_markdown.url

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://enterprise.github.com/downloads/en/markdown-cheatsheet.pdf

‎NPM_NOTES.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
When updating the package (or just updating the README) you must bump the version before you publish.
2+
3+
npm version patch
4+
npm publish
5+

‎SEE_ALSO.url

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/LeCoupa/awesome-cheatsheets

‎atop.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Reading log history
2+
3+
Open today's logfile:
4+
5+
atop -r
6+
7+
or open yesterday's logfile:
8+
9+
atop -r y
10+
11+
or open the day before yesterday's logfile:
12+
13+
atop -r yy
14+
15+
Then jump forwards and backwards in time with <kbd>t</kbd> and <kbd>T</kbd> respectively.
16+
17+
Use <kbd>b</kbd> then `16:20` to jump to a specific time.
18+
19+
20+
# Sorting processes
21+
22+
C – sort in order of cpu consumption (default)
23+
M – sort in order of memory usage
24+
D – sort in order of disk activity
25+
N – sort in order of network activity
26+
A – sort in order of most active resource (auto mode)
27+
28+
29+
# Sources
30+
31+
- https://haydenjames.io/use-atop-linux-server-performance-analysis/

‎contrib/MOVING_CLI_NOTES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
On iTerm2, Shift-Left and Shift-Right jump words
Loading

‎contrib/kubernetes-cheatsheet.pdf

444 KB
Binary file not shown.

‎contrib/modern-js-cheatsheet

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 7424bb030d032a9a4dd53ef2a2573468f43eddb5
Loading

‎contrib/originals/moving_cli_blah.svg

+126
Loading
Loading
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
git init <repo>
2+
cd <repo>
3+
git remote add -f origin <url>
4+
5+
git config core.sparseCheckout true
6+
7+
echo "some/dir/" >> .git/info/sparse-checkout
8+
echo "another/sub/tree" >> .git/info/sparse-checkout
9+
10+
From: https://askubuntu.com/questions/460885/how-to-clone-git-repository-only-some-directories#645276
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
git checkout -b rewritten-branch
2+
3+
git filter-branch --prune-empty --subdirectory-filter <folder_name> rewritten-branch
4+
5+
From: https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/

‎how_to_use_blank_lines_in_code.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
I have started thinking of blank lines as "separating/grouping concepts when needed".
2+
3+
So if I have three concepts on three lines, I might put all three lines together, to save space.
4+
5+
But if one of those concepts now suddenly needs two lines, I will put some blank lines around it, to separate it from the other concepts/tasks.
6+
7+
Also, I will keep a line or two immediately next to an if block or for loop, if that line is part of the same task.

‎mongo/shorter_ids.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
In the past we have stored `_id` and `id` fields in each document. This has been somewhat confusing!
2+
3+
I think we did that because the mongo ObjectIds were considered too long and ugly for the front-end and for users.
4+
5+
Instead of doing that again, if we don’t want to use ObjectIds, we have other options.
6+
7+
We can actually set `_id` to anything we want, as long as it is unique!
8+
9+
1. We can set `_id` to an incrementing number: 1, 2, 3, … This is good to look at, but not good for sharding. Only suitable for small collections which we don’t want to shard (< 10,000).
10+
11+
2. We can set `_id` to a shorter random id like `J5m9g~0J`, e.g. using [nanoid](https://github.com/ai/nanoid) This is sharding-friendly, and we can use their collision probability [calculator](https://alex7kom.github.io/nano-nanoid-cc/) to select a length that is suitable for our collection.
12+
13+
(An alternative is [dylang/shortid](https://github.com/dylang/shortid) but nanoid appears to be better. There are [collision concerns](https://github.com/ai/nanoid/issues/8) and [prediction concerns](https://github.com/dylang/shortid/issues/70) with shortid.)
14+
15+
(We can use `-` instead of `~` if we prefer. But either way, we should [avoid](https://github.com/dylang/shortid/issues/96) using nanoids that have one of those symbols at the end! Probably simpler to just reduce the alphabet to alphanumerics.)
16+
17+
By default, mongo uses ObjectId to generate long _ids because they are guaranteed to be unique even in the worst-case scenarios. But in situations when we know the number of documents created will be low we can opt for short _ids.

‎react/setState_is_asynchronous.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# What we discovered about setState today
2+
3+
When calling `this.setState()`, we should never refer to `this.state`.
4+
5+
Why? Because the state update we pass will be applied later, asynchronously. By that time, `this.state` might have changed, but our update was based on the old copy of `this.state`!
6+
7+
// BAD
8+
this.setState({ counter: this.state.counter + 1 })
9+
10+
// GOOD (can be safely applied asnchronously)
11+
this.setState((previousState) => ({ counter: previousState.counter + 1 }))
12+
13+
But, if you are just clobbering a property, without updating it or worrying about previous states, you can just do:
14+
15+
this.setState({ counter: 0 })
16+
17+
Short read: https://medium.com/@wereHamster/beware-react-setstate-is-asynchronous-ce87ef1a9cf3
18+
19+
Long read: https://medium.freecodecamp.org/functional-setstate-is-the-future-of-react-374f30401b6b
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
https://github.com/yannickcr/eslint-plugin-react/issues/491#issuecomment-196756317
2+
3+
```js
4+
const foo = (a, b) => (
5+
<View>
6+
<BigComponent data={a} />
7+
<BigComponent data={b} />
8+
</View>
9+
)
10+
```
11+
12+
You might think that foo will not be called if `a` and `b` remain the same.
13+
14+
However [for reasons of performance]() this is not applied by default.
15+
16+
But it looks like [you can apply it when you need it](https://github.com/facebook/react/issues/5677#issuecomment-241265146).
17+

‎react_redux_gotchas.txt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# React
2+
3+
## this.setState() is asynchronous
4+
5+
TLDR: Do not refer to `this.state` when calling `this.setState()`. Pass a function to setState instead.
6+
7+
It is fine to update state with a small merge:
8+
9+
this.setState({ foo: 2 })
10+
this.setState({ bar: 7 })
11+
12+
but if you need to refer to the current state, then be careful:
13+
14+
// Avoid this form
15+
this.setState({ foo: this.state.foo * 2 })
16+
17+
One change like this will work, but if you make two updates within one cycle, you may encounter problems. Because setState does not apply your merges immediately. It waits and applies them later.
18+
19+
// BAD
20+
// The second and third calls will still be using the OLD state!
21+
this.setState({ foo: this.state.foo * 4 })
22+
this.setState({ foo: this.state.foo / 2 })
23+
this.setState({ bar: this.state.foo + 5 })
24+
25+
In the example above, the first change to foo gets completely discarded. `this.state` will not change until some point in the future, when React decides to apply your state changes.
26+
27+
In order to handle the asynchronous nature of setState, we can provide it with a function argument. The function will accept the current state, and return a merge.
28+
29+
// GOOD
30+
// All calls will be applied to the state in turn
31+
this.setState(state => ({ foo: state.foo * 4 }))
32+
this.setState(state => ({ foo: state.foo / 2 }))
33+
this.setState(state => ({ bar: state.foo + 5 }))
34+
35+
With a starting state of `{foo: 1}` we will end with state `{foo: 2, bar: 7}` as desired.
36+
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Q: Should I store `foo` in the React Component’s state or in the Redux store?
2+
3+
A: For global (shared) app state, ideally use the Redux store. For re-usable components, use the component’s own state. When in doubt, do whatever is less awkward.
4+
5+
https://github.com/reactjs/redux/issues/1287#issuecomment-175351978
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/galkinrost/redux-state
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Quick introduction
2+
3+
Open a folder in Vim:
4+
5+
$ vim ./project
6+
7+
Or if you already have Vim open:
8+
9+
:e ./project
10+
11+
You can switch netrw to tree list view if you like:
12+
13+
iii
14+
15+
Move down to a file you want to open and open it in a vertical split:
16+
17+
v
18+
19+
Now if you want the file view on the left, you might want to swap the windows (panes):
20+
21+
CTRL-W x
22+
23+
Now if you want to open another file, `v` would create another split, giving you three windows (panes). That's probably not what you want.
24+
25+
So to open another file in the same ("previous") window, hover over the file and hit:
26+
27+
P
28+
29+
You can expand or shrink the current window with:
30+
31+
30 CTRL-W >
32+
33+
5 CTRL-W <
34+
35+
36+
# Configuration
37+
38+
I use the following defaults in my `.vimrc`:
39+
40+
" Default to tree view
41+
42+
let g:netrw_liststyle = 3
43+
44+
" Make `v` open the file on the right rather than the left
45+
46+
let g:netrw_altv = 1
47+
48+
" Make the split use more space for editor than for tree
49+
50+
let g:netrw_winsize = 80
51+

‎webstorm_shorcuts.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cmd-Shift-8 (*) Toggle column select mode

0 commit comments

Comments
 (0)
Please sign in to comment.