mirror of
https://github.com/onkelbeh/cheatsheets.git
synced 2025-10-16 15:38:44 +02:00
Compare commits
685 Commits
v1.0.20181
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
97db63d83d | ||
|
01ee3a82c6 | ||
|
1f681bd293 | ||
|
c2ffe99a30 | ||
|
b00d106985 | ||
|
1ba47a8e7e | ||
|
93d0654801 | ||
|
17bd2c9b82 | ||
|
0df6062c3a | ||
|
6253384e7d | ||
|
83e30b2c0e | ||
|
db4b9363e0 | ||
|
25eaa9a78c | ||
|
1fa8ae160f | ||
|
746bae2ebe | ||
|
27970b1495 | ||
|
edfb8bba78 | ||
|
403cc72ee3 | ||
|
5c9fd725cf | ||
|
fffa95b86b | ||
|
1325a4c6e6 | ||
|
7f81a61d0d | ||
|
42dd9eff84 | ||
|
511de900ba | ||
|
641915c80c | ||
|
d62bbeb024 | ||
|
758a48d9c5 | ||
|
8e03519c2b | ||
|
e067bd588d | ||
|
ba20f0bf67 | ||
|
9ef88ffade | ||
|
4b05ba3b0a | ||
|
a7b5dbe1e7 | ||
|
d138253d1e | ||
|
49f5585e62 | ||
|
feb02eb551 | ||
|
a7335649e2 | ||
|
faa73e54b0 | ||
|
44bdd413fb | ||
|
bf059536c6 | ||
|
021ec16bf1 | ||
|
1c9e012802 | ||
|
2ac6e0ed0c | ||
|
dc91d7f64e | ||
|
e8bfec363f | ||
|
bdf7fc2505 | ||
|
dc066dc18f | ||
|
46907176f9 | ||
|
4f18d6a46b | ||
|
d4cac4c37e | ||
|
3e4487a8ed | ||
|
d328285853 | ||
|
ccd97452a6 | ||
|
3be696141e | ||
|
7317522a8c | ||
|
c7d50cdbe1 | ||
|
6fbdf3efbe | ||
|
e21b17f5e7 | ||
|
95c60a03b4 | ||
|
de4bb16b2d | ||
|
1dbdb9c1aa | ||
|
afb4634e79 | ||
|
122e4d4992 | ||
|
af33da8de6 | ||
|
3b16d4cf2c | ||
|
9c2b6d725f | ||
|
ba8d9189ae | ||
|
90dbde9990 | ||
|
a2d0c9279d | ||
|
ca529c9d4f | ||
|
76e9d99fb9 | ||
|
726e5c04b2 | ||
|
62e5f5f5ea | ||
|
748c2a65b5 | ||
|
39a6c1a6ab | ||
|
05890aa33d | ||
|
db559f8898 | ||
|
ea5f9100f2 | ||
|
c8d1d57d9f | ||
|
711ba22911 | ||
|
ab9ab48bc5 | ||
|
cc9f2439cb | ||
|
877f83fbed | ||
|
9c1026d62f | ||
|
6afbde3c2d | ||
|
6b4c9ef35d | ||
|
b91885ec71 | ||
|
5efbf15d4f | ||
|
cd02bb5a2c | ||
|
11cfb5c943 | ||
|
04d0b8d9df | ||
|
0d16abcb6a | ||
|
9b0e8f2203 | ||
|
9cc370f984 | ||
|
c8aa8f2aac | ||
|
66b6648e49 | ||
|
d7fc5ccf02 | ||
|
000441292e | ||
|
58a1129c9b | ||
|
83017d313e | ||
|
859d8e4f0b | ||
|
076c9d6b89 | ||
|
5522b615bc | ||
|
71a0a6582a | ||
|
b7f08ce1e6 | ||
|
5f5ce3eb83 | ||
|
287295eae1 | ||
|
a5abcaea10 | ||
|
1a0c86e002 | ||
|
655647d5d4 | ||
|
f1dfc086e5 | ||
|
58232cc505 | ||
|
0a6785c3f1 | ||
|
09d5779281 | ||
|
271e0b7c5d | ||
|
6999e947cb | ||
|
fac4d1e60b | ||
|
288baef931 | ||
|
d8fb4189fd | ||
|
3cd65f1974 | ||
|
5fb0ab2a68 | ||
|
68758d5b26 | ||
|
e02473bcb5 | ||
|
d62209edf3 | ||
|
14068e6c4a | ||
|
05b5e05d09 | ||
|
3a367c969c | ||
|
955bc18ead | ||
|
34e7fe3d3c | ||
|
5b68e050e0 | ||
|
b50655f6dc | ||
|
994a66d843 | ||
|
b86ebd8968 | ||
|
e7d44f5f8c | ||
|
f142dce3f3 | ||
|
689e6a5e69 | ||
|
484fba606f | ||
|
8b42b199dd | ||
|
685ac707b0 | ||
|
1c43d9feb4 | ||
|
cd27a164b3 | ||
|
2060d12b1d | ||
|
5a312cd79e | ||
|
03a14640d7 | ||
|
95713890ce | ||
|
3cbc5b1bcd | ||
|
5a23b79e78 | ||
|
c84d4c1b97 | ||
|
301d6b07f5 | ||
|
8a3d8c3449 | ||
|
f5125bd1ec | ||
|
c1741f6923 | ||
|
3e380ef4a2 | ||
|
e5fcc03e3e | ||
|
21c62b3729 | ||
|
8b6f889761 | ||
|
0dae9e9f4d | ||
|
03a4487e86 | ||
|
6e34105043 | ||
|
b28b6527f3 | ||
|
3bf1169205 | ||
|
ff5e63c9db | ||
|
e2680e5684 | ||
|
f6faef05d8 | ||
|
8041e914f3 | ||
|
918aa48327 | ||
|
028c578bc1 | ||
|
dcf31435ab | ||
|
ec1223800f | ||
|
154c4af2d6 | ||
|
f0f4f05c92 | ||
|
ede185bf27 | ||
|
76ee217b88 | ||
|
320c38959e | ||
|
28c5f62de1 | ||
|
1bf9823bea | ||
|
a2cec5f0f0 | ||
|
88f171cba2 | ||
|
a6de3c7882 | ||
|
e0379d3cb4 | ||
|
b3c91e197a | ||
|
f7d4f61acf | ||
|
ee4ed02fa5 | ||
|
9762ba1f75 | ||
|
85d55d6e13 | ||
|
7e5ccb9336 | ||
|
c1de0e223c | ||
|
4d47cbd4e9 | ||
|
1acbf74350 | ||
|
02fed04a43 | ||
|
1e966a9ff1 | ||
|
8646bb2c89 | ||
|
39f62fc3e9 | ||
|
3e12cb0b43 | ||
|
6cf3493058 | ||
|
9148ed237e | ||
|
9ec89aa788 | ||
|
e2a59f4ff9 | ||
|
246693576d | ||
|
c1f9f6f951 | ||
|
58ede74aec | ||
|
1729e1d2a7 | ||
|
be0341938b | ||
|
8ea3efc08b | ||
|
e1292194df | ||
|
e8f302b290 | ||
|
1fbacbc9f8 | ||
|
f7f77ad479 | ||
|
b27d7d7f55 | ||
|
2822b14a57 | ||
|
616896d1d8 | ||
|
fbd66d4838 | ||
|
9dd25959fa | ||
|
18b09de08b | ||
|
b407143e5e | ||
|
269c709c61 | ||
|
c03aa5de51 | ||
|
76acff1923 | ||
|
8747708136 | ||
|
692375e0fc | ||
|
91e7bfe13b | ||
|
c051140380 | ||
|
dec49c3969 | ||
|
aef8d25a92 | ||
|
9e0dbeddce | ||
|
f2066053f8 | ||
|
7a85a431af | ||
|
c719e2899d | ||
|
36337818d9 | ||
|
6a1378f310 | ||
|
cca13c9ca5 | ||
|
8a9907db52 | ||
|
ed7ad56266 | ||
|
11849e8464 | ||
|
2a4cbe953f | ||
|
16588e2efe | ||
|
5c4b57691f | ||
|
901f457dc2 | ||
|
3cf86447a3 | ||
|
e54458ad9c | ||
|
68af8e66f6 | ||
|
afc25b5e1f | ||
|
c792f1b418 | ||
|
ba699dd29e | ||
|
aff701a600 | ||
|
6b43bf97da | ||
|
18ebcc9b2e | ||
|
45160e4cc7 | ||
|
04f28a1d76 | ||
|
a54b580e01 | ||
|
aff27988e0 | ||
|
42950dfac7 | ||
|
959b471fb6 | ||
|
31b8a9af45 | ||
|
21306a7bfe | ||
|
d20fddb40a | ||
|
a0849391d2 | ||
|
e3cd185414 | ||
|
bec53c5405 | ||
|
360bb87287 | ||
|
d4e3421ac6 | ||
|
02c3e97f4a | ||
|
ee072214f7 | ||
|
865ad2cd98 | ||
|
32fa7a6898 | ||
|
05e2dabc76 | ||
|
ac3891cae8 | ||
|
969967363f | ||
|
87ed01b739 | ||
|
b82849e840 | ||
|
fcc6196aa4 | ||
|
58d1602609 | ||
|
f3cef3c398 | ||
|
b4e978f074 | ||
|
41a2964704 | ||
|
26e0f381fb | ||
|
3a918a1619 | ||
|
6b7e8ed460 | ||
|
a595901d99 | ||
|
25070809c1 | ||
|
1fa97113d5 | ||
|
5d514222d6 | ||
|
b3cab9aa28 | ||
|
6076941a33 | ||
|
51924e42bd | ||
|
f534ec6c72 | ||
|
c27d9bf443 | ||
|
46787089cd | ||
|
81aaaf064a | ||
|
b1ff74a82f | ||
|
6722b20d19 | ||
|
40e1c30405 | ||
|
048697b3d3 | ||
|
b0a436587f | ||
|
4dbdd73c52 | ||
|
75b102fca5 | ||
|
214a4ed82e | ||
|
02bbc11dae | ||
|
ee1bbb06a3 | ||
|
d8df859e5c | ||
|
57ed177028 | ||
|
4c38e4ae49 | ||
|
85cf4ec38f | ||
|
ae18baa7e9 | ||
|
d5683a9ddf | ||
|
577bc0dae1 | ||
|
66d30a519c | ||
|
0a91b64a1a | ||
|
fef9dffd21 | ||
|
d3203a354c | ||
|
a20fdfe4e6 | ||
|
9ed567ec08 | ||
|
42bac34c80 | ||
|
271d37ec33 | ||
|
a8475e711e | ||
|
17ac9a671b | ||
|
aafab35c90 | ||
|
60f66d6750 | ||
|
69b75e6d26 | ||
|
d2cbc97ddf | ||
|
517343fcd9 | ||
|
242c5bccbf | ||
|
d0381c2254 | ||
|
a78a39538b | ||
|
aa8c2632d7 | ||
|
761fe6498e | ||
|
e961eb3a50 | ||
|
67850f71bc | ||
|
bf22b55008 | ||
|
9a73127177 | ||
|
147fd9351e | ||
|
cd03070b11 | ||
|
d42235b255 | ||
|
0114a74db2 | ||
|
2a51cfe548 | ||
|
bfb2305e3b | ||
|
1a76636dd5 | ||
|
c46a9c2c6d | ||
|
cd02419737 | ||
|
6b2cc8de1e | ||
|
6b4d445701 | ||
|
d56fcc75bf | ||
|
1ba32f1831 | ||
|
e7f7e28b5a | ||
|
ec4b0cf9bd | ||
|
9254692750 | ||
|
20e0fac85b | ||
|
ee079ad300 | ||
|
9827f09f5c | ||
|
ef43970680 | ||
|
59d47b33a3 | ||
|
734e13c744 | ||
|
574355b794 | ||
|
efd0a4590a | ||
|
3973e58287 | ||
|
9f6ea99c19 | ||
|
d48d956a5a | ||
|
799ca9ef39 | ||
|
6da706b706 | ||
|
abf62e4868 | ||
|
0361fa173b | ||
|
7a2322761a | ||
|
912afcd792 | ||
|
42df935e43 | ||
|
cb4e03077f | ||
|
a652d427eb | ||
|
3d839093e9 | ||
|
455decd2c4 | ||
|
a6fb6f3a26 | ||
|
47356a2e6a | ||
|
ef9f00aa5c | ||
|
69ebb03cca | ||
|
81eb884b74 | ||
|
3f2d48a756 | ||
|
447de944e4 | ||
|
0c7e52aafc | ||
|
a2019a2aa1 | ||
|
9c8df067e5 | ||
|
ded62323ec | ||
|
132babca6e | ||
|
ebd538f1f6 | ||
|
ecf5282f1f | ||
|
1caa08f0ca | ||
|
d8b2a29afa | ||
|
9ba6e49d36 | ||
|
d0da7addd5 | ||
|
187fc495d3 | ||
|
4570737d5c | ||
|
cf52d5d7e3 | ||
|
b5cd93a09f | ||
|
2b6aeb322c | ||
|
925abb960b | ||
|
9490cf3adf | ||
|
d65e607ae2 | ||
|
2b20b8549a | ||
|
ebe8a85148 | ||
|
5342ff47df | ||
|
0db542841d | ||
|
25ca53525c | ||
|
f58b5070c0 | ||
|
d55d4f9fc8 | ||
|
2d70df1fbb | ||
|
a0e23ed4f4 | ||
|
a4e0b6c7df | ||
|
e5fbc750ff | ||
|
0e9b7337ab | ||
|
48a96fd920 | ||
|
ffdf83a45f | ||
|
30ca1950aa | ||
|
0b8a65c575 | ||
|
4704baedfa | ||
|
85ed8e15aa | ||
|
b81b7b73c9 | ||
|
ada2e95afb | ||
|
08773a877a | ||
|
ef74b689ef | ||
|
fd9ccf25d5 | ||
|
63bde1e309 | ||
|
e815651821 | ||
|
eb2a0eabe1 | ||
|
caa7a045a9 | ||
|
f2844aee9f | ||
|
129d586ef6 | ||
|
60a2de77fb | ||
|
bc51528f1a | ||
|
b1155732aa | ||
|
86918eb0c1 | ||
|
d472f10861 | ||
|
71a59adbca | ||
|
e9ca32b14a | ||
|
afda4c70dc | ||
|
005789bb91 | ||
|
e8acd9672d | ||
|
46dd46edf1 | ||
|
b3a27632df | ||
|
fe34c4d738 | ||
|
2906fc9c6e | ||
|
7a8e661857 | ||
|
aa4bca1180 | ||
|
b497f41d18 | ||
|
fbca147904 | ||
|
6d9358a908 | ||
|
0bc396c632 | ||
|
caa337d5ea | ||
|
19d2158efb | ||
|
c3a4bd411b | ||
|
d5b83196c3 | ||
|
039979de41 | ||
|
5e41424a3e | ||
|
a3bc51825a | ||
|
cbac026d47 | ||
|
2211c7f3ec | ||
|
b74da3ccd0 | ||
|
1d4e572260 | ||
|
04b1d6212e | ||
|
8f73df1d15 | ||
|
2aaf864757 | ||
|
31351e989c | ||
|
6c461dbb7c | ||
|
c9d091c264 | ||
|
09ddca4962 | ||
|
7010476b4f | ||
|
055c3c795d | ||
|
743ac3ab20 | ||
|
6f0d6e5160 | ||
|
24f7cc6197 | ||
|
3c5040facb | ||
|
c6ee300406 | ||
|
41ad26474e | ||
|
d6cfb7b9a4 | ||
|
c9cde14fef | ||
|
b78de6b210 | ||
|
0527273f27 | ||
|
e3f165a90b | ||
|
13d7dd9e72 | ||
|
d3ba69bbc5 | ||
|
9661eff7dc | ||
|
3c90dc2117 | ||
|
947d9c3135 | ||
|
4d4ae7bfc7 | ||
|
9aa5716f18 | ||
|
b54a975c74 | ||
|
3176e8c706 | ||
|
4f3ef7db34 | ||
|
b340d90631 | ||
|
62b7da238b | ||
|
5c30fa8f4a | ||
|
33581a946a | ||
|
997e7bc0e0 | ||
|
eb78a6f5fe | ||
|
0aed72ece6 | ||
|
cb50928040 | ||
|
bf06214da9 | ||
|
dcc12e5c00 | ||
|
50271b5925 | ||
|
f7a365b23d | ||
|
d5623e46fb | ||
|
4d88c763ff | ||
|
ab73124b11 | ||
|
1ed003c8f4 | ||
|
6a12e5827b | ||
|
b6272988d4 | ||
|
f402f171b7 | ||
|
7d314b24a4 | ||
|
4cdd05f9aa | ||
|
cdbdd559ca | ||
|
7813be2238 | ||
|
c8b99a83ff | ||
|
35b6899663 | ||
|
1a17fe6148 | ||
|
5735718b7b | ||
|
746cbff8fe | ||
|
08ee61d2a4 | ||
|
1333ccada0 | ||
|
7e787c0a76 | ||
|
76dc2ef27d | ||
|
14134685c7 | ||
|
66b3324759 | ||
|
27d8585107 | ||
|
58f0dad61d | ||
|
1d4bca0e19 | ||
|
b7510ac455 | ||
|
31fa66ce5d | ||
|
70f39563b4 | ||
|
86b951267b | ||
|
5c0d96cbf4 | ||
|
c5006cfd4f | ||
|
0c740038e2 | ||
|
4da6b9adbe | ||
|
1de147b430 | ||
|
46d700336f | ||
|
7bc7228728 | ||
|
23274c85e9 | ||
|
5f56569a11 | ||
|
8820f58f31 | ||
|
25a2090a84 | ||
|
df11d9ed8b | ||
|
9f66c5d998 | ||
|
e21dcf1028 | ||
|
41babf9c07 | ||
|
a5490a0641 | ||
|
c44a075f78 | ||
|
d5ee7731e6 | ||
|
e2d29e30a4 | ||
|
8769155f5e | ||
|
452c07e78a | ||
|
f1a7af534f | ||
|
8843c62e6d | ||
|
bbe2b8c20d | ||
|
b879ad3316 | ||
|
a001fdcc00 | ||
|
1ac4600426 | ||
|
e7b9a592b9 | ||
|
1e927dccfc | ||
|
f3b1d593e8 | ||
|
b0133fbe85 | ||
|
ccd9127c52 | ||
|
74ba88e2da | ||
|
cfa6a1a08f | ||
|
bc68aeea82 | ||
|
88c2807868 | ||
|
39a691de4e | ||
|
c5e46d65e9 | ||
|
b9ba6a1ca7 | ||
|
0655d01d62 | ||
|
27be18e66b | ||
|
f2f6cafab6 | ||
|
f4070993d6 | ||
|
c353827bc4 | ||
|
013be6f383 | ||
|
7c933b55be | ||
|
c98bbd5b7d | ||
|
daed05eac0 | ||
|
c2d101f521 | ||
|
6710ba8dc7 | ||
|
f58b48c931 | ||
|
462e38c332 | ||
|
6a8b3e2174 | ||
|
29de4b74d0 | ||
|
7957c3bee4 | ||
|
2175c6275c | ||
|
27714bd874 | ||
|
9657713dde | ||
|
00a0c399cf | ||
|
331b30e13f | ||
|
55d018bc87 | ||
|
090d42f103 | ||
|
3c76e512a6 | ||
|
b3e81e0da9 | ||
|
5bb0b19505 | ||
|
8d5a749df3 | ||
|
8662fd4d3d | ||
|
87b52d5186 | ||
|
b21150deeb | ||
|
e2d9dc7772 | ||
|
665406da15 | ||
|
303813e74a | ||
|
c706d50ca4 | ||
|
fc41560d71 | ||
|
fd64f68d80 | ||
|
aed89335d9 | ||
|
c0835bcb29 | ||
|
3957e0f973 | ||
|
e05517f9f7 | ||
|
fa039e5b65 | ||
|
a18063bb9a | ||
|
7f7e899014 | ||
|
f79ab86a2c | ||
|
aaa1f64e65 | ||
|
61dd655951 | ||
|
94db676cfe | ||
|
a328be7419 | ||
|
a6cc2eade2 | ||
|
34839f27d8 | ||
|
8ea2be4731 | ||
|
15ec89d069 | ||
|
2349f623c2 | ||
|
dfce59b09f | ||
|
327932b685 | ||
|
57c49cd8aa | ||
|
376563ba4b | ||
|
fa16f8134c | ||
|
69f50888f4 | ||
|
a930009433 | ||
|
4c2bdaa050 | ||
|
2d565ceec4 | ||
|
9ce285d9ac | ||
|
b9ab467545 | ||
|
2dea4f4c8e | ||
|
07d6304a0f | ||
|
11b4c983a1 | ||
|
3b758480db | ||
|
f2583a9960 | ||
|
57540e6d64 | ||
|
d184261ab0 | ||
|
fa9f16c5ee | ||
|
a75bec82da | ||
|
4f0fb36e6d | ||
|
eccede41ed | ||
|
79f35133f0 | ||
|
b2b544e9bd | ||
|
4588c31ee9 | ||
|
945942faa3 | ||
|
4d3077222d | ||
|
c65dc4811d | ||
|
7406b2bc71 | ||
|
4eacb18b60 | ||
|
79384c2e24 | ||
|
d1a15b33d9 | ||
|
996e1829a1 | ||
|
11a00de0db | ||
|
37a0cf7d5e | ||
|
5d99c3619f | ||
|
7d2217779a | ||
|
08d176e787 | ||
|
28fac2ae2a | ||
|
0e64b13d77 | ||
|
0b74fe127d | ||
|
dc74c2b5ea | ||
|
5cff5267ab | ||
|
938b9d00b1 | ||
|
b922942c55 | ||
|
16ab1ceb31 | ||
|
c695eb7add | ||
|
d77bc9e67a | ||
|
34009ee911 | ||
|
639085251c | ||
|
f871d96e3b | ||
|
066d825b91 | ||
|
db405af253 | ||
|
26c6ed30ad | ||
|
15f8649fd9 | ||
|
b46a977600 | ||
|
04ea319247 | ||
|
dccb59103e | ||
|
de5f5a4f2b | ||
|
2f7fcbe089 | ||
|
fdad334b45 | ||
|
e722384011 | ||
|
37a09ba016 | ||
|
fd17d3f1b6 | ||
|
8365f5e761 | ||
|
c2e9c8fc36 | ||
|
194bd28bf9 | ||
|
76b013411a |
@ -1 +0,0 @@
|
||||
node_modules
|
37
.eslintrc.cjs
Normal file
37
.eslintrc.cjs
Normal file
@ -0,0 +1,37 @@
|
||||
/* eslint-env node */
|
||||
module.exports = {
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:astro/recommended',
|
||||
'prettier'
|
||||
],
|
||||
env: {
|
||||
browser: true // enables window, document, etc
|
||||
},
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['@typescript-eslint'],
|
||||
root: true,
|
||||
ignorePatterns: ['dist/**'],
|
||||
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.test.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off'
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['*.astro'],
|
||||
parser: 'astro-eslint-parser',
|
||||
parserOptions: {
|
||||
parser: '@typescript-eslint/parser',
|
||||
extraFileExtensions: ['.astro']
|
||||
}
|
||||
// rules: {
|
||||
// override/add rules settings here, such as:
|
||||
// "astro/no-set-html-directive": "error"
|
||||
// },
|
||||
}
|
||||
]
|
||||
}
|
BIN
.github/images/gitpod_preview_tut.png
vendored
Normal file
BIN
.github/images/gitpod_preview_tut.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 504 KiB |
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 148 KiB |
39
.github/workflows/build.yml
vendored
Normal file
39
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: Run tests
|
||||
on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
bundler-cache: true
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
- uses: pnpm/action-setup@v3
|
||||
with: { run_install: false }
|
||||
|
||||
# https://github.com/pnpm/action-setup?tab=readme-ov-file#use-cache-to-reduce-installation-time
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
- uses: actions/cache@v4
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Install playwright browsers
|
||||
run: pnpm playwright install --with-deps chromium
|
||||
- name: Run tests
|
||||
run: pnpm run ci
|
31
.gitignore
vendored
31
.gitignore
vendored
@ -1,5 +1,26 @@
|
||||
_output
|
||||
_site
|
||||
.jekyll-metadata
|
||||
/node_modules
|
||||
/vendor
|
||||
# build output
|
||||
dist/
|
||||
# generated types
|
||||
.astro/
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
|
||||
# environment variables
|
||||
.env
|
||||
.env.production
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
||||
|
||||
.cache
|
||||
|
||||
# playwright
|
||||
test-results
|
||||
|
1
.node-version
Normal file
1
.node-version
Normal file
@ -0,0 +1 @@
|
||||
20.11.1
|
6
.prettierignore
Normal file
6
.prettierignore
Normal file
@ -0,0 +1,6 @@
|
||||
src/sass/vendor
|
||||
vendor
|
||||
.cache
|
||||
dist
|
||||
*.md
|
||||
pnpm-lock.yaml
|
6
.prettierrc
Normal file
6
.prettierrc
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"plugins": ["prettier-plugin-astro"]
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"*.md": {
|
||||
"type": "cheat",
|
||||
"template": [
|
||||
"---",
|
||||
"title: {basename|capitalize}",
|
||||
"category: Ruby",
|
||||
"layout: 2017/sheet",
|
||||
"updated: DATE",
|
||||
"---"
|
||||
]
|
||||
}
|
||||
}
|
1
.ruby-version
Normal file
1
.ruby-version
Normal file
@ -0,0 +1 @@
|
||||
3.2.2
|
10
.travis.yml
10
.travis.yml
@ -1,10 +0,0 @@
|
||||
language: ruby
|
||||
rvm:
|
||||
- 2.5.0
|
||||
script:
|
||||
- make -B _site
|
||||
- if ! make test; then make test-warning; exit 16; fi
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
- _site
|
4
.vscode/extensions.json
vendored
Normal file
4
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"recommendations": ["astro-build.astro-vscode"],
|
||||
"unwantedRecommendations": []
|
||||
}
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "./node_modules/.bin/astro dev",
|
||||
"name": "Development server",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
8
.vscode/markdown.code-snippets
vendored
Normal file
8
.vscode/markdown.code-snippets
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Test snip": {
|
||||
"prefix": ["about"],
|
||||
"body": "Copyright. Foo Corp 2028",
|
||||
"description": "Adds copyright...",
|
||||
"scope": "markdown"
|
||||
}
|
||||
}
|
1
101.md
1
101.md
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: 101
|
||||
category: JavaScript libraries
|
||||
layout: 2017/sheet
|
||||
updated: 2017-09-21
|
||||
intro: |
|
||||
[101](https://www.npmjs.com/package/101) is a JavaScript library for dealing with immutable data in a functional manner.
|
||||
|
@ -1,8 +1,29 @@
|
||||
# Developer notes
|
||||
|
||||
## Runtimes
|
||||
|
||||
Requires Node.js, Ruby, Yarn v1.
|
||||
|
||||
See `.ruby-version` and `.node-version` for supported versions.
|
||||
|
||||
## Gitpod
|
||||
|
||||
This repository supports contribution using [gitpod](https://gitpod.io) which is online IDE using [Theia](https://github.com/eclipse-theia/theia).
|
||||
|
||||
To open-up the environment simple natigate on https://gitpod.io/#https://github.com/rstacruz/cheatsheets
|
||||
|
||||
Or using a button:<br>
|
||||
[](https://gitpod.io/#https://github.com/rstacruz/cheatsheets)
|
||||
|
||||
### Preview built website
|
||||
|
||||
To preview the website you need to first build it then you can navigate to file that you are trying to contribute and preview directly.
|
||||
|
||||
<img src='.github/images/gitpod_preview_tut.png' width=828 height=459/>
|
||||
|
||||
## Starting a local instance
|
||||
|
||||
This starts Jekyll and Webpack. This requires recent versions of [Node.js], [Yarn], [Ruby] and [Bundler] installed.
|
||||
This starts Jekyll and Parcel. This requires recent versions of [Node.js], [Yarn], [Ruby] and [Bundler] installed.
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
@ -27,7 +48,7 @@ First time setup:
|
||||
docker-compose build
|
||||
|
||||
# First-time setup
|
||||
docker-compose run --rm web bundle install && yarn
|
||||
docker-compose run --rm web bundle install && docker-compose run --rm web yarn install
|
||||
```
|
||||
|
||||
Starting the server:
|
||||
@ -42,9 +63,11 @@ See <https://devhints.io/cheatsheet-styles> for a reference on styling.
|
||||
|
||||
## JavaScript
|
||||
|
||||
When updating JavaScript, be sure webpack is running (`yarn run dev` takes care of this).
|
||||
When updating JavaScript, be sure Parcel is running (`yarn dev` takes care of this).
|
||||
|
||||
This auto-updates `/assets/packed/` with sources in `_js/`.
|
||||
This auto-updates `/assets/packed/` and `_includes/2017/critical/` with sources in `_parcel/`.
|
||||
|
||||
Before committing, run `yarn parcel:build` first.
|
||||
|
||||
## JavaScript tests
|
||||
|
||||
@ -61,16 +84,14 @@ Each sheet supports these metadata:
|
||||
```yml
|
||||
---
|
||||
title: React.js
|
||||
layout: 2017/sheet # 'default' | '2017/sheet'
|
||||
|
||||
# Optional:
|
||||
category: React
|
||||
updated: 2017-08-30 # To show in the updated list
|
||||
ads: false # Add this to disable ads
|
||||
weight: -5 # lower number = higher in related posts list
|
||||
deprecated: true # Don't show in related posts
|
||||
deprecated_by: /enzyme # Point to latest version
|
||||
prism_languages: [vim] # Extra syntax highlighting
|
||||
updated: 2020-06-14
|
||||
ads: false # Add this to disable ads
|
||||
weight: -5 # lower number = higher in related posts list
|
||||
deprecated: true # Don't show in related posts
|
||||
deprecated_by: /enzyme # Point to latest version
|
||||
prism_languages: [vim] # Extra syntax highlighting
|
||||
intro: |
|
||||
This is some *Markdown* at the beginning of the article.
|
||||
tags:
|
||||
@ -79,9 +100,10 @@ tags:
|
||||
|
||||
# Special pages:
|
||||
# (don't set these for cheatsheets)
|
||||
type: home # home | article | error
|
||||
og_type: website # opengraph type
|
||||
type: home # home | article | error
|
||||
og_type: website # opengraph type
|
||||
---
|
||||
|
||||
```
|
||||
|
||||
## Prism languages
|
||||
@ -101,6 +123,7 @@ title: ES2015
|
||||
category: Hidden
|
||||
redirect_to: /es6
|
||||
---
|
||||
|
||||
```
|
||||
|
||||
## Localizations
|
||||
@ -128,7 +151,7 @@ The site devhints.io is backed by CloudFlare. Updates will take 2 days to propag
|
||||
|
||||
There are multiple ways to set meta description.
|
||||
|
||||
### keywords (and intro)
|
||||
### Keywords (and intro)
|
||||
|
||||
Set `keywords` (and optionally `intro`). This is the easiest and the preferred
|
||||
way for now.
|
||||
@ -141,7 +164,7 @@ React.Component · render() · componentDidMount() · props/state · React is a
|
||||
JavaScript library for building web...
|
||||
```
|
||||
|
||||
### description (and intro)
|
||||
### Description (and intro)
|
||||
|
||||
Set `description` (and optionally `intro`)
|
||||
|
||||
@ -153,29 +176,6 @@ One-page reference to React and its API. React is a JavaScript library for
|
||||
building web user interfaces...
|
||||
```
|
||||
|
||||
### intro only
|
||||
### Intro only
|
||||
|
||||
If you left out `description` or `keywords`, a default description will be added.
|
||||
|
||||
## Critical path CSS
|
||||
|
||||
The critical path CSS is stored in:
|
||||
|
||||
- `_includes/2017/critical/home.html`
|
||||
- `_includes/2017/critical/sheet.html`
|
||||
|
||||
You'll need to update these every now and then when you change something in the CSS. Use this to update these snippets:
|
||||
|
||||
```
|
||||
yarn run critical
|
||||
```
|
||||
|
||||
You can temporarily disable critical path optimizations by loading it with `?nocrit=1`, eg, `https://devhints.io/?nocrit=1`.
|
||||
|
||||
## Critical path JS
|
||||
|
||||
There's JavaScript that's included inline in every page. It's entrypoint is:
|
||||
|
||||
- `_js/critical.js`
|
||||
|
||||
This is automatically compiled into the partial `_includes/2017/critical/critical.js`. Keep this bundle as small as possible.
|
||||
|
@ -1,9 +0,0 @@
|
||||
FROM ruby:2.5.1-alpine3.7
|
||||
RUN apk update && apk add --no-cache nodejs build-base
|
||||
RUN apk add yarn --no-cache --repository http://dl-3.alpinelinux.org/alpine/v3.8/community/ --allow-untrusted
|
||||
RUN mkdir -p /app
|
||||
WORKDIR /app
|
||||
# COPY Gemfile Gemfile.lock ./
|
||||
# RUN bundle install -j 4
|
||||
# COPY package.json yarn.lock ./
|
||||
# RUN yarn
|
6
Gemfile
6
Gemfile
@ -1,2 +1,4 @@
|
||||
source 'https://rubygems.org'
|
||||
gem 'github-pages', group: :jekyll_plugins
|
||||
source "https://rubygems.org"
|
||||
gem "minitest"
|
||||
gem "kramdown"
|
||||
gem "kramdown-parser-gfm"
|
||||
|
219
Gemfile.lock
219
Gemfile.lock
@ -1,216 +1,21 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (4.2.8)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.5.2)
|
||||
public_suffix (>= 2.0.2, < 4.0)
|
||||
coffee-script (2.4.1)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.12.2)
|
||||
colorator (1.1.0)
|
||||
ethon (0.10.1)
|
||||
ffi (>= 1.3.0)
|
||||
execjs (2.7.0)
|
||||
faraday (0.13.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.9.18)
|
||||
forwardable-extended (2.6.0)
|
||||
gemoji (3.0.0)
|
||||
github-pages (156)
|
||||
activesupport (= 4.2.8)
|
||||
github-pages-health-check (= 1.3.5)
|
||||
jekyll (= 3.5.2)
|
||||
jekyll-avatar (= 0.4.2)
|
||||
jekyll-coffeescript (= 1.0.1)
|
||||
jekyll-default-layout (= 0.1.4)
|
||||
jekyll-feed (= 0.9.2)
|
||||
jekyll-gist (= 1.4.1)
|
||||
jekyll-github-metadata (= 2.8.0)
|
||||
jekyll-mentions (= 1.2.0)
|
||||
jekyll-optional-front-matter (= 0.2.0)
|
||||
jekyll-paginate (= 1.1.0)
|
||||
jekyll-readme-index (= 0.1.0)
|
||||
jekyll-redirect-from (= 0.12.1)
|
||||
jekyll-relative-links (= 0.4.1)
|
||||
jekyll-sass-converter (= 1.5.0)
|
||||
jekyll-seo-tag (= 2.3.0)
|
||||
jekyll-sitemap (= 1.0.0)
|
||||
jekyll-swiss (= 0.4.0)
|
||||
jekyll-theme-architect (= 0.1.0)
|
||||
jekyll-theme-cayman (= 0.1.0)
|
||||
jekyll-theme-dinky (= 0.1.0)
|
||||
jekyll-theme-hacker (= 0.1.0)
|
||||
jekyll-theme-leap-day (= 0.1.0)
|
||||
jekyll-theme-merlot (= 0.1.0)
|
||||
jekyll-theme-midnight (= 0.1.0)
|
||||
jekyll-theme-minimal (= 0.1.0)
|
||||
jekyll-theme-modernist (= 0.1.0)
|
||||
jekyll-theme-primer (= 0.5.0)
|
||||
jekyll-theme-slate (= 0.1.0)
|
||||
jekyll-theme-tactile (= 0.1.0)
|
||||
jekyll-theme-time-machine (= 0.1.0)
|
||||
jekyll-titles-from-headings (= 0.4.0)
|
||||
jemoji (= 0.8.0)
|
||||
kramdown (= 1.13.2)
|
||||
liquid (= 4.0.0)
|
||||
listen (= 3.0.6)
|
||||
mercenary (~> 0.3)
|
||||
minima (= 2.1.1)
|
||||
rouge (= 1.11.1)
|
||||
terminal-table (~> 1.4)
|
||||
github-pages-health-check (1.3.5)
|
||||
addressable (~> 2.3)
|
||||
net-dns (~> 0.8)
|
||||
octokit (~> 4.0)
|
||||
public_suffix (~> 2.0)
|
||||
typhoeus (~> 0.7)
|
||||
html-pipeline (2.7.0)
|
||||
activesupport (>= 2)
|
||||
nokogiri (>= 1.4)
|
||||
i18n (0.8.6)
|
||||
jekyll (3.5.2)
|
||||
addressable (~> 2.4)
|
||||
colorator (~> 1.0)
|
||||
jekyll-sass-converter (~> 1.0)
|
||||
jekyll-watch (~> 1.1)
|
||||
kramdown (~> 1.3)
|
||||
liquid (~> 4.0)
|
||||
mercenary (~> 0.3.3)
|
||||
pathutil (~> 0.9)
|
||||
rouge (~> 1.7)
|
||||
safe_yaml (~> 1.0)
|
||||
jekyll-avatar (0.4.2)
|
||||
jekyll (~> 3.0)
|
||||
jekyll-coffeescript (1.0.1)
|
||||
coffee-script (~> 2.2)
|
||||
jekyll-default-layout (0.1.4)
|
||||
jekyll (~> 3.0)
|
||||
jekyll-feed (0.9.2)
|
||||
jekyll (~> 3.3)
|
||||
jekyll-gist (1.4.1)
|
||||
octokit (~> 4.2)
|
||||
jekyll-github-metadata (2.8.0)
|
||||
jekyll (~> 3.1)
|
||||
octokit (~> 4.0, != 4.4.0)
|
||||
jekyll-mentions (1.2.0)
|
||||
activesupport (~> 4.0)
|
||||
html-pipeline (~> 2.3)
|
||||
jekyll (~> 3.0)
|
||||
jekyll-optional-front-matter (0.2.0)
|
||||
jekyll (~> 3.0)
|
||||
jekyll-paginate (1.1.0)
|
||||
jekyll-readme-index (0.1.0)
|
||||
jekyll (~> 3.0)
|
||||
jekyll-redirect-from (0.12.1)
|
||||
jekyll (~> 3.3)
|
||||
jekyll-relative-links (0.4.1)
|
||||
jekyll (~> 3.3)
|
||||
jekyll-sass-converter (1.5.0)
|
||||
sass (~> 3.4)
|
||||
jekyll-seo-tag (2.3.0)
|
||||
jekyll (~> 3.3)
|
||||
jekyll-sitemap (1.0.0)
|
||||
jekyll (~> 3.3)
|
||||
jekyll-swiss (0.4.0)
|
||||
jekyll-theme-architect (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-cayman (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-dinky (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-hacker (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-leap-day (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-merlot (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-midnight (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-minimal (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-modernist (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-primer (0.5.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.2)
|
||||
jekyll-theme-slate (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-tactile (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-time-machine (0.1.0)
|
||||
jekyll (~> 3.5)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-titles-from-headings (0.4.0)
|
||||
jekyll (~> 3.3)
|
||||
jekyll-watch (1.5.0)
|
||||
listen (~> 3.0, < 3.1)
|
||||
jemoji (0.8.0)
|
||||
activesupport (~> 4.0)
|
||||
gemoji (~> 3.0)
|
||||
html-pipeline (~> 2.2)
|
||||
jekyll (>= 3.0)
|
||||
kramdown (1.13.2)
|
||||
liquid (4.0.0)
|
||||
listen (3.0.6)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9.7)
|
||||
mercenary (0.3.6)
|
||||
mini_portile2 (2.2.0)
|
||||
minima (2.1.1)
|
||||
jekyll (~> 3.3)
|
||||
minitest (5.10.3)
|
||||
multipart-post (2.0.0)
|
||||
net-dns (0.8.0)
|
||||
nokogiri (1.8.0)
|
||||
mini_portile2 (~> 2.2.0)
|
||||
octokit (4.7.0)
|
||||
sawyer (~> 0.8.0, >= 0.5.3)
|
||||
pathutil (0.14.0)
|
||||
forwardable-extended (~> 2.6)
|
||||
public_suffix (2.0.5)
|
||||
rb-fsevent (0.10.2)
|
||||
rb-inotify (0.9.10)
|
||||
ffi (>= 0.5.0, < 2)
|
||||
rouge (1.11.1)
|
||||
safe_yaml (1.0.4)
|
||||
sass (3.5.1)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
sawyer (0.8.1)
|
||||
addressable (>= 2.3.5, < 2.6)
|
||||
faraday (~> 0.8, < 1.0)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
thread_safe (0.3.6)
|
||||
typhoeus (0.8.0)
|
||||
ethon (>= 0.8.0)
|
||||
tzinfo (1.2.3)
|
||||
thread_safe (~> 0.1)
|
||||
unicode-display_width (1.3.0)
|
||||
kramdown (2.4.0)
|
||||
rexml
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
minitest (5.18.0)
|
||||
rexml (3.2.5)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
aarch64-linux-android
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
github-pages
|
||||
kramdown
|
||||
kramdown-parser-gfm
|
||||
minitest
|
||||
|
||||
BUNDLED WITH
|
||||
1.11.2
|
||||
2.4.1
|
||||
|
45
Makefile
45
Makefile
@ -1,45 +0,0 @@
|
||||
npmbin := ./node_modules/.bin
|
||||
PORT ?= 3000
|
||||
HOST ?= 127.0.0.1
|
||||
|
||||
# Builds intermediate files. Needs a _site built first though
|
||||
update: _site critical
|
||||
|
||||
# Builds _site
|
||||
_site:
|
||||
bundle exec jekyll build --incremental
|
||||
|
||||
# Builds critical path CSS/JS
|
||||
critical: _site
|
||||
node _support/critical.js
|
||||
|
||||
# Starts development server
|
||||
dev:
|
||||
$(npmbin)/concurrently -k -p command -c "blue,green" \
|
||||
"make dev-webpack" \
|
||||
"make dev-jekyll"
|
||||
|
||||
dev-webpack:
|
||||
$(npmbin)/webpack --watch --colors -p
|
||||
|
||||
dev-jekyll:
|
||||
if [ -f _site ]; then \
|
||||
bundle exec jekyll serve --safe --trace --drafts --watch --incremental --host $(HOST) --port $(PORT); \
|
||||
else \
|
||||
bundle exec jekyll serve --safe --trace --drafts --watch --host $(HOST) --port $(PORT); \
|
||||
fi
|
||||
|
||||
test: _site
|
||||
@test -f _site/vim.html
|
||||
@test -f _site/react.html
|
||||
@test -f _site/index.html
|
||||
@grep "<script src" _site/index.html >/dev/null
|
||||
@grep "<script src" _site/vim.html >/dev/null
|
||||
@grep "<script src" _site/react.html >/dev/null
|
||||
|
||||
test-warning:
|
||||
@echo "========="
|
||||
@echo "If your build failed at this point, it means"
|
||||
@echo "the site failed to generate. Check the project"
|
||||
@echo "out locally and try to find out why."
|
||||
@echo "========="
|
19
README.md
19
README.md
@ -1,13 +1,13 @@
|
||||
# Devhints
|
||||
<h1 align='center'>Devhints</h1>
|
||||
|
||||
> TL;DR for developer documentation - a ridiculous collection of cheatsheets
|
||||
|
||||
[](https://travis-ci.org/rstacruz/cheatsheets "See test builds")
|
||||
<blockquote align='center'>
|
||||
TL;DR for developer documentation - a ridiculous collection of cheatsheets
|
||||
</blockquote>
|
||||
|
||||
<br>
|
||||
|
||||
<p align='center'>
|
||||
<a href='https://devhints.io/'><img src='_docs/images/screenshot.png' width=600></a>
|
||||
<a href='https://devhints.io/'><img src='.github/images/screenshot.png' width=600></a>
|
||||
<br>
|
||||
✨ <b><a href='https://devhints.io/'>devhints.io</a></b> ✨
|
||||
</p>
|
||||
@ -17,3 +17,12 @@
|
||||
---
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md) for developer notes.
|
||||
|
||||
[](https://gitpod.io/#https://github.com/rstacruz/cheatsheets)
|
||||
|
||||
<h2 align='center'>Similar projects</h1>
|
||||
|
||||
- [Command Line Interface Pages](https://github.com/command-line-interface-pages)
|
||||
- [tldr-pages](https://github.com/tldr-pages/tldr)
|
||||
- [Cheat](https://github.com/cheat/cheat)
|
||||
- [Eg](https://github.com/srsudar/eg)
|
||||
|
61
_config.yml
61
_config.yml
@ -1,61 +0,0 @@
|
||||
# Jekyll configuration
|
||||
|
||||
whitelist:
|
||||
- jekyll-redirect-from
|
||||
- jekyll-github-metadata
|
||||
|
||||
plugins:
|
||||
- jekyll-redirect-from
|
||||
- jekyll-github-metadata
|
||||
|
||||
exclude:
|
||||
- Makefile
|
||||
- README.md
|
||||
- CONTRIBUTING.md
|
||||
- Gemfile
|
||||
- Gemfile.lock
|
||||
- CNAME
|
||||
- vendor
|
||||
- package.json
|
||||
- .babelrc
|
||||
- yarn.lock
|
||||
- package-lock.json
|
||||
- webpack.config.js
|
||||
- node_modules
|
||||
- Dockerfile
|
||||
- docker_compose.yml
|
||||
|
||||
# Markdown
|
||||
|
||||
highlighter: false
|
||||
markdown: kramdown
|
||||
kramdown:
|
||||
input: GFM
|
||||
hard_wrap: false
|
||||
parse_block_html: true
|
||||
syntax_highlighter_opts:
|
||||
disable: true
|
||||
|
||||
# Defaults
|
||||
|
||||
defaults:
|
||||
- scope:
|
||||
path: ""
|
||||
type: pages
|
||||
values:
|
||||
layout: "default"
|
||||
og_type: article
|
||||
type: article
|
||||
category: "Others"
|
||||
excerpt_separator: "<!--more-->"
|
||||
prism_languages: []
|
||||
|
||||
# Site info
|
||||
|
||||
url: https://devhints.io
|
||||
title: Devhints.io cheatsheets
|
||||
|
||||
# GitHub metadata
|
||||
# https://help.github.com/articles/repository-metadata-on-github-pages/
|
||||
|
||||
repository: rstacruz/cheatsheets
|
@ -1,2 +0,0 @@
|
||||
# No trailing slash
|
||||
preview_host: https://assets.devhints.io/previews
|
@ -1,4 +0,0 @@
|
||||
enabled: false
|
||||
token: "653d56e083fec2a9ae1b6c7cde4e5f5f"
|
||||
title: "Rollbar"
|
||||
description: "Real-time error monitoring, alerting, and analytics for developers 🚀"
|
@ -1,2 +0,0 @@
|
||||
enabled: false
|
||||
src: //cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=ricostacruzcom
|
@ -1,27 +0,0 @@
|
||||
enabled: true
|
||||
names:
|
||||
- Analytics
|
||||
- Ansible
|
||||
- Apps
|
||||
- CLI
|
||||
- CSS
|
||||
- Databases
|
||||
- Devops
|
||||
- Elixir
|
||||
- Git
|
||||
- HTML
|
||||
- JavaScript
|
||||
- JavaScript libraries
|
||||
- Jekyll
|
||||
- Ledger
|
||||
- Markup
|
||||
- macOS
|
||||
- Node.js
|
||||
- PHP
|
||||
- Rails
|
||||
- React
|
||||
- Ruby
|
||||
- Ruby libraries
|
||||
- Vim
|
||||
- Fitness
|
||||
- Others
|
@ -1,2 +0,0 @@
|
||||
enabled: true
|
||||
token: "c2c8bc62-c275-4c7a-a304-74335c5a1cd0"
|
@ -1,50 +0,0 @@
|
||||
home:
|
||||
title: "Rico's cheatsheets"
|
||||
tagline: |
|
||||
Hey! I'm <a href='https://ricostacruz.com'>@rstacruz</a> and this is a modest collection of cheatsheets I've written.
|
||||
|
||||
top_nav:
|
||||
title: Devhints.io
|
||||
edit: Edit
|
||||
edit_on_github: Edit this page on GitHub
|
||||
|
||||
sheet:
|
||||
suffix: cheatsheet
|
||||
|
||||
social_list:
|
||||
default_description: "Ridiculous collection of web development cheatsheets"
|
||||
description: "The ultimate cheatsheet for TITLE."
|
||||
facebook_share: Share on Facebook
|
||||
twitter_share: Share on Twitter
|
||||
|
||||
related_posts_callout:
|
||||
description: Over SIZE curated cheatsheets, by developers for developers.
|
||||
link: Devhints home
|
||||
|
||||
related_posts_group:
|
||||
top: Top cheatsheets
|
||||
other: Other cheatsheets
|
||||
category: Other CATEGORY cheatsheets
|
||||
|
||||
search_form:
|
||||
default_placeholder: Search SIZE+ cheatsheets
|
||||
home_placeholder: Search...
|
||||
prefix: devhints.io
|
||||
|
||||
comments_area:
|
||||
suffix: for this cheatsheet.
|
||||
link: "Write yours!"
|
||||
|
||||
not_found:
|
||||
title: Not found
|
||||
description: Sorry, we don't have a cheatsheet for this yet. Try searching!
|
||||
home: Back to home
|
||||
|
||||
announcement:
|
||||
id: 2017-10-26-twitter
|
||||
title: |
|
||||
New: We're on Twitter ♥️
|
||||
body: |
|
||||
Follow [@devhints](https://twitter.com/devhints) on Twitter for daily "today I learned" snippets!
|
||||
|
||||
[](https://twitter.com/devhints)
|
@ -1,2 +0,0 @@
|
||||
enabled: true
|
||||
host: devhints.disqus.com
|
@ -1,3 +0,0 @@
|
||||
enabled: true
|
||||
hostname: devhints.io
|
||||
id: "UA-106902774-1"
|
@ -1,81 +0,0 @@
|
||||
---
|
||||
title: Ansible
|
||||
category: Ruby
|
||||
---
|
||||
|
||||
## Looping
|
||||
|
||||
### Array (with_items)
|
||||
|
||||
```yaml
|
||||
vars:
|
||||
security_groups:
|
||||
- name: 'hello'
|
||||
desc: 'world'
|
||||
|
||||
- name: 'hola'
|
||||
desc: 'mundo'
|
||||
|
||||
tasks:
|
||||
- name: Create required security groups
|
||||
ec2_group:
|
||||
name: "{{ item.name }}"
|
||||
description: "{{ item.desc }}"
|
||||
with_items: "{{ security_groups }}"
|
||||
```
|
||||
|
||||
### Object (with_dict)
|
||||
|
||||
```yaml
|
||||
tasks:
|
||||
- name: Print phone records
|
||||
debug: msg="User {{ item.key }} is {{ item.value.name }} ({{ item.value.telephone }})"
|
||||
with_dict: "{{ users }}"
|
||||
```
|
||||
|
||||
## with_file
|
||||
|
||||
```yaml
|
||||
- name: "Send key"
|
||||
ec2_key:
|
||||
key_material: "{{ item }}"
|
||||
with_file: ./keys/sshkey.pub
|
||||
|
||||
# or
|
||||
with_fileglob: ./keys/*.pub
|
||||
```
|
||||
|
||||
### Conditionals
|
||||
|
||||
```yml
|
||||
- include: setup-debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6") or
|
||||
(ansible_distribution == "Debian" and ansible_distribution_major_version == "7")
|
||||
|
||||
|
||||
# Just like "and"
|
||||
when:
|
||||
- ansible_distribution == "CentOS"
|
||||
- ansible_distribution_major_version == "6"
|
||||
```
|
||||
|
||||
## Expressions
|
||||
|
||||
```
|
||||
{{ item }}
|
||||
{{ item.name }}
|
||||
{{ item[0].name }}
|
||||
|
||||
{{ item | default('latest') }}
|
||||
```
|
||||
|
||||
## Includes
|
||||
|
||||
```
|
||||
tasks:
|
||||
- include: wordpress.yml
|
||||
vars:
|
||||
wp_user: timmy
|
||||
```
|
@ -1,78 +0,0 @@
|
||||
# Installing
|
||||
wget "http://kohanaphp.com/download?modules%5Bauth%5D=Auth&languages%5Ben_US%5D=en_US&format=zip" -O k.zip &&\
|
||||
unzip -q k.zip && rm k.zip &&\
|
||||
mv Kohana_*/* . && rm -rf Kohana_* &&\
|
||||
rm -f "Kohana License.html" &&\
|
||||
# htaccess
|
||||
cat example.htaccess | sed 's/RewriteBase .*/RewriteBase \//g' > .htaccess && rm example.htaccess &&\
|
||||
echo Done! Go and edit application/config/config.php and change the site stuff.
|
||||
|
||||
# Public HTML
|
||||
mkdir -p public_html &&\
|
||||
mv index.html public_html &&\
|
||||
mv .htaccess public_html &&\
|
||||
echo Done. Now edit index.html's paths
|
||||
|
||||
Git ignore
|
||||
(echo \*.swo; echo \*.swp; echo .DS_Store; echo Thumbs.db; echo \*~; echo application/logs; echo application/cache ) > .gitignore &&\
|
||||
|
||||
# Database
|
||||
$config['default'] = array
|
||||
(
|
||||
'benchmark' => TRUE,
|
||||
'persistent' => FALSE,
|
||||
'connection' => array
|
||||
(
|
||||
'type' => 'mysql',
|
||||
'user' => 'leet', // set to db user name
|
||||
'pass' => 'l33t', // set to db user password
|
||||
'host' => 'localhost',
|
||||
'port' => FALSE,
|
||||
'socket' => FALSE,
|
||||
'database' => 'leetdb' // set to db name
|
||||
),
|
||||
'character_set' => 'utf8',
|
||||
'table_prefix' => '',
|
||||
'object' => TRUE,
|
||||
'cache' => FALSE,
|
||||
'escape' => TRUE
|
||||
);
|
||||
|
||||
|
||||
// ORM model
|
||||
class Post_Model extends ORM {
|
||||
protected $has_one = array('user'); // has_many, belong_to, has_one, has_and_belongs_to_many
|
||||
}
|
||||
|
||||
// ORM
|
||||
$post = ORM::factory('post', 1);
|
||||
$post->name = "Post name";
|
||||
$post->save();
|
||||
foreach ($post->categories as $category)
|
||||
{
|
||||
echo $category->name;
|
||||
}
|
||||
|
||||
// Find (returns even if no row is found)
|
||||
$o = ORM::factory('article')->find(1);
|
||||
$o = ORM::factory('article')->where('title', $title)->find();
|
||||
if (!$o->loaded) { die('Not found'); }
|
||||
echo $o->title;
|
||||
|
||||
// Find_all
|
||||
$o = ORM::factory('article')->find_all();
|
||||
foreach ($o as $article) { echo $article->title; }
|
||||
|
||||
// ->$saved
|
||||
// ->$changed[]
|
||||
// ->$object_name (Blog_Post_Model => "blog_post")
|
||||
// ->$primary_key ('id')
|
||||
// ->$primary_val ('username') - more userfriendly identifier
|
||||
// ->$table_name
|
||||
// ->$ignored_columns = array('whatever')
|
||||
// ->$table_columns = array('id', 'username')
|
||||
// ->$sorting = array('last_login' => 'desc') -- default sorting
|
||||
|
||||
//
|
||||
|
||||
|
@ -1,104 +0,0 @@
|
||||
# Debug
|
||||
logger.debug "xx"
|
||||
|
||||
# Controller stuff
|
||||
class MyController < ApplicationController::Base
|
||||
controller.response.body
|
||||
|
||||
# Filters
|
||||
before_filter :require_login # Looks for require_login method
|
||||
before_filter MyFilter # Looks for MyFilter class
|
||||
before_filter { |ct| head(400) if ct.params["stop_action"] }
|
||||
around_filter :catch_exceptions
|
||||
after_filter :xx
|
||||
|
||||
layout "admin_area" # Looks for the view file
|
||||
layout "admin_area", :except => [ :rss, :whatever ]
|
||||
layout :foo # Looks for private function foo
|
||||
|
||||
private
|
||||
def whatever ...
|
||||
|
||||
class MyFilter
|
||||
def self.filter(controller, &block)
|
||||
|
||||
# Model
|
||||
|
||||
belongs_to :user
|
||||
validates_presence_of :user
|
||||
default_scope :order => 'id DESC'
|
||||
named_scope :today, :conditions = "created_at x"
|
||||
named_scope :today, lambda {{ :conditions = [ "created_at between ? and ?", 1.hour.ago.utc, 300.seconds.ago.utc ] }}
|
||||
# Then you can call feed.today
|
||||
|
||||
# Controller methods
|
||||
render :action => 'help', :layout => 'help'
|
||||
render :text => 'so and so'
|
||||
render :status => :created, :location => post_url(post) # With HTTP headers
|
||||
redirect_to :action => 'index'
|
||||
render :partial => 'product', :collection => @products, :as => :item, :spacer_template => "product_ruler"
|
||||
return head(:method_not_allowed)
|
||||
head :created, :location => '...'
|
||||
|
||||
url_for :controller => 'posts', :action => 'recent'
|
||||
|
||||
location = request.env["SERVER_ADDR"]
|
||||
|
||||
# For views
|
||||
auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "RSS Feed"})
|
||||
javascript_include_tag "foo"
|
||||
stylesheet_link_tag
|
||||
image_tag
|
||||
|
||||
# Ruby stuff!
|
||||
# Defining a class method (not a typo)
|
||||
Fixnum.instance_eval { def ten; 10; end }
|
||||
Fixnum.ten # => 10
|
||||
|
||||
# Defining an instance method
|
||||
Fixnum.class_eval { def number; self; end }
|
||||
7.number #=> 7
|
||||
|
||||
# Multiple arguments, send()
|
||||
class Klass
|
||||
def hello(*args); "Hello " + args.join(' '); end
|
||||
end
|
||||
Klass.new.send :hello, "gentle", "readers"
|
||||
|
||||
def can(*args)
|
||||
yield if can?(*args)
|
||||
end
|
||||
# can(x) {...} => if can?(x) {...}
|
||||
|
||||
|
||||
|
||||
# Struct
|
||||
class Foo < Struct.new(:name, :email)
|
||||
end
|
||||
|
||||
j = Foo.new("Jason", "jason@bateman.com")
|
||||
j.name = "Hi"
|
||||
print j.name
|
||||
|
||||
|
||||
# Struct
|
||||
class Foo < Struct.new(:name, :email)
|
||||
end
|
||||
|
||||
j = Foo.new("Jason", "jason@bateman.com")
|
||||
j.name = "Hi"
|
||||
print j.name
|
||||
|
||||
|
||||
# Method missing
|
||||
def method_missing(method_name, *arguments)
|
||||
if method_name.to_s[-1,1] == "?"
|
||||
self == method_name.to_s[0..-2]
|
||||
|
||||
|
||||
# Rails logger
|
||||
Rails.logger.info("...")
|
||||
|
||||
# To string
|
||||
:hello_there.to_s
|
||||
|
@ -1,7 +0,0 @@
|
||||
---
|
||||
title: Cinema4d
|
||||
category: Apps
|
||||
---
|
||||
|
||||
E R T : Move/rotate/scale
|
||||
P : snapping
|
@ -1,56 +0,0 @@
|
||||
---
|
||||
title: Compass sprites
|
||||
---
|
||||
|
||||
### Compass: Sprites
|
||||
|
||||
@import compass/utilities/sprites
|
||||
|
||||
$sprites: sprite-map('sprites/*.png')
|
||||
$sprites: sprite-map('sprites/*.png', $spacing: 20px)
|
||||
|
||||
@mixin sprite($name)
|
||||
background-image: sprite-url($sprite)
|
||||
|
||||
+sprite-dimensions($sprite, $name)
|
||||
width: image-width(sprite-file($sprite, $name)
|
||||
height: image-height(sprite-file($sprite, $name)
|
||||
|
||||
+sprite-background-position($sprite, $name[, $offset-x, $offset-y])
|
||||
background-position: sprite-position($sprite, $name)
|
||||
nth(sprite-position($sprite, $name), 1) # X position
|
||||
nth(sprite-position($sprite, $name), 2) # Y position
|
||||
|
||||
### Compass: Sprites (the @import way)
|
||||
|
||||
// Sprite sets (applies to icon/*.png)
|
||||
$icon-spacing: 0
|
||||
$icon-dimensions: true
|
||||
$icon-repeat: no-repeat
|
||||
$icon-position: 0
|
||||
|
||||
// Individual (applies to icon/mail.png)
|
||||
$icon-mail-spacing: 0
|
||||
|
||||
@import 'icon/*.png'
|
||||
@include all-icon-sprites
|
||||
|
||||
// Usage
|
||||
.image1
|
||||
@extend .icon-mail
|
||||
|
||||
.image2
|
||||
@extend .icon-refresh;
|
||||
|
||||
// ### Advanced control
|
||||
// The sprite map is available as $icon-sprites. You can then use
|
||||
// `sprite()` on it.
|
||||
|
||||
.image3
|
||||
background: sprite($icon-sprites, refresh)
|
||||
//background: url(...) 0 -16px;
|
||||
|
||||
.image3-with-offset
|
||||
background: sprite($icon-sprites, refresh, -2px, -9px)
|
||||
//background: url(...) -2px -19px;
|
||||
|
@ -1,43 +0,0 @@
|
||||
---
|
||||
title: Docker on OSX
|
||||
category: Devops
|
||||
---
|
||||
|
||||
You'll need these:
|
||||
|
||||
* [boot2docker] - bootstraps a Virtualbox VM to run a docker daemon
|
||||
* [docker] - docker client
|
||||
|
||||
### Install
|
||||
|
||||
$ brew install boot2docker
|
||||
$ brew install docker
|
||||
$ boot2docker init
|
||||
|
||||
### Turning on
|
||||
|
||||
$ boot2docker start
|
||||
|
||||
Waiting for VM to be started...... Started.
|
||||
To connect the Docker client to the Docker daemon, please set:
|
||||
|
||||
export DOCKER_HOST=tcp://192.168.59.103:2375
|
||||
|
||||
$ export DOCKER_HOST=tcp://192.168.59.103:2375
|
||||
|
||||
### Try it
|
||||
|
||||
$ docker search ubuntu
|
||||
|
||||
$ docker pull ubuntu
|
||||
$ docker start ubuntu
|
||||
|
||||
### Turning off
|
||||
|
||||
$ boot2docker save
|
||||
# save state to disk
|
||||
|
||||
### Vagrant
|
||||
|
||||
[boot2docker]: https://github.com/boot2docker/boot2docker
|
||||
[docker]: https://www.docker.com/
|
@ -1,18 +0,0 @@
|
||||
---
|
||||
title: eslint
|
||||
category: JavaScript libraries
|
||||
---
|
||||
|
||||
```js
|
||||
// "comma-dangle": "always" ("always-multiline", "never")
|
||||
var foo = {
|
||||
bar: "baz",
|
||||
qux: "quux",
|
||||
};
|
||||
var arr = [1,2,];
|
||||
```
|
||||
|
||||
```
|
||||
// "yoda": "always" ("never")
|
||||
if ("red" === color)
|
||||
```
|
@ -1,9 +0,0 @@
|
||||
---
|
||||
title: GitHub
|
||||
category: Git
|
||||
---
|
||||
|
||||
### URLs
|
||||
|
||||
github.com/:userrepo/blame/:branch/:path
|
||||
github.com/:userrepo/commit/:commit
|
@ -1,28 +0,0 @@
|
||||
---
|
||||
title: jQuery mobile events
|
||||
category: JavaScript libraries
|
||||
---
|
||||
|
||||
### Mobile events
|
||||
|
||||
For support for `tap`, `swipe`, `swipeLeft`, et al, use
|
||||
[jquery.mobile.event.js][m]. Be sure to set `$.support.touch` first.
|
||||
|
||||
To get `$.support.touch` (and family), use this from
|
||||
[jquery.mobile.support.js][s]:
|
||||
|
||||
$.extend($.support, {
|
||||
orientation: "orientation" in window && "onorientationchange" in window,
|
||||
touch: "ontouchend" in document,
|
||||
cssTransitions: "WebKitTransitionEvent" in window,
|
||||
pushState: "pushState" in history && "replaceState" in history,
|
||||
mediaquery: $.mobile.media( "only all" ),
|
||||
cssPseudoElement: !!propExists( "content" ),
|
||||
touchOverflow: !!propExists( "overflowScrolling" ),
|
||||
boxShadow: !!propExists( "boxShadow" ) && !bb,
|
||||
scrollTop: ( "pageXOffset" in window || "scrollTop" in document.documentElement || "scrollTop" in fakeBody[ 0 ] ) && !webos && !operamini,
|
||||
dynamicBaseTag: baseTagTest()
|
||||
});
|
||||
|
||||
[m]:https://github.com/jquery/jquery-mobile/blob/master/js/jquery.mobile.event.js
|
||||
[s]:https://github.com/jquery/jquery-mobile/blob/master/js/jquery.mobile.support.js
|
@ -1,32 +0,0 @@
|
||||
---
|
||||
title: node-gh
|
||||
category: JavaScript libraries
|
||||
---
|
||||
|
||||
## Everywhere
|
||||
|
||||
| Flag | Description |
|
||||
| ---- | ---- |
|
||||
| `-u rstacruz -r nprogress` | Repo name |
|
||||
| `--browser` | Browser |
|
||||
{:.no-head}
|
||||
|
||||
## Notifications
|
||||
|
||||
```
|
||||
gh nt
|
||||
gh nt --watch
|
||||
```
|
||||
|
||||
## Issues
|
||||
|
||||
| Command | Description |
|
||||
| ---- | ---- |
|
||||
| `gh is 'Issue name'` | Create issue |
|
||||
| `gh is --search 'foo'` | Search issues |
|
||||
| `gh is 'Name' 'Description'` | Create issue |
|
||||
| `gh is 123` | Modify issue `123` (use with flags below) |
|
||||
| ... `-L`/`--label x,y,z` | Add label |
|
||||
| ... `-A`/`--assignee` | Assign to user |
|
||||
| ... `-c`/`--comment 'Thanks'` | Add a comment
|
||||
{:.no-head}
|
@ -1,7 +0,0 @@
|
||||
---
|
||||
title: Git one-liners
|
||||
---
|
||||
|
||||
When did someone work
|
||||
|
||||
git log --all --author='Rico' --pretty="%ai" | awk '{ print $1 }' | sort | uniq
|
@ -1,26 +0,0 @@
|
||||
|
||||
### Encrypt decrypt
|
||||
|
||||
gpg --encrypt --recepient 'James Receiverson' foo.txt
|
||||
gpg --decrypt foo.txt.gpg
|
||||
|
||||
### Making keys
|
||||
|
||||
gpg --gen-key
|
||||
|
||||
### Share your public key
|
||||
|
||||
# via file
|
||||
gpg --armor --output pub.txt --export "Rico Sta. Cruz"
|
||||
|
||||
# via server
|
||||
gpg --send-keys "Rico Sta. Cruz" --keyserver http://...
|
||||
|
||||
### Key management
|
||||
|
||||
gpg --list-keys
|
||||
gpg --delete-key 'email@addie'
|
||||
|
||||
### See
|
||||
|
||||
* https://www.madboa.com/geek/gpg-quickstart/
|
@ -1,19 +0,0 @@
|
||||
---
|
||||
title: Homebrew formula
|
||||
---
|
||||
|
||||
brew create http://example.com/foo-0.1.tar.gz
|
||||
|
||||
https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md#formula-cookbook
|
||||
|
||||
assert(this.ary.indexOf(zero) === two)
|
||||
|
||||
|
||||
```
|
||||
def install
|
||||
system "./configure", "--prefix=#{prefix}", "--disable-debug", "--disable-dependency-tracking"
|
||||
system "make", "install"
|
||||
cd "build/cmake"
|
||||
mv "a", "b"
|
||||
end
|
||||
```
|
@ -1,21 +0,0 @@
|
||||
---
|
||||
title: iOS
|
||||
---
|
||||
|
||||
Multiple Exchange accounts:
|
||||
|
||||
scp root@iphone.local:/private/var/mobile/Library/Preferences/com.apple.accountsettings.plist .
|
||||
|
||||
Paths:
|
||||
|
||||
/Library/Themes # Winterboard themes
|
||||
/User/Media/DCIM/100APPLE # Photos
|
||||
/User/Media/Recordings # Voice recordings
|
||||
|
||||
Copy photos:
|
||||
|
||||
rsync -v -r root@iphone.local:/User/Media/DCIM/100APPLE ./photos
|
||||
|
||||
Ringtone conversion using ffmpeg:
|
||||
|
||||
ffmpeg -i foo.mp3 -ac 1 -ab 128000 -f mp4 -acodec libfaac -y target.m4r
|
@ -1,10 +0,0 @@
|
||||
{% if site.data.content.announcement %}
|
||||
<div class='announcements-list'>
|
||||
<div class='announcements-item item -hide' data-js-dismissable='{"id":"{{ site.data.content.announcement.id }}"}'>
|
||||
<h3 class='title'>{{ site.data.content.announcement.title }}</h3>
|
||||
<div class='body'>{{ site.data.content.announcement.body | markdownify }}</div>
|
||||
<button data-js-dismiss class='close'></button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -1,34 +0,0 @@
|
||||
<script type='application/ld+json'>
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "NewsArticle",
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": "https://google.com/article"
|
||||
},
|
||||
"headline": {{ meta_title | jsonify }},
|
||||
"image": [ {{ meta_image | jsonify }} ],
|
||||
"description": {{ meta_description | jsonify }}
|
||||
}
|
||||
</script>
|
||||
<script type='application/ld+json'>
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "BreadcrumbList",
|
||||
"itemListElement": [{
|
||||
"@type": "ListItem",
|
||||
"position": 1,
|
||||
"item": {
|
||||
"@id": "{{ site.url }}/#{{ page.category | downcase | replace: ' ', '-' }}",
|
||||
"name": "{{ page.category }}"
|
||||
}
|
||||
},{
|
||||
"@type": "ListItem",
|
||||
"position": 2,
|
||||
"item": {
|
||||
"@id": {{ page_url | jsonify }},
|
||||
"name": {{ page.title | jsonify }}
|
||||
}
|
||||
}]
|
||||
}
|
||||
</script>
|
@ -1,13 +0,0 @@
|
||||
{% assign pixel_href = 'https://codefund.io/t/l/TOKEN/pixel.png' | replace: 'TOKEN', site.data.berry.token %}
|
||||
{% assign link_href = 'https://codefund.io/t/c/TOKEN/' | replace: 'TOKEN', site.data.berry.token %}
|
||||
|
||||
<aside class='berry-sponsor' data-js-no-preview>
|
||||
<div class='cs__wrapper'>
|
||||
<div class='cs__header'>Proudly sponsored by</div>
|
||||
<a href='{{ link_href }}' class='cs__blurb' target='_blank' rel='noopener'>
|
||||
<strong>{{ site.data.berry.title }}</strong>
|
||||
<span>{{ site.data.berry.description }}</span>
|
||||
</a>
|
||||
<img class='cs__pixel' src='{{ pixel_href }}' />
|
||||
</div>
|
||||
</aside>
|
@ -1,4 +0,0 @@
|
||||
<aside class='codefund-sponsor' data-js-no-preview>
|
||||
<script src='https://codefund.io/scripts/{{ site.data.codefund.token }}/embed.js?template=centered'></script>
|
||||
<div id='codefund_ad'></div>
|
||||
</aside>
|
@ -1,22 +0,0 @@
|
||||
{% assign identifier = include.page.url | remove: '.html' | remove_first: '/' %}
|
||||
{% if site.data.disqus.enabled %}
|
||||
<section class='comments-area' id='comments' data-js-no-preview>
|
||||
<div class='container'>
|
||||
<details class='comments-details'>
|
||||
<summary>
|
||||
<strong class='count'>
|
||||
<span class='disqus-comment-count' data-disqus-identifier="{{ identifier }}" data-disqus-url='{{ site.url }}/{{ identifier }}'>0 Comments</span>
|
||||
</strong>
|
||||
<span class='suffix'>{{ site.data.content.comments_area.suffix }}</span>
|
||||
<span class='fauxlink'>{{ site.data.content.comments_area.link }}</span>
|
||||
</summary>
|
||||
<div class='comments-section'>
|
||||
<div class='comments'>
|
||||
<div id='disqus_thread'></div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<noscript data-js-disqus='{"host":"{{ site.data.disqus.host }}","url":"{{ site.url }}/{{ identifier }}","identifier":"{{ identifier }}"}'></noscript>
|
||||
</section>
|
||||
{% endif %}
|
@ -1 +0,0 @@
|
||||
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=2)}([function(e,n){function t(e,n){var t=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;if(t)return t.call(e,n);if(e.parentNode){for(var r=e.parentNode.querySelectorAll(n),o=r.length;o--;0)if(r[o]===e)return!0;return!1}}e.exports=t},function(e,n,t){function r(e,n){if(n){if(Array.isArray(n))return void o(n,function(n){r(e,n)});if(e.classList){var t=n.split(" ").filter(Boolean);o(t,function(n){e.classList.add(n)})}else e.className+=" "+n}}var o=t(4);e.exports=r},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(){d||((0,c.default)(document.documentElement,"LoadDone"),d=!0)}var i=t(3),u=r(i),a=t(1),c=r(a),f=t(6),l=r(f),s=document.querySelector("[data-js-main-body]");s&&((0,u.default)(s),(0,c.default)(s,"-wrapified")),(0,l.default)(window,"load",o),setTimeout(o,5e3);var d=void 0},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}function i(e){u(e).forEach(function(e){(0,p.findChildren)(e,"[data-js-h3-section-list]").forEach(function(e){a(e)})})}function u(e){return c(e,{tag:"h2",wrapperFn:function(){return(0,p.createDiv)({class:"h2-section"})},bodyFn:function(){return(0,p.createDiv)({class:"body h3-section-list","data-js-h3-section-list":""})}})}function a(e){return c(e,{tag:"h3",wrapperFn:function(){return(0,p.createDiv)({class:"h3-section"})},bodyFn:function(){return(0,p.createDiv)({class:"body"})}})}function c(e,n){function t(e,n,t){var r=i(),o=e.className;o&&(0,d.default)(r,o),(0,p.before)(e,r);var a=u();return o&&(0,d.default)(a,o),(0,p.appendMany)(a,t),n&&r.appendChild(n),r.appendChild(a),r}var r=n.tag,i=n.wrapperFn,u=n.bodyFn,a=e.children[0],c=[];if(a&&!(0,l.default)(a,r)){var f=(0,p.nextUntil)(a,r);c.push(t(a,null,[a].concat(o(f))))}return(0,p.findChildren)(e,r).forEach(function(e){var n=(0,p.nextUntil)(e,r);c.push(t(e,e,n))}),c}Object.defineProperty(n,"__esModule",{value:!0}),n.default=i,n.groupify=c;var f=t(0),l=r(f),s=t(1),d=r(s),p=t(5)},function(e,n){function t(e,n){var t,r,o=e.length;if("number"==typeof o)for(t=0;t<o;t++)n(e[t],t);else{r=0;for(t in e)e.hasOwnProperty(t)&&n(e[t],t,r++)}return e}e.exports=t},function(e,n,t){"use strict";function r(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}function o(e,n){n.forEach(function(n){e.appendChild(n)})}function i(e,n){return u(e.nextSibling,n,[])}function u(e,n,t){return e?(0,s.default)(e,n)?t:u(e.nextSibling,n,[].concat(r(t),[e])):t}function a(e,n){e.parentNode.insertBefore(n,e)}function c(e,n){return[].slice.call(e.children).filter(function(e){return(0,s.default)(e,n)})}function f(e){var n=document.createElement("div");return Object.keys(e).forEach(function(t){n.setAttribute(t,e[t])}),n}Object.defineProperty(n,"__esModule",{value:!0}),n.appendMany=o,n.nextUntil=i,n.before=a,n.findChildren=c,n.createDiv=f;var l=t(0),s=function(e){return e&&e.__esModule?e:{default:e}}(l)},function(e,n){function t(e,n,t){e.addEventListener?e.addEventListener(n,t):e.attachEvent("on"+n,function(){t.call(e)})}e.exports=t}]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,5 +0,0 @@
|
||||
<!-- critical js -->
|
||||
<script>{% include 2017/critical/critical.js %}</script>
|
||||
<script src='{{base}}/assets/packed/vendor.js?t={{ timestamp }}'></script>
|
||||
<script src='{{base}}/assets/packed/app.js?t={{ timestamp }}'></script>
|
||||
{% for lang in page.prism_languages %}<script src='https://cdn.jsdelivr.net/npm/prismjs@1.6.0/components/prism-{{lang}}.min.js'></script>{% endfor %}
|
@ -1,24 +0,0 @@
|
||||
{% include meta.html %}
|
||||
{% include polyfills.html %}
|
||||
|
||||
<!-- critical css -->
|
||||
{% if include.critical == 'home'
|
||||
%}<style id='critical-css'>{% include 2017/critical/home.css %}</style>{%
|
||||
endif
|
||||
%}{%
|
||||
if include.critical == 'sheet'
|
||||
%}<style id='critical-css'>{% include 2017/critical/sheet.css %}</style>{%
|
||||
endif %}
|
||||
|
||||
<!-- allow disabling critical CSS optimization by passing ?nocrit=1 -->
|
||||
<script id='critical-css-disable'>if (~window.location.search.indexOf('nocrit')){;[].slice.call(document.querySelectorAll('#critical-css')).map(function(e){e.parentNode.removeChild(e)})}</script>
|
||||
|
||||
<!-- deferred css -->
|
||||
<script id='deferred-css'>;(function(links){(requestAnimationFrame||mozRequestAnimationFrame||webkitRequestAnimationFrame||msRequestAnimationFrame||(function(fn){window.addEventListener('load',fn)}))(function(){var h=document.getElementsByTagName('head')[0],l,i;for (i=0;i<links.length;i++){l=document.createElement('link');l.rel='stylesheet';l.href=links[i];h.appendChild(l);}})})([
|
||||
'https://fonts.googleapis.com/css?family=Cousine',
|
||||
'{{base}}/assets/2017/style.css?t={{ timestamp }}'
|
||||
])</script>
|
||||
<noscript id='deferred-css-fallback'>
|
||||
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Cousine'>
|
||||
<link rel='stylesheet' href='{{base}}/assets/2017/style.css?t={{ timestamp }}'>
|
||||
</noscript>
|
@ -1,41 +0,0 @@
|
||||
{% comment %}
|
||||
|
||||
This partial assigns these variables:
|
||||
|
||||
meta_image: "https://assets.devhints.io/previews/react.jpg"
|
||||
meta_description: "A comprehensive cheatsheet for React."
|
||||
meta_title: "React cheatsheet"
|
||||
depth: "1"
|
||||
base: "./"
|
||||
timestamp: "293048189123"
|
||||
page_url: "https://devhints.io/react"
|
||||
|
||||
It emits some blank lines because Jekyll, lol.
|
||||
|
||||
{% endcomment %}
|
||||
|
||||
{% assign depth = page.url | split: '/' | size | minus: 1 %}
|
||||
|
||||
{% assign base = '' %}
|
||||
{% if depth <= 1 %}{% assign base = '.' %}
|
||||
{% elsif depth == 2 %}{% assign base = '..' %}
|
||||
{% elsif depth == 3 %}{% assign base = '../..' %}
|
||||
{% elsif depth == 4 %}{% assign base = '../../..' %}{% endif %}
|
||||
|
||||
{% assign timestamp = site.time | date: "%Y%m%d%H%M%S" %}
|
||||
|
||||
{% if site.data.assets.preview_host %}{% capture meta_image %}{%
|
||||
if page.url == '/'
|
||||
%}{{ site.data.assets.preview_host }}/index.jpg?t={{ timestamp }}{%
|
||||
else
|
||||
%}{{ site.data.assets.preview_host }}{{ include.page.url | remove: '.html' }}.jpg?t={{ timestamp }}{%
|
||||
endif
|
||||
%}{% endcapture %}{% endif %}
|
||||
|
||||
{% capture meta_title %}{% include values/title.html page=include.page %}{% endcapture %}
|
||||
{% assign meta_title = meta_title | strip_newlines %}
|
||||
|
||||
{% capture meta_description %}{% include values/description.html page=include.page %}{% endcapture %}
|
||||
{% assign meta_description = meta_description | strip_newlines %}
|
||||
|
||||
{% capture page_url %}{{ site.url }}{{ page.url | remove: '.html' }}{% endcapture %}
|
@ -1,14 +0,0 @@
|
||||
{% assign slug = include.page.url | remove: '.html' | remove_first: '/' %}
|
||||
<a class='{{ include.class }} -item-{{ slug }}'
|
||||
href="{{base}}{{ include.page.url | remove: '.html' }}"
|
||||
data-js-searchable-item='{"slug":"{{ slug }}","category":"{{ include.page.category }}"}'>
|
||||
<span class='info'>
|
||||
<code class='slug'>{{ slug }}</code>
|
||||
|
||||
{% if include.page.layout == '2017/sheet' %}
|
||||
<abbr class='attribute-peg -new-layout hint--bottom' data-hint='New layout!'><span></span></abbr>
|
||||
{% endif %}
|
||||
|
||||
<span class='title'>{{ include.page.title }} {{ include.page.redirect_to }}</span>
|
||||
</span>
|
||||
</a>
|
@ -1,12 +0,0 @@
|
||||
<li class='{{ include.class }}'>
|
||||
<a href='{{ base }}{{ include.page.url | remove: '.html' }}'>
|
||||
<strong>{{ include.page.title }}</strong>
|
||||
<span>
|
||||
cheatsheet
|
||||
|
||||
{% if include.page.layout == '2017/sheet' %}
|
||||
<abbr class='attribute-peg -new-layout hint--bottom' data-hint='New layout!'><span></span></abbr>
|
||||
{% endif %}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
@ -1,62 +0,0 @@
|
||||
{% assign category_pages = site.pages
|
||||
| where: "category", include.page.category
|
||||
| where_exp: "page", "page.url != include.page.url"
|
||||
| where_exp: "page", "page.deprecated != true"
|
||||
| where_exp: "page", "page.redirect_to == null"
|
||||
| sort: "weight", "last"
|
||||
%}
|
||||
{% assign top_pages = site.pages
|
||||
| where_exp: "page", "page.url != include.page.url"
|
||||
| where_exp: "page", "page.deprecated != true"
|
||||
| sort: "weight", "last"
|
||||
%}
|
||||
{% assign size = site.pages | size %}
|
||||
<footer class='related-posts-area' id='related' data-js-no-preview>
|
||||
<div class='container'>
|
||||
<div class='related-posts-section'>
|
||||
<div class='callout'>
|
||||
<a class='related-posts-callout' href='{{ base }}'>
|
||||
<div class='text'>
|
||||
<i class='icon'></i>
|
||||
|
||||
<span class='description'>
|
||||
{{ site.data.content.related_posts_callout.description | replace: "SIZE", size }}
|
||||
</span>
|
||||
|
||||
<span class='push-button -dark'>
|
||||
{{ site.data.content.related_posts_callout.link }}
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class='group'>
|
||||
<div class='related-posts-group'>
|
||||
{% if include.page.category == 'Others' %}
|
||||
<h3>{{ site.data.content.related_posts_group.other }}</h3>
|
||||
{% else %}
|
||||
<h3>{{ site.data.content.related_posts_group.category | replace: "CATEGORY", include.page.category }}</h3>
|
||||
{% endif %}
|
||||
|
||||
<ul class='related-post-list'>
|
||||
{% for page in category_pages limit: 6 %}
|
||||
{% include 2017/related-posts-item.html page=page class='item related-post-item' %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='group'>
|
||||
<div class='related-posts-group'>
|
||||
<h3>{{ site.data.content.related_posts_group.top }}</h3>
|
||||
|
||||
<ul class='related-post-list'>
|
||||
{% for page in top_pages limit: 6 %}
|
||||
{% include 2017/related-posts-item.html page=page class='item related-post-item' %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
@ -1,12 +0,0 @@
|
||||
<footer class='search-footer' data-js-no-preview>
|
||||
<div class='container'>
|
||||
<div class='search-footer-section'>
|
||||
<div class='search'>
|
||||
{% include 2017/search-form.html class="-small" %}
|
||||
</div>
|
||||
<div class='links'>
|
||||
<a class='home-button' href='{{ base }}'><i></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
@ -1,19 +0,0 @@
|
||||
<form
|
||||
{% if include.live %}data-js-search-form{% endif %}
|
||||
class='search' action='{{ base }}' method='get'>
|
||||
<label class='search-box {{ include.class }}'>
|
||||
<span class='prefix'>{{ site.data.content.search_form.prefix }}</span>
|
||||
<span class='sep'>/</span>
|
||||
<input name='q'
|
||||
type='text'
|
||||
{% if include.live %}
|
||||
{% assign placeholder = site.data.content.search_form.home_placeholder | replace: "%{size}", size %}
|
||||
autofocus data-js-search-input
|
||||
placeholder='{{ placeholder }}'
|
||||
{% else %}
|
||||
{% assign size = site.pages | size %}
|
||||
{% assign placeholder = site.data.content.search_form.default_placeholder | replace: "SIZE", size %}
|
||||
placeholder='{{ placeholder }}'
|
||||
{% endif %}>
|
||||
</label>
|
||||
</form>
|
@ -1,35 +0,0 @@
|
||||
{% comment %}
|
||||
Params:
|
||||
- noshare
|
||||
- noedit
|
||||
- noback
|
||||
{% endcomment %}
|
||||
<nav class='top-nav' data-js-no-preview role='navigation'>
|
||||
<div class='container'>
|
||||
{% unless include.page.noback %}
|
||||
<div class='left'>
|
||||
<a class='home back-button' href='{{base}}'></a>
|
||||
</div>
|
||||
{% endunless %}
|
||||
|
||||
<a class='brand' href='{{base}}'>
|
||||
{{ site.data.content.top_nav.title }}
|
||||
</a>
|
||||
|
||||
{% unless include.noshare %}
|
||||
<div class='actions'>
|
||||
{% include social-list.html class="social page-actions" page=include.page %}
|
||||
|
||||
{% unless include.noedit %}
|
||||
<ul class='page-actions'>
|
||||
<li class='link github -button hint--bottom' data-hint='{{ site.data.content.top_nav.edit_on_github }}'>
|
||||
<a href='{{ site.github.repository_url }}/blob/master/{{ page.path | remove: '.html' }}'>
|
||||
<span class='text -visible'>{{ site.data.content.top_nav.edit }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endunless %}
|
||||
</div>
|
||||
{% endunless %}
|
||||
</div>
|
||||
</nav>
|
@ -1,20 +0,0 @@
|
||||
<div class="about-the-site">
|
||||
<div class="container">
|
||||
<p class='blurb'>
|
||||
<strong><a href="{{ base }}">{{ site.title }}</a></strong> is a collection of cheatsheets I've written over the years.
|
||||
Suggestions and corrections? <a href='https://github.com/rstacruz/cheatsheets/issues/907'>Send them in</a>.
|
||||
<i class='fleuron'></i>
|
||||
I'm <a href="http://ricostacruz.com">Rico Sta. Cruz</a>.
|
||||
Check out my <a href="http://ricostacruz.com/til">Today I learned blog</a> for more.
|
||||
</p>
|
||||
|
||||
{% if page.url != '/index.html' %}
|
||||
<p class='back'>
|
||||
<a class='big-button -back -slim' href='.#toc'></a>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
@ -5,18 +5,17 @@
|
||||
|
||||
#### Date
|
||||
|
||||
| Example | Output |
|
||||
| --- | --- |
|
||||
| `YYYY-MM-DD` | `2014-01-01` |
|
||||
| `dddd, MMMM Do YYYY` | `Friday, May 16th 2014` |
|
||||
{: .-shortcuts}
|
||||
| Example | Output |
|
||||
| ------------------------- | ---------------------- |
|
||||
| `YYYY-MM-DD` | 2014-01-01 |
|
||||
| `dddd, MMMM Do YYYY` | Friday, May 16th 2014 |
|
||||
| `dddd [the] Do [of] MMMM` | Friday the 16th of May |
|
||||
|
||||
#### Time
|
||||
|
||||
| Example | Output |
|
||||
| --- | --- |
|
||||
| `hh:mm a` | `12:30 pm` |
|
||||
{: .-shortcuts}
|
||||
| Example | Output |
|
||||
| --------- | -------- |
|
||||
| `hh:mm a` | 12:30 pm |
|
||||
|
||||
Used by [Moment.js](http://momentjs.com/docs/#/displaying/) and [date-fns/format](https://date-fns.org/v1.28.5/docs/format). Similar to Java [SimpleDateFormat](https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html).
|
||||
|
||||
@ -33,7 +32,7 @@ Used by [Moment.js](http://momentjs.com/docs/#/displaying/) and [date-fns/format
|
||||
| `YYYY` | `2013` | |
|
||||
| --- | --- | --- |
|
||||
| `M` | `1`..`12` _(Jan is 1)_ | **Month** |
|
||||
| `Mo` | `1st`..`31st` | |
|
||||
| `Mo` | `1st`..`12th` | |
|
||||
| `MM` | `01`..`12` _(Jan is 1)_ | |
|
||||
| `MMM` | `Jan` | |
|
||||
| `MMMM` | `January` | |
|
||||
@ -86,17 +85,16 @@ Used by [Moment.js](http://momentjs.com/docs/#/displaying/) and [date-fns/format
|
||||
|
||||
### Presets
|
||||
|
||||
| Example | Output |
|
||||
| --- | --- |
|
||||
| `LT` | `8:30 PM` |
|
||||
| `LTS` | `8:30:25 PM` |
|
||||
| --- | --- |
|
||||
| `LL` | `August 2 1985` |
|
||||
| `ll` | `Aug 2 1985` |
|
||||
| --- | --- |
|
||||
| `LLL` | `August 2 1985 08:30 PM` |
|
||||
| `lll` | `Aug 2 1985 08:30 PM` |
|
||||
| --- | --- |
|
||||
| `LLLL` | `Thursday, August 2 1985 08:30 PM` |
|
||||
| `llll` | `Thu, Aug 2 1985 08:30 PM` |
|
||||
{: .-shortcuts}
|
||||
| Example | Output |
|
||||
| ------- | -------------------------------- |
|
||||
| `LT` | 8:30 PM |
|
||||
| `LTS` | 8:30:25 PM |
|
||||
| --- | --- |
|
||||
| `LL` | August 2 1985 |
|
||||
| `ll` | Aug 2 1985 |
|
||||
| --- | --- |
|
||||
| `LLL` | August 2 1985 08:30 PM |
|
||||
| `lll` | Aug 2 1985 08:30 PM |
|
||||
| --- | --- |
|
||||
| `LLLL` | Thursday, August 2 1985 08:30 PM |
|
||||
| `llll` | Thu, Aug 2 1985 08:30 PM |
|
||||
|
@ -1,14 +0,0 @@
|
||||
{% include about-the-site.html %}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
|
||||
|
||||
{% comment %}<!-- https://github.com/highlightjs/cdn-release/tree/master/build/languages -->{% endcomment %}
|
||||
{% for lang in page.hljs_languages %}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/languages/{{lang}}.min.js"></script>
|
||||
{% endfor %}
|
||||
|
||||
<script src="https://cdn.rawgit.com/rstacruz/unorphan/v1.0.1/index.js"></script>
|
||||
<script>hljs.initHighlightingOnLoad()</script>
|
||||
<script>unorphan('h1, h2, h3, p, li, .unorphan')</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,12 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang='en' class='no-js {{ page.html_class }}'>
|
||||
<head>
|
||||
{% include meta.html %}
|
||||
{% include polyfills.html %}
|
||||
<style>html{opacity:0}</style>
|
||||
<link href="https://ricostacruz.com/til/assets/style.css?t={{ timestamp }}" rel="stylesheet" />
|
||||
<link href="{{base}}/assets/style.css?t={{ timestamp }}" rel="stylesheet" />
|
||||
<link href="{{base}}/assets/print.css?t={{ timestamp }}" rel="stylesheet" media="print" />
|
||||
</head>
|
||||
<body>
|
||||
<div class='all'>
|
@ -1,85 +0,0 @@
|
||||
{% include 2017/meta-vars.html page=page %}
|
||||
<meta charset='utf-8'>
|
||||
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
|
||||
<link href='{{ base }}/assets/favicon.png' rel='shortcut icon'>
|
||||
<meta content='{{ page.url }}' name='app:pageurl'>
|
||||
|
||||
{% if meta_title %}
|
||||
<title>{{ meta_title }}</title>
|
||||
<meta content='{{ meta_title }}' property='og:title'>
|
||||
<meta content='{{ meta_title }}' property='twitter:title'>
|
||||
<meta content='{{ page.og_type | default: "article" }}' property='og:type'>
|
||||
{% endif %}
|
||||
|
||||
{% if meta_image %}
|
||||
<meta content='{{ meta_image | escape }}' property='og:image'>
|
||||
<meta content='{{ meta_image | escape }}' property='twitter:image'>
|
||||
<meta content='900' property='og:image:width'>
|
||||
<meta content='471' property='og:image:height'>
|
||||
{% endif %}
|
||||
|
||||
{% if meta_description %}
|
||||
<meta content="{{ meta_description | escape }}" name="description">
|
||||
<meta content="{{ meta_description | escape }}" property="og:description">
|
||||
<meta content="{{ meta_description | escape }}" property="twitter:description">
|
||||
{% endif %}
|
||||
|
||||
<link rel="canonical" href="{{ page_url }}">
|
||||
<meta name="og:url" content="{{ page_url }}">
|
||||
{% if page.url == '/' %}
|
||||
<link rel="prefetch" href="{{ site.url }}">
|
||||
<link rel="prerender" href="{{ site.url }}">
|
||||
{% endif %}
|
||||
|
||||
{% if page.author %}
|
||||
{% for author in site.authors | where: "name", page.author %}
|
||||
<meta content='{{ author.name }}' name='author'>
|
||||
{% if author.ogp %}
|
||||
<meta content='{{ author.ogp }}' property='article:author'>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if site.title %}
|
||||
<meta content='{{ site.title }}' property='og:site_name'>
|
||||
{% endif %}
|
||||
|
||||
{% if site.facebook.app_id %}
|
||||
<meta content='{{ site.facebook.app_id }}' property='fb:app_id'>
|
||||
{% endif %}
|
||||
|
||||
{% if site.facebook.admin %}
|
||||
<meta content='{{ site.facebook.admin }}' property='fb:admins'>
|
||||
{% endif %}
|
||||
|
||||
{% if page.date %}
|
||||
<meta content='{{ page.date | date: "%Y-%m-%d" }}' property='article:published_date'>
|
||||
{% endif %}
|
||||
|
||||
{% if page.category %}
|
||||
<meta content='{{ page.category }}' property='article:section'>
|
||||
{% endif %}
|
||||
|
||||
{% if page.tags %}
|
||||
{% for tag in page.tags %}
|
||||
<meta content='{{ tag }}' property='article:tag'>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if site.data.google_analytics.enabled %}
|
||||
<script async src='https://www.googletagmanager.com/gtag/js?id={{ site.data.google_analytics.id }}'></script>
|
||||
<script>
|
||||
{% comment %} if(~location.hostname.indexOf('{{site.data.google_analytics.hostname}}')){ {% endcomment %}
|
||||
window.dataLayer=window.dataLayer||[];
|
||||
function gtag(){dataLayer.push(arguments)};
|
||||
gtag('js',new Date());
|
||||
gtag('config','{{ site.data.google_analytics.id }}');
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
{% if depth %}
|
||||
<meta property='page:depth' content='{{depth}}'>
|
||||
{% endif %}
|
||||
|
||||
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
|
||||
<script>(function(H){H.className=H.className.replace(/\bNoJs\b/,'WithJs')})(document.documentElement)</script>
|
@ -1,9 +0,0 @@
|
||||
<script>(function(d,s){if(window.Promise&&[].includes&&Object.assign&&window.Map)return;var js,sc=d.getElementsByTagName(s)[0];js=d.createElement(s);js.src='https://cdn.polyfill.io/v2/polyfill.min.js';sc.parentNode.insertBefore(js, sc);}(document,'script'))</script>
|
||||
|
||||
<!--[if lt IE 9]>{%comment%}
|
||||
{%endcomment%}<script src='https://cdnjs.cloudflare.com/ajax/libs/nwmatcher/1.2.5/nwmatcher.min.js'></script>{%comment%}
|
||||
{%endcomment%}<script src='https://cdnjs.cloudflare.com/ajax/libs/json2/20140204/json2.js'></script>{%comment%}
|
||||
{%endcomment%}<script src='https://cdn.rawgit.com/gisu/selectivizr/1.0.3/selectivizr.js'></script>{%comment%}
|
||||
{%endcomment%}<script src='https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js'></script>{%comment%}
|
||||
{%endcomment%}<script src='https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js'></script>{%comment%}
|
||||
{%endcomment%}<![endif]-->
|
@ -1,6 +0,0 @@
|
||||
<div class='site-header'>
|
||||
<div class='container'>
|
||||
This is <a href="."><em>{{ site.title }}</em></a> — a collection of cheatsheets I've written.
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,12 +0,0 @@
|
||||
{% if include.page.type == 'home' %}
|
||||
{% assign description = site.data.content.social_list.default_description %}
|
||||
{% else %}
|
||||
{% assign description = site.data.content.social_list.description | replace: "TITLE", include.page.title %}
|
||||
{% endif %}
|
||||
<ul class="social-list {{ include.class }}">
|
||||
<li class="facebook link hint--bottom" data-hint="{{ site.data.content.social_list.facebook_share }}"><a href="https://www.facebook.com/sharer/sharer.php?u={{ site.url | uri_escape }}{{ include.page.url | uri_escape }}" target="share"><span class="text"></span></a></li>
|
||||
<li class="twitter link hint--bottom" data-hint="{{ site.data.content.social_list.twitter_share }}"><a href="https://twitter.com/intent/tweet?text={{ description | uri_escape }}%20{{ site.url | uri_escape }}{{ include.page.url | uri_escape }}" target="share"><span class="text"></span></a></li>
|
||||
{% comment %}
|
||||
<li class="googleplus link hint--bottom" data-hint="Share on Google Plus"><a href="https://plus.google.com/share?url={{ site.url }}{{ include.page.url }}" target="share"><span class="text">+1</span></a></li>-->
|
||||
{% endcomment %}
|
||||
</ul>
|
@ -1,17 +0,0 @@
|
||||
{%
|
||||
if page.description and page.intro
|
||||
%}{{ page.description }} {{ page.intro | markdownify | strip_html }}{%
|
||||
elsif page.description
|
||||
%}{{ page.description }} · One-page guide to {{ page.title }}{%
|
||||
elsif page.keywords and page.intro
|
||||
%}{{ page.keywords | join: ' · ' }} · {{ page.intro | markdownify | strip_html }}{%
|
||||
elsif page.keywords
|
||||
%}{{ page.keywords | join: ' · ' }} · One-page guide to {{ page.title }}{%
|
||||
elsif page.intro
|
||||
%}One-page guide to {{ page.title }}: usage, examples, and more. {{ page.intro | markdownify | strip_html }}{%
|
||||
elsif page.type == 'article'
|
||||
%}The one-page guide to {{ page.title }}: usage, examples, links, snippets, and more.{%
|
||||
else
|
||||
%}The one-page guide to {{ page.title }}: usage, examples, links, snippets, and more.{%
|
||||
endif
|
||||
%}
|
@ -1,11 +0,0 @@
|
||||
{%
|
||||
if page.full_title
|
||||
%}{{ page.full_title }}{%
|
||||
elsif page.type == 'article'
|
||||
%}{{ page.title }} cheatsheet{%
|
||||
elsif page.title
|
||||
%}{{ page.title }}{%
|
||||
else
|
||||
%}{{ site.title }}{%
|
||||
endif
|
||||
%}
|
@ -1,7 +0,0 @@
|
||||
// 3rd party libs
|
||||
window.Prism = require('prismjs')
|
||||
|
||||
// All the others
|
||||
function requireAll (r) { r.keys().forEach(r) }
|
||||
requireAll(require.context('./initializers/', true, /\.js$/))
|
||||
requireAll(require.context('./behaviors/', true, /\.js$/))
|
@ -1,44 +0,0 @@
|
||||
import onmount from 'onmount'
|
||||
import prepend from 'dom101/prepend'
|
||||
|
||||
const DEFAULTS = {
|
||||
// select elements to put anchor on
|
||||
rule: 'h2[id]',
|
||||
// class name for anchor
|
||||
className: 'local-anchor anchor',
|
||||
// text of anchor
|
||||
text: '#',
|
||||
// append before or after innerText?
|
||||
shouldAppend: false,
|
||||
}
|
||||
|
||||
/*
|
||||
* Behavior: Add local anchors
|
||||
*/
|
||||
|
||||
onmount('[data-js-anchors]', function () {
|
||||
const data = JSON.parse(this.getAttribute('data-js-anchors') || '{}')
|
||||
const rules = Array.isArray(data)
|
||||
? (data.length ? data : [DEFAULTS])
|
||||
: [Object.assign({}, DEFAULTS, data)]
|
||||
|
||||
for (const { rule, className, text, shouldAppend } of rules) {
|
||||
for (const el of this.querySelectorAll(rule)) {
|
||||
if (!el.hasAttribute('id')) {
|
||||
continue
|
||||
}
|
||||
|
||||
const id = el.getAttribute('id')
|
||||
const anchor = document.createElement('a')
|
||||
anchor.setAttribute('href', `#${id}`)
|
||||
anchor.setAttribute('class', className)
|
||||
anchor.innerText = String(text || DEFAULTS.text)
|
||||
|
||||
if (shouldAppend) {
|
||||
el.appendChild(anchor)
|
||||
} else {
|
||||
prepend(el, anchor)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
@ -1,22 +0,0 @@
|
||||
import closest from 'dom101/closest'
|
||||
import remove from 'dom101/remove'
|
||||
import on from 'dom101/on'
|
||||
import { getData } from '../helpers/data'
|
||||
import onmount from 'onmount'
|
||||
import * as Dismiss from '../helpers/dismiss'
|
||||
|
||||
/**
|
||||
* Dismiss button
|
||||
*/
|
||||
|
||||
onmount('[data-js-dismiss]', function () {
|
||||
const parent = closest(this, '[data-js-dismissable]')
|
||||
const dismissable = getData(parent, 'js-dismissable')
|
||||
const id = (dismissable && dismissable.id) || ''
|
||||
|
||||
on(this, 'click', e => {
|
||||
Dismiss.setDismissed(id)
|
||||
e.preventDefault()
|
||||
if (parent) remove(parent)
|
||||
})
|
||||
})
|
@ -1,17 +0,0 @@
|
||||
import onmount from 'onmount'
|
||||
import remove from 'dom101/remove'
|
||||
import removeClass from 'dom101/remove-class'
|
||||
|
||||
import { getData } from '../helpers/data'
|
||||
import { isDismissed } from '../helpers/dismiss'
|
||||
import { isPreview } from '../helpers/preview'
|
||||
|
||||
onmount('[data-js-dismissable]', function () {
|
||||
const id = getData(this, 'js-dismissable').id || ''
|
||||
|
||||
if (isPreview() || isDismissed(id)) {
|
||||
remove(this)
|
||||
} else {
|
||||
removeClass(this, '-hide')
|
||||
}
|
||||
})
|
@ -1,32 +0,0 @@
|
||||
import onmount from 'onmount'
|
||||
import injectDisqus from '../helpers/inject_disqus'
|
||||
|
||||
/**
|
||||
* Delay disqus by some time. It's at the bottom of the page, there's no need
|
||||
* for it to load fast. This will give more time to load more critical assets.
|
||||
*/
|
||||
|
||||
const DISQUS_DELAY = 100
|
||||
|
||||
/**
|
||||
* Injects Disqus onto the page.
|
||||
*/
|
||||
|
||||
onmount('[data-js-disqus]', function () {
|
||||
const data = JSON.parse(this.getAttribute('data-js-disqus'))
|
||||
const $parent = this.parentNode
|
||||
$parent.setAttribute('hidden', true)
|
||||
|
||||
window.disqus_config = function () {
|
||||
this.page.url = data.url
|
||||
this.page.identifier = data.identifier
|
||||
}
|
||||
|
||||
// Disqus takes a while to load, don't do it so eagerly.
|
||||
window.addEventListener('load', () => {
|
||||
setTimeout(() => {
|
||||
injectDisqus(data.host)
|
||||
$parent.removeAttribute('hidden')
|
||||
}, DISQUS_DELAY)
|
||||
})
|
||||
})
|
@ -1,32 +0,0 @@
|
||||
/* eslint-disable no-new */
|
||||
|
||||
import Isotope from 'isotope-layout/dist/isotope.pkgd.js'
|
||||
import onmount from 'onmount'
|
||||
import on from 'dom101/on'
|
||||
import qsa from 'dom101/query-selector-all'
|
||||
|
||||
/*
|
||||
* Behavior: Isotope
|
||||
*/
|
||||
|
||||
onmount('[data-js-h3-section-list]', function () {
|
||||
const iso = new Isotope(this, {
|
||||
itemSelector: '.h3-section',
|
||||
transitionDuration: 0
|
||||
})
|
||||
|
||||
const images = qsa('img', this)
|
||||
|
||||
images.forEach(image => {
|
||||
on(image, 'load', () => {
|
||||
iso.layout()
|
||||
})
|
||||
})
|
||||
|
||||
// Insurance against weirdness on pages like devhints.io/vim, where the
|
||||
// critical path CSS may look different from the final CSS (because of the
|
||||
// tables).
|
||||
on(window, 'load', () => {
|
||||
iso.layout()
|
||||
})
|
||||
})
|
@ -1,16 +0,0 @@
|
||||
import remove from 'dom101/remove'
|
||||
import onmount from 'onmount'
|
||||
import addClass from 'dom101/add-class'
|
||||
|
||||
import { isPreview } from '../helpers/preview'
|
||||
|
||||
/*
|
||||
* Behavior: Things to remove when preview mode is on
|
||||
*/
|
||||
|
||||
onmount('[data-js-no-preview]', function (b) {
|
||||
if (isPreview()) {
|
||||
remove(this)
|
||||
addClass(document.documentElement, 'PreviewMode')
|
||||
}
|
||||
})
|
@ -1,17 +0,0 @@
|
||||
import onmount from 'onmount'
|
||||
import on from 'dom101/on'
|
||||
|
||||
/**
|
||||
* Submitting the search form
|
||||
*/
|
||||
|
||||
onmount('[data-js-search-form]', function () {
|
||||
on(this, 'submit', e => {
|
||||
e.preventDefault()
|
||||
|
||||
const link = document.querySelector('a[data-search-index]:visible')
|
||||
const href = link && link.getAttribute('href')
|
||||
|
||||
if (href) window.location = href
|
||||
})
|
||||
})
|
@ -1,22 +0,0 @@
|
||||
import onmount from 'onmount'
|
||||
import * as Search from '../helpers/search'
|
||||
import qs from '../helpers/qs'
|
||||
import on from 'dom101/on'
|
||||
|
||||
onmount('[data-js-search-input]', function () {
|
||||
on(this, 'input', () => {
|
||||
const val = this.value
|
||||
|
||||
if (val === '') {
|
||||
Search.showAll()
|
||||
} else {
|
||||
Search.show(val)
|
||||
}
|
||||
})
|
||||
|
||||
const query = (qs(window.location.search) || {}).q
|
||||
if (query && query.length) {
|
||||
this.value = query
|
||||
setTimeout(() => { Search.show(query) })
|
||||
}
|
||||
})
|
@ -1,22 +0,0 @@
|
||||
import onmount from 'onmount'
|
||||
import { nextUntil } from '../helpers/dom'
|
||||
import matches from 'dom101/matches'
|
||||
|
||||
// Ensure that search-index is set first
|
||||
import './searchable-item'
|
||||
|
||||
/**
|
||||
* Propagate item search indices to headers
|
||||
*/
|
||||
|
||||
onmount('[data-js-searchable-header]', function () {
|
||||
const els = nextUntil(this, '[data-js-searchable-header]')
|
||||
.filter(el => matches(el, '[data-search-index]'))
|
||||
|
||||
const keywords = els
|
||||
.map(n => n.getAttribute('data-search-index'))
|
||||
.join(' ')
|
||||
.split(' ')
|
||||
|
||||
this.setAttribute('data-search-index', keywords.join(' '))
|
||||
})
|
@ -1,13 +0,0 @@
|
||||
import onmount from 'onmount'
|
||||
import permutate from '../helpers/permutate'
|
||||
|
||||
/**
|
||||
* Sets search indices (`data-search-index` attribute)
|
||||
*/
|
||||
|
||||
onmount('[data-js-searchable-item]', function () {
|
||||
const data = JSON.parse(this.getAttribute('data-js-searchable-item') || '{}')
|
||||
const words = permutate(data)
|
||||
|
||||
this.setAttribute('data-search-index', words.join(' '))
|
||||
})
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* This is the "critical path" JavaScript that will be included INLINE on every
|
||||
* page. Keep this as small as possible!
|
||||
*/
|
||||
|
||||
import wrapify from './wrapify'
|
||||
import addClass from 'dom101/add-class'
|
||||
import on from 'dom101/on'
|
||||
|
||||
// Transform the main body markup to make it readable.
|
||||
const body = document.querySelector('[data-js-main-body]')
|
||||
|
||||
if (body) {
|
||||
wrapify(body)
|
||||
addClass(body, '-wrapified')
|
||||
}
|
||||
|
||||
// Be "done" when we're done, or after a certain timeout.
|
||||
on(window, 'load', done)
|
||||
setTimeout(done, 5000)
|
||||
|
||||
let isDone
|
||||
function done () {
|
||||
if (isDone) return
|
||||
addClass(document.documentElement, 'LoadDone')
|
||||
isDone = true
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/* eslint-env jest */
|
||||
import qs from '../qs'
|
||||
|
||||
describe('qs()', () => {
|
||||
test('basic', run({
|
||||
input: '?preview=1',
|
||||
output: { preview: '1' }
|
||||
}))
|
||||
|
||||
test('two fragments', run({
|
||||
input: '?a=1&b=2',
|
||||
output: { a: '1', b: '2' }
|
||||
}))
|
||||
|
||||
function run ({ input, output }) {
|
||||
return function () {
|
||||
const result = qs(input)
|
||||
expect(result).toEqual(output)
|
||||
}
|
||||
}
|
||||
})
|
@ -1,61 +0,0 @@
|
||||
import matches from 'dom101/matches'
|
||||
|
||||
/*
|
||||
* Just like jQuery.append
|
||||
*/
|
||||
|
||||
export function appendMany (el, children) {
|
||||
children.forEach(child => { el.appendChild(child) })
|
||||
}
|
||||
|
||||
/*
|
||||
* Just like jQuery.nextUntil
|
||||
*/
|
||||
|
||||
export function nextUntil (el, selector) {
|
||||
const nextEl = el.nextSibling
|
||||
return nextUntilTick(nextEl, selector, [])
|
||||
}
|
||||
|
||||
function nextUntilTick (el, selector, acc) {
|
||||
if (!el) return acc
|
||||
|
||||
const isMatch = matches(el, selector)
|
||||
if (isMatch) return acc
|
||||
|
||||
return nextUntilTick(el.nextSibling, selector, [ ...acc, el ])
|
||||
}
|
||||
|
||||
/*
|
||||
* Just like jQuery.before
|
||||
*/
|
||||
|
||||
export function before (reference, newNode) {
|
||||
reference.parentNode.insertBefore(newNode, reference)
|
||||
}
|
||||
|
||||
/*
|
||||
* Like jQuery.children('selector')
|
||||
*/
|
||||
|
||||
export function findChildren (el, selector) {
|
||||
return [].slice.call(el.children)
|
||||
.filter(child => matches(child, selector))
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a div
|
||||
* @private
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* createDiv({ class: 'foo' })
|
||||
*/
|
||||
|
||||
export function createDiv (props) {
|
||||
const d = document.createElement('div')
|
||||
Object.keys(props).forEach(key => {
|
||||
d.setAttribute(key, props[key])
|
||||
})
|
||||
return d
|
||||
}
|
@ -1 +0,0 @@
|
||||
/* blank */
|
@ -1,71 +0,0 @@
|
||||
/**
|
||||
* Permutates a searcheable item.
|
||||
*
|
||||
* permutate({
|
||||
* slug: 'hello-world',
|
||||
* category: 'greetings'
|
||||
* })
|
||||
*/
|
||||
|
||||
export default function permutate (data) {
|
||||
let words = []
|
||||
if (data.slug) {
|
||||
words = words.concat(permutateString(data.slug))
|
||||
}
|
||||
if (data.category) {
|
||||
words = words.concat(permutateString(data.category))
|
||||
}
|
||||
return words
|
||||
}
|
||||
|
||||
/**
|
||||
* Permutates strings.
|
||||
*
|
||||
* @example
|
||||
* permutateString('hi joe')
|
||||
* => ['h', 'hi', 'j', 'jo', 'joe']
|
||||
*/
|
||||
|
||||
export function permutateString (str) {
|
||||
let words = []
|
||||
let inputs = splitwords(str)
|
||||
|
||||
inputs.forEach(word => {
|
||||
words = words.concat(permutateWord(word))
|
||||
})
|
||||
|
||||
return words
|
||||
}
|
||||
|
||||
/**
|
||||
* Permutates a word.
|
||||
*
|
||||
* @example
|
||||
* permutateWord('hello')
|
||||
* => ['h', 'he', 'hel', 'hell', 'hello']
|
||||
*/
|
||||
|
||||
export function permutateWord (str) {
|
||||
let words = []
|
||||
const len = str.length
|
||||
for (var i = 1; i <= len; ++i) {
|
||||
words.push(str.substr(0, i))
|
||||
}
|
||||
return words
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for splitting to words.
|
||||
*
|
||||
* @example
|
||||
* splitWords('Hello, world!')
|
||||
* => ['hello', 'world']
|
||||
*/
|
||||
|
||||
export function splitwords (str) {
|
||||
const words = str.toLowerCase()
|
||||
.split(/[ /\-_]/)
|
||||
.filter(k => k && k.length !== 0)
|
||||
|
||||
return words
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
import { splitwords } from './permutate'
|
||||
import qsa from 'dom101/query-selector-all'
|
||||
|
||||
/**
|
||||
* Show everything.
|
||||
*
|
||||
* @example
|
||||
* Search.showAll()
|
||||
*/
|
||||
|
||||
export function showAll () {
|
||||
qsa('[data-search-index]').forEach(el => {
|
||||
el.removeAttribute('aria-hidden')
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for a given keyword.
|
||||
*
|
||||
* @example
|
||||
* Search.show('hello')
|
||||
*/
|
||||
|
||||
export function show (val) {
|
||||
const keywords = splitwords(val)
|
||||
|
||||
if (!keywords.length) return showAll()
|
||||
|
||||
const selectors = keywords
|
||||
.map(k => `[data-search-index~=${JSON.stringify(k)}]`)
|
||||
.join('')
|
||||
|
||||
qsa('[data-search-index]').forEach(el => {
|
||||
el.setAttribute('aria-hidden', true)
|
||||
})
|
||||
|
||||
qsa(selectors).forEach(el => {
|
||||
el.removeAttribute('aria-hidden')
|
||||
})
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
import ready from 'dom101/ready'
|
||||
import onmount from 'onmount'
|
||||
|
||||
/**
|
||||
* Behavior: Wrapping
|
||||
*/
|
||||
|
||||
ready(() => {
|
||||
setTimeout(() => { onmount() })
|
||||
})
|
@ -1,274 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`h2 + pre 1`] = `
|
||||
<div>
|
||||
|
||||
|
||||
<div
|
||||
class="h2-section"
|
||||
>
|
||||
<h2>
|
||||
heading
|
||||
</h2>
|
||||
<div
|
||||
class="body h3-section-list"
|
||||
data-js-h3-section-list=""
|
||||
>
|
||||
|
||||
|
||||
<div
|
||||
class="h3-section language-markdown"
|
||||
>
|
||||
<div
|
||||
class="body language-markdown"
|
||||
>
|
||||
<pre
|
||||
class="language-markdown"
|
||||
>
|
||||
(code)
|
||||
</pre>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`h3 with class 1`] = `
|
||||
<div>
|
||||
|
||||
|
||||
<div
|
||||
class="h2-section -hello"
|
||||
>
|
||||
<div
|
||||
class="body h3-section-list -hello"
|
||||
data-js-h3-section-list=""
|
||||
>
|
||||
<div
|
||||
class="h3-section -hello"
|
||||
>
|
||||
<h3
|
||||
class="-hello"
|
||||
>
|
||||
install
|
||||
</h3>
|
||||
<div
|
||||
class="body -hello"
|
||||
>
|
||||
|
||||
|
||||
<p>
|
||||
(install)
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`multiple h2s 1`] = `
|
||||
<div>
|
||||
|
||||
|
||||
<div
|
||||
class="h2-section"
|
||||
>
|
||||
<h2>
|
||||
multiple h2
|
||||
</h2>
|
||||
<div
|
||||
class="body h3-section-list"
|
||||
data-js-h3-section-list=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="h2-section"
|
||||
>
|
||||
<h2>
|
||||
|
||||
|
||||
|
||||
</h2>
|
||||
<div
|
||||
class="body h3-section-list"
|
||||
data-js-h3-section-list=""
|
||||
>
|
||||
<div
|
||||
class="h3-section"
|
||||
>
|
||||
<h3>
|
||||
install
|
||||
</h3>
|
||||
<div
|
||||
class="body"
|
||||
>
|
||||
|
||||
|
||||
<p>
|
||||
(install)
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="h3-section"
|
||||
>
|
||||
<h3>
|
||||
usage
|
||||
</h3>
|
||||
<div
|
||||
class="body"
|
||||
>
|
||||
|
||||
|
||||
<p>
|
||||
(usage)
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="h2-section"
|
||||
>
|
||||
<h2>
|
||||
getting started
|
||||
</h2>
|
||||
<div
|
||||
class="body h3-section-list"
|
||||
data-js-h3-section-list=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="h2-section"
|
||||
>
|
||||
<h2>
|
||||
|
||||
|
||||
|
||||
</h2>
|
||||
<div
|
||||
class="body h3-section-list"
|
||||
data-js-h3-section-list=""
|
||||
>
|
||||
<div
|
||||
class="h3-section"
|
||||
>
|
||||
<h3>
|
||||
first
|
||||
</h3>
|
||||
<div
|
||||
class="body"
|
||||
>
|
||||
|
||||
|
||||
<p>
|
||||
(first)
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="h3-section"
|
||||
>
|
||||
<h3>
|
||||
second
|
||||
</h3>
|
||||
<div
|
||||
class="body"
|
||||
>
|
||||
|
||||
|
||||
<p>
|
||||
(second)
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`simple usage 1`] = `
|
||||
<div>
|
||||
|
||||
|
||||
<div
|
||||
class="h2-section"
|
||||
>
|
||||
<h2>
|
||||
simple usage
|
||||
</h2>
|
||||
<div
|
||||
class="body h3-section-list"
|
||||
data-js-h3-section-list=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="h2-section"
|
||||
>
|
||||
<h2>
|
||||
|
||||
|
||||
|
||||
</h2>
|
||||
<div
|
||||
class="body h3-section-list"
|
||||
data-js-h3-section-list=""
|
||||
>
|
||||
<div
|
||||
class="h3-section"
|
||||
>
|
||||
<h3>
|
||||
install
|
||||
</h3>
|
||||
<div
|
||||
class="body"
|
||||
>
|
||||
|
||||
|
||||
<p>
|
||||
(install)
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="h3-section"
|
||||
>
|
||||
<h3>
|
||||
usage
|
||||
</h3>
|
||||
<div
|
||||
class="body"
|
||||
>
|
||||
|
||||
|
||||
<p>
|
||||
(usage)
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
@ -1,63 +0,0 @@
|
||||
/* eslint-env jest */
|
||||
import wrapify from '../index'
|
||||
import $ from 'jquery'
|
||||
|
||||
it('simple usage', run(`
|
||||
<div>
|
||||
<h2>simple usage<h2>
|
||||
|
||||
<h3>install</h3>
|
||||
<p>(install)</p>
|
||||
|
||||
<h3>usage</h3>
|
||||
<p>(usage)</p>
|
||||
</div>
|
||||
`, $div => {
|
||||
expect($div.find('.h2-section .h3-section-list .h3-section').length).toEqual(2)
|
||||
}))
|
||||
|
||||
it('h3 with class', run(`
|
||||
<div>
|
||||
<h3 class='-hello'>install</h3>
|
||||
<p>(install)</p>
|
||||
</div>
|
||||
`, $div => {
|
||||
expect($div.find('div.h3-section.-hello').length).toEqual(1)
|
||||
expect($div.find('div.h3-section-list.-hello').length).toEqual(1)
|
||||
}))
|
||||
|
||||
it('multiple h2s', run(`
|
||||
<div>
|
||||
<h2>multiple h2<h2>
|
||||
|
||||
<h3>install</h3>
|
||||
<p>(install)</p>
|
||||
|
||||
<h3>usage</h3>
|
||||
<p>(usage)</p>
|
||||
|
||||
<h2>getting started<h2>
|
||||
|
||||
<h3>first</h3>
|
||||
<p>(first)</p>
|
||||
|
||||
<h3>second</h3>
|
||||
<p>(second)</p>
|
||||
</div>
|
||||
`))
|
||||
|
||||
function run (input, fn) {
|
||||
return function () {
|
||||
const $div = $(input)
|
||||
wrapify($div[0])
|
||||
expect($div[0]).toMatchSnapshot()
|
||||
if (fn) fn($div)
|
||||
}
|
||||
}
|
||||
|
||||
it('h2 + pre', run(`
|
||||
<div>
|
||||
<h2>heading</h2>
|
||||
<pre class='language-markdown'>(code)</pre>
|
||||
</div>
|
||||
`))
|
@ -1,110 +0,0 @@
|
||||
import matches from 'dom101/matches'
|
||||
import addClass from 'dom101/add-class'
|
||||
import { appendMany, nextUntil, before, findChildren, createDiv } from '../helpers/dom'
|
||||
|
||||
/**
|
||||
* Wraps h2 sections into h2-section.
|
||||
* Wraps h3 sections into h3-section.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
export default function wrapify (root) {
|
||||
// These are your H2 sections. Returns a list of .h2-section nodes.
|
||||
const sections = wrapifyH2(root)
|
||||
|
||||
// For each h2 section, wrap the H3's in them
|
||||
sections.forEach(section => {
|
||||
const bodies = findChildren(section, '[data-js-h3-section-list]')
|
||||
bodies.forEach(body => { wrapifyH3(body) })
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps h2 sections into h2-section.
|
||||
* Creates and HTML structure like so:
|
||||
*
|
||||
* .h2-section
|
||||
* h2.
|
||||
* (title)
|
||||
* .body.h3-section-list.
|
||||
* (body goes here)
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
function wrapifyH2 (root) {
|
||||
return groupify(root, {
|
||||
tag: 'h2',
|
||||
wrapperFn: () => createDiv({ class: 'h2-section' }),
|
||||
bodyFn: () => createDiv({
|
||||
class: 'body h3-section-list',
|
||||
'data-js-h3-section-list': ''
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps h3 sections into h3-section.
|
||||
* Creates and HTML structure like so:
|
||||
*
|
||||
* .h3-section
|
||||
* h3.
|
||||
* (title)
|
||||
* .body.
|
||||
* (body goes here)
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
function wrapifyH3 (root) {
|
||||
return groupify(root, {
|
||||
tag: 'h3',
|
||||
wrapperFn: () => createDiv({ class: 'h3-section' }),
|
||||
bodyFn: () => createDiv({ class: 'body' })
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Groups all headings (a `tag` selector) under wrappers like `.h2-section`
|
||||
* (build by `wrapperFn()`).
|
||||
* @private
|
||||
*/
|
||||
|
||||
export function groupify (el, { tag, wrapperFn, bodyFn }) {
|
||||
const first = el.children[0]
|
||||
let result = []
|
||||
|
||||
// Handle the markup before the first h2
|
||||
if (first && !matches(first, tag)) {
|
||||
const sibs = nextUntil(first, tag)
|
||||
result.push(wrap(first, null, [ first, ...sibs ]))
|
||||
}
|
||||
|
||||
// Find all h3's inside it
|
||||
const children = findChildren(el, tag)
|
||||
|
||||
children.forEach(child => {
|
||||
const sibs = nextUntil(child, tag)
|
||||
result.push(wrap(child, child, sibs))
|
||||
})
|
||||
|
||||
return result
|
||||
|
||||
function wrap (pivot, first, sibs) {
|
||||
const wrap = wrapperFn()
|
||||
|
||||
const pivotClass = pivot.className
|
||||
if (pivotClass) addClass(wrap, pivotClass)
|
||||
before(pivot, wrap)
|
||||
|
||||
const body = bodyFn()
|
||||
if (pivotClass) addClass(body, pivotClass)
|
||||
appendMany(body, sibs)
|
||||
|
||||
if (first) wrap.appendChild(first)
|
||||
wrap.appendChild(body)
|
||||
|
||||
return wrap
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class='NoJs' lang='en'><head>
|
||||
|
||||
{% assign featured_pages = site.pages
|
||||
| where_exp: "page", "page.tags contains 'Featured'"
|
||||
%}
|
||||
{% assign recent_pages = site.pages
|
||||
| where_exp: "page", "page.updated"
|
||||
| sort: "updated", "first"
|
||||
%}
|
||||
{% include 2017/head.html critical='home' %}
|
||||
|
||||
</head><body>
|
||||
|
||||
{% include 2017/top-nav.html page=page is_home=true noedit=true noback=true %}
|
||||
|
||||
{% if site.data.carbon.enabled %}
|
||||
<div class='SideAd' role='complementary'>
|
||||
<script async src='{{ site.data.carbon.src }}' id="_carbonads_js"></script>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class='body-area -slim'>
|
||||
<div class='site-header' role='banner'>
|
||||
<h1>
|
||||
{{ site.data.content.home.title }}
|
||||
</h1>
|
||||
<p>
|
||||
{{ site.data.content.home.tagline }}
|
||||
</p>
|
||||
|
||||
{% include 2017/search-form.html live=true %}
|
||||
|
||||
{% if site.data.berry.enabled %}
|
||||
<div class='adbox' role='complementary'>
|
||||
{% include 2017/berry-sponsor.html %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if site.data.codefund.enabled %}
|
||||
<div class='adbox' role='complementary'>
|
||||
{% include 2017/codefund.html %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class='pages-list' role='main'>
|
||||
{% for page in featured_pages %}
|
||||
{% include 2017/pages-list-item.html page=page class='item top-sheet' %}
|
||||
{% endfor %}
|
||||
|
||||
<h2 class='category item' data-js-searchable-header>
|
||||
<span>Recently updated</span>
|
||||
</h2>
|
||||
|
||||
{% for page in recent_pages reversed %}
|
||||
{% if forloop.index <= 18 %}
|
||||
{% include 2017/pages-list-item.html page=page class='article item' %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% for category in site.data.categories.names %}
|
||||
<h2 class='category item' id='{{ category | downcase | replace: " ", "-" }}' data-js-searchable-header>
|
||||
<span>{{ category }}</span>
|
||||
</h2>
|
||||
|
||||
{% for page in site.pages %}
|
||||
{% if page.category == category %}
|
||||
{% if page.title %}
|
||||
{% include 2017/pages-list-item.html page=page class='article item' %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
<div class='message item missing-message'>
|
||||
<h3>See something missing?</h3>
|
||||
<p>
|
||||
<a class='push-button' href='{{ site.github.repository_url }}/issues/907'>Request cheatsheet</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include 2017/announcements-list.html %}
|
||||
|
||||
{% include 2017/foot.html %}
|
||||
</body>
|
||||
</html>
|
@ -1,26 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang='en'><head>
|
||||
|
||||
{% include 2017/head.html %}
|
||||
|
||||
</head><body>
|
||||
|
||||
{% include 2017/top-nav.html page=page noshare=true %}
|
||||
|
||||
<div class='body-area -slim'>
|
||||
<div class='site-header'>
|
||||
<h1>{{ site.data.content.not_found.title }}</h1>
|
||||
<p>{{ site.data.content.not_found.description }}</p>
|
||||
|
||||
{% include 2017/search-form.html %}
|
||||
|
||||
<p class='action'>
|
||||
<a class='push-button' href='./'>{{ site.data.content.not_found.home }}</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include 2017/foot.html %}
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,68 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class='NoJs' lang='en'><head>
|
||||
|
||||
{% include 2017/head.html critical='sheet' %}
|
||||
{% include 2017/article-schema.html page=page %}
|
||||
|
||||
</head><body>
|
||||
|
||||
{% include 2017/top-nav.html page=page %}
|
||||
|
||||
<div class='body-area'>
|
||||
<header class='main-heading -center' role='banner'>
|
||||
<h1 class='h1'>{{ page.title }} <em>{{ site.data.content.sheet.suffix }}</em></h1>
|
||||
|
||||
<div class='adbox' data-js-no-preview>
|
||||
{% if site.data.berry.enabled %}
|
||||
<div class='ad -berry' role='complementary'>
|
||||
{% include 2017/berry-sponsor.html %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if site.data.codefund.enabled %}
|
||||
<div class='ad -codefund' role='complementary'>
|
||||
{% include 2017/codefund.html %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if site.data.carbon.enabled %}
|
||||
<div class='HeadlineAd ad -carbon' role='complementary'>
|
||||
<script async src='{{ site.data.carbon.src }}' id="_carbonads_js"></script>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{% if page.tags contains 'WIP' %}
|
||||
<aside class='notice-box'>
|
||||
This page is a work in progress. You can help by <a href='{{ site.github.repository_url }}/blob/master/{{ page.path | remove: '.html' }}'>suggesting edits</a>!
|
||||
</aside>
|
||||
{% endif %}
|
||||
|
||||
{% if page.deprecated_by %}
|
||||
<aside class='notice-box'>
|
||||
<strong>Deprecated:</strong> This guide covers an older version.
|
||||
<a href='{{ base }}{{ page.deprecated_by }}'>A newer version is available here.</a>
|
||||
</aside>
|
||||
{% endif %}
|
||||
|
||||
{% if page.intro %}
|
||||
<div class='intro-content MarkdownBody'>
|
||||
{{ page.intro | markdownify }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<main class='post-content MarkdownBody' data-js-main-body data-js-anchors role='main'>
|
||||
{{ content }}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<div class='pre-footer' data-js-no-preview><i class='icon'></i></div>
|
||||
|
||||
{% include 2017/comments-area.html page=page %}
|
||||
{% include 2017/search-footer.html %}
|
||||
{% include 2017/related-posts.html page=page %}
|
||||
{% include 2017/foot.html %}
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1 +0,0 @@
|
||||
{{content}}
|
@ -1,30 +0,0 @@
|
||||
---
|
||||
type: article
|
||||
---
|
||||
{% include head.html %}
|
||||
{% include site-header.html %}
|
||||
|
||||
<div class='post-list -single -cheatsheet'>
|
||||
<div class='post-item'>
|
||||
{% include social-list.html page=page class="-collapse" %}
|
||||
|
||||
<div class='post-headline -cheatsheet'>
|
||||
<p class='prelude'><span></span></p>
|
||||
<h1><span>{{ page.title }}</span></h1>
|
||||
</div>
|
||||
|
||||
{% if site.data.carbon.enabled %}
|
||||
<div class='headline-ad'>
|
||||
<script async src='{{ site.data.carbon.src }}' id="_carbonads_js"></script>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class='post-content -cheatsheet'>
|
||||
{{ content }}
|
||||
</div>
|
||||
|
||||
{% include social-list.html page=page %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include foot.html %}
|
@ -1,25 +0,0 @@
|
||||
---
|
||||
type: article
|
||||
---
|
||||
{% include head.html %}
|
||||
{% include site-header.html %}
|
||||
|
||||
{% include 2017/article-schema.html page=page %}
|
||||
|
||||
<div class='post-list -single -cheatsheet'>
|
||||
<div class='post-item'>
|
||||
<div class='post-headline -cheatsheet'>
|
||||
<p class='prelude'><span></span></p>
|
||||
<h1><span>{{ page.title }}</span></h1>
|
||||
{% include social-list.html page=page %}
|
||||
</div>
|
||||
|
||||
<div class='post-content -cheatsheet'>
|
||||
{{ content }}
|
||||
</div>
|
||||
|
||||
{% include social-list.html page=page %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include foot.html %}
|
@ -1,30 +0,0 @@
|
||||
---
|
||||
html_class: home
|
||||
type: home
|
||||
---
|
||||
{% include head.html %}
|
||||
{% include site-header.html %}
|
||||
|
||||
{% for category in site.data.categories.names %}
|
||||
<div class='pages-header'>
|
||||
<h2 id='{{ category | downcase | replace: " ", "-" }}'>{{ category }}</h2>
|
||||
</div>
|
||||
<div class='pages-list'>
|
||||
{% for page in site.pages %}
|
||||
{% if page.category == category %}
|
||||
<a href="{{base}}{{ page.url }}">
|
||||
<span class='title'>{{ page.title }}</span>
|
||||
<span class='date'>{{ page.url | remove: '.html' | remove: '/' }}</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% if site.data.carbon.enabled %}
|
||||
<div class='side-ad'>
|
||||
<script async src='{{ site.data.carbon.src }}' id="_carbonads_js"></script>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% include foot.html %}
|
@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
{% assign target = page.redirect.to | remove: '.html' | replace: 'cheatsheets/cheatsheets', 'cheatsheets' %}
|
||||
<html lang="en-US">
|
||||
<meta charset="utf-8">
|
||||
<title>Redirecting…</title>
|
||||
<link rel="canonical" href="{{ target }}">
|
||||
<meta http-equiv="refresh" content="0; url={{ target }}">
|
||||
<h1>Redirecting...</h1>
|
||||
<a href="{{ target }}">Click here if you are not redirected.</a>
|
||||
<script>location="{{ target }}"</script>
|
||||
</html>
|
@ -1,47 +0,0 @@
|
||||
$bounce: cubic-bezier(.75,-0.5,0,1.75);
|
||||
|
||||
/*
|
||||
* "Preloader":
|
||||
* This makes the content semi-transparent before the page ad loads.
|
||||
*/
|
||||
|
||||
.post-content {
|
||||
html.WithJs & {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Pop it in as the page loads
|
||||
*/
|
||||
|
||||
.berry-sponsor {
|
||||
html.WithJs & {
|
||||
transform: scale(0.9) translate3d(0, -16px, 0);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
html.WithJs.LoadDone & {
|
||||
transform: scale(1) translate3d(0, 0, 0);
|
||||
opacity: 1;
|
||||
transition: transform 500ms $bounce, opacity 500ms linear;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Defer "loading" until page's onload event fires.
|
||||
* (The page actually already loaded, we just pretend like it hasn't)
|
||||
*/
|
||||
|
||||
.pages-list,
|
||||
.post-content.-wrapified,
|
||||
.intro-content {
|
||||
html.WithJs & {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
html.WithJs.LoadDone & {
|
||||
opacity: 1;
|
||||
transition: opacity 100ms linear 100ms;
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
.attribute-peg {
|
||||
& {
|
||||
display: inline-block;
|
||||
height: 12px;
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
& > span {
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background: saturate(lighten(#5a8, 16%), 24%);
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
.berry-sponsor {
|
||||
text-align: center;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
max-width: 320px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
/*
|
||||
* Berry styles
|
||||
*/
|
||||
|
||||
.cs__header {
|
||||
color: $base-mute;
|
||||
@include font-size(-1);
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
content: '—';
|
||||
margin: 0 0.5em;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.cs__blurb {
|
||||
&,
|
||||
&:hover,
|
||||
&:focus {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
& {
|
||||
color: $base-text;
|
||||
display: block;
|
||||
}
|
||||
|
||||
& > strong {
|
||||
color: $base-head;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
& > strong {
|
||||
color: $base-text;
|
||||
}
|
||||
|
||||
& > span {
|
||||
color: $base-mute;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cs__pixel {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
pointer-events: none;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
.body-area {
|
||||
max-width: $area-width;
|
||||
margin: 0 auto;
|
||||
@include gutter(padding);
|
||||
|
||||
&.-slim {
|
||||
max-width: 740px;
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
.codefund-sponsor {
|
||||
& {
|
||||
min-height: 114px;
|
||||
}
|
||||
|
||||
.cf-wrapper {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* h2 section
|
||||
*/
|
||||
|
||||
/* Hide the first h2 heading */
|
||||
.h2-section {
|
||||
&:first-child:not(.-no-hide) > h2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 481px) {
|
||||
& + & {
|
||||
margin-top: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Hide anchors until mouseover */
|
||||
& > .anchor {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
&:hover > .anchor {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* H3 section list:
|
||||
* The body that is isotoped.
|
||||
*/
|
||||
|
||||
.h3-section-list {
|
||||
& {
|
||||
@include section-gutter(margin-left, $multiplier: -1);
|
||||
@include section-gutter(margin-right, $multiplier: -1);
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
// Clearfix
|
||||
&::after {
|
||||
content: '';
|
||||
display: table;
|
||||
clear: both;
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
// Each section
|
||||
& > .h3-section {
|
||||
@include section-gutter(padding);
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (min-width: 769px) {
|
||||
& > .h3-section {
|
||||
padding-top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Two column (default)
|
||||
*/
|
||||
|
||||
.h3-section-list,
|
||||
.h3-section-list.-two-column {
|
||||
@media (min-width: 769px) {
|
||||
& > .h3-section {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* One column
|
||||
*/
|
||||
|
||||
.h3-section-list.-one-column {
|
||||
& > .h3-section {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
& > .h3-section + .h3-section {
|
||||
margin-top: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Three column
|
||||
*/
|
||||
|
||||
.h3-section-list.-three-column {
|
||||
@media (min-width: 769px) {
|
||||
& > .h3-section {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 961px) {
|
||||
& > .h3-section {
|
||||
width: 33.33%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Three column, left reference
|
||||
*/
|
||||
|
||||
.h3-section-list.-left-reference {
|
||||
@media (min-width: 769px) {
|
||||
& > .h3-section {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 961px) {
|
||||
& > .h3-section {
|
||||
width: 66.67%;
|
||||
}
|
||||
|
||||
& > .h3-section:first-child {
|
||||
width: 33.33%;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Carbon ads
|
||||
*
|
||||
* .headline-ad
|
||||
* #carbonads
|
||||
* span
|
||||
* span.carbon-wrap
|
||||
* a.carbon-img > img
|
||||
* a.carbon-text {description}
|
||||
* a.carbon-poweredby {powered by Carbon}
|
||||
*/
|
||||
|
||||
.HeadlineAd {
|
||||
@include font-size(-1);
|
||||
@include carbon-style;
|
||||
|
||||
& {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
&,
|
||||
& > div > span {
|
||||
min-width: 130px + 16px + 64px;
|
||||
max-width: 380px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
& > div > span {
|
||||
display: inline-block;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
// Clearfix
|
||||
& > div > span::after {
|
||||
content: '';
|
||||
display: table;
|
||||
clear: both;
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
.carbon-img {
|
||||
float: right;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.carbon-text:first-line {
|
||||
@include font-size(1);
|
||||
color: $base-head;
|
||||
font-weight: 300;
|
||||
margin-bottom: -0.02em;
|
||||
}
|
||||
|
||||
@media (min-width: 481px) {
|
||||
.carbon-poweredby::before {
|
||||
display: block;
|
||||
content: '';
|
||||
width: 32px;
|
||||
height: 1px;
|
||||
background: $dark-line-color;
|
||||
margin: 8px (130px + 16px) 8px auto;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
.push-button {
|
||||
@extend %push-button;
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
.SideAd {
|
||||
@include font-size(-1);
|
||||
@include carbon-style;
|
||||
|
||||
@media (min-width: 961px) {
|
||||
position: absolute;
|
||||
right: 32px;
|
||||
top: 80px;
|
||||
width: 130px;
|
||||
text-align: left;
|
||||
|
||||
.carbon-img {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.carbon-text:first-line {
|
||||
color: $base-head;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.carbon-poweredby::before {
|
||||
display: block;
|
||||
content: '';
|
||||
width: 32px;
|
||||
height: 1px;
|
||||
background: $dark-line-color;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
& {
|
||||
margin: 16px auto;
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
display: table;
|
||||
clear: both;
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
.carbon-img {
|
||||
float: left;
|
||||
margin-right: 16px;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
.site-header {
|
||||
margin: 32px 0;
|
||||
|
||||
& > p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
color: $base-mute;
|
||||
}
|
||||
|
||||
& > p > a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
& > h1 {
|
||||
@include font-size(8);
|
||||
line-height: 1.2;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: $base-head;
|
||||
font-weight: 200;
|
||||
text-align: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
& > .search {
|
||||
margin-top: 32px;
|
||||
}
|
||||
|
||||
& > .action {
|
||||
margin-top: 32px;
|
||||
}
|
||||
|
||||
& > .adbox {
|
||||
margin: 16px auto;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
& > .adbox {
|
||||
margin-left: -16px;
|
||||
margin-right: -16px;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
.local-anchor {
|
||||
& {
|
||||
margin-left: -.9em;
|
||||
margin-right: .1em;
|
||||
padding: 0 .1em;
|
||||
}
|
||||
|
||||
// Decoration
|
||||
.MarkdownBody &,
|
||||
.MarkdownBody &:visited {
|
||||
color: $base-mute;
|
||||
text-decoration: inherit;
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
.MarkdownBody &:target,
|
||||
.MarkdownBody :target > & {
|
||||
color: $base-a;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.MarkdownBody &:hover,
|
||||
.MarkdownBody &:focus {
|
||||
color: white;
|
||||
background: $base-a;
|
||||
opacity: 1;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
@import '../vendor/sanitize.css/sanitize';
|
||||
@import './variables';
|
||||
@import '../vendor/modularscale/modularscale';
|
||||
@import '../vendor/ionicons-inline/ionicons';
|
||||
@import './utils/carbon-style';
|
||||
@import './utils/font-size';
|
||||
@import './utils/gutter';
|
||||
@import './utils/heading-style';
|
||||
@import './utils/section-gutter';
|
||||
@import './utils/section-with-container';
|
||||
@import './placeholders/push-button';
|
||||
@import './base/base';
|
||||
@import './base/fade';
|
||||
@import './markdown/a-em';
|
||||
@import './markdown/code';
|
||||
@import './markdown/headings';
|
||||
@import './markdown/local-anchor';
|
||||
@import './markdown/p';
|
||||
@import './markdown/table';
|
||||
@import './markdown/ul';
|
||||
@import './components/attribute-peg';
|
||||
@import './components/announcements-item';
|
||||
@import './components/announcements-list';
|
||||
@import './components/back-button';
|
||||
@import './components/berry-sponsor';
|
||||
@import './components/body-area';
|
||||
@import './components/codefund-sponsor';
|
||||
@import './components/comments-area';
|
||||
@import './components/comments-details';
|
||||
@import './components/comments-section';
|
||||
@import './components/h2-section';
|
||||
@import './components/h3-section';
|
||||
@import './components/h3-section-list';
|
||||
@import './components/headline-ad';
|
||||
@import './components/hint-mark';
|
||||
@import './components/home-button';
|
||||
@import './components/intro-content';
|
||||
@import './components/main-heading';
|
||||
@import './components/missing-message';
|
||||
@import './components/notice-box';
|
||||
@import './components/page-actions';
|
||||
@import './components/pages-list';
|
||||
@import './components/pre-footer';
|
||||
@import './components/push-button';
|
||||
@import './components/related-posts-area';
|
||||
@import './components/related-posts-callout';
|
||||
@import './components/related-posts-group';
|
||||
@import './components/related-posts-section';
|
||||
@import './components/related-post-list';
|
||||
@import './components/related-post-item';
|
||||
@import './components/search-box';
|
||||
@import './components/search-footer';
|
||||
@import './components/side-ad';
|
||||
@import './components/site-header';
|
||||
@import './components/top-nav';
|
||||
@import './components/top-sheet';
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Base carbon ads style
|
||||
*/
|
||||
|
||||
@mixin carbon-style {
|
||||
.carbon-img,
|
||||
.carbon-text,
|
||||
.carbon-poweredby {
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.carbon-img {
|
||||
width: 130px;
|
||||
height: 100px;
|
||||
box-shadow: $shadow3;
|
||||
}
|
||||
|
||||
.carbon-img > img {
|
||||
border-radius: 3px;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.carbon-img:hover {
|
||||
transform: translate3d(0, -1px, 0);
|
||||
box-shadow: $shadow6;
|
||||
}
|
||||
|
||||
.carbon-text,
|
||||
.carbon-text:visited {
|
||||
color: $gray-text;
|
||||
}
|
||||
|
||||
.carbon-poweredby,
|
||||
.carbon-poweredby:visited {
|
||||
color: lighten($gray-text, 20%);
|
||||
}
|
||||
|
||||
.carbon-text:hover,
|
||||
.carbon-poweredby:hover {
|
||||
color: $base-a;
|
||||
}
|
||||
}
|
||||
|
589
_sass/vendor/sanitize.css/sanitize.scss
vendored
589
_sass/vendor/sanitize.css/sanitize.scss
vendored
@ -1,589 +0,0 @@
|
||||
/*! sanitize.css v5.0.0 | CC0 License | github.com/jonathantneal/sanitize.css */
|
||||
|
||||
/* Document (https://html.spec.whatwg.org/multipage/semantics.html#semantics)
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Remove repeating backgrounds in all browsers (opinionated).
|
||||
* 2. Add box sizing inheritence in all browsers (opinionated).
|
||||
*/
|
||||
|
||||
*,
|
||||
::before,
|
||||
::after {
|
||||
background-repeat: no-repeat; /* 1 */
|
||||
box-sizing: inherit; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add text decoration inheritance in all browsers (opinionated).
|
||||
* 2. Add vertical alignment inheritence in all browsers (opinionated).
|
||||
*/
|
||||
|
||||
::before,
|
||||
::after {
|
||||
text-decoration: inherit; /* 1 */
|
||||
vertical-align: inherit; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add border box sizing in all browsers (opinionated).
|
||||
* 2. Add the default cursor in all browsers (opinionated).
|
||||
* 3. Prevent font size adjustments after orientation changes in IE and iOS.
|
||||
*/
|
||||
|
||||
html {
|
||||
box-sizing: border-box; /* 1 */
|
||||
cursor: default; /* 2 */
|
||||
-ms-text-size-adjust: 100%; /* 3 */
|
||||
-webkit-text-size-adjust: 100%; /* 3 */
|
||||
}
|
||||
|
||||
/* Sections (https://html.spec.whatwg.org/multipage/semantics.html#sections)
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 9-.
|
||||
*/
|
||||
|
||||
article,
|
||||
aside,
|
||||
footer,
|
||||
header,
|
||||
nav,
|
||||
section {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the margin in all browsers (opinionated).
|
||||
*/
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the font size and margin on `h1` elements within `section` and
|
||||
* `article` contexts in Chrome, Firefox, and Safari.
|
||||
*/
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
margin: .67em 0;
|
||||
}
|
||||
|
||||
/* Grouping content (https://html.spec.whatwg.org/multipage/semantics.html#grouping-content)
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 9-.
|
||||
* 1. Add the correct display in IE.
|
||||
*/
|
||||
|
||||
figcaption,
|
||||
figure,
|
||||
main { /* 1 */
|
||||
display: block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct margin in IE 8.
|
||||
*/
|
||||
|
||||
figure {
|
||||
margin: 1em 40px;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add the correct box sizing in Firefox.
|
||||
* 2. Show the overflow in Edge and IE.
|
||||
*/
|
||||
|
||||
hr {
|
||||
box-sizing: content-box; /* 1 */
|
||||
height: 0; /* 1 */
|
||||
overflow: visible; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the list style on navigation lists in all browsers (opinionated).
|
||||
*/
|
||||
|
||||
nav ol,
|
||||
nav ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inheritance and scaling of font size in all browsers.
|
||||
* 2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
pre {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/* Text-level semantics (https://html.spec.whatwg.org/multipage/semantics.html#text-level-semantics)
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Remove the gray background on active links in IE 10.
|
||||
* 2. Remove gaps in links underline in iOS 8+ and Safari 8+.
|
||||
*/
|
||||
|
||||
a {
|
||||
background-color: transparent; /* 1 */
|
||||
-webkit-text-decoration-skip: objects; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Remove the bottom border in Firefox 39-.
|
||||
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
|
||||
*/
|
||||
|
||||
abbr[title] {
|
||||
border-bottom: none; /* 1 */
|
||||
text-decoration: underline; /* 2 */
|
||||
text-decoration: underline dotted; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent the duplicate application of `bolder` by the next rule in Safari 6.
|
||||
*/
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: inherit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font weight in Chrome, Edge, and Safari.
|
||||
*/
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inheritance and scaling of font size in all browsers.
|
||||
* 2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
code,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font style in Android 4.3-.
|
||||
*/
|
||||
|
||||
dfn {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct background and color in IE 9-.
|
||||
*/
|
||||
|
||||
mark {
|
||||
background-color: #ffff00;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font size in all browsers.
|
||||
*/
|
||||
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent `sub` and `sup` elements from affecting the line height in
|
||||
* all browsers.
|
||||
*/
|
||||
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -.25em;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -.5em;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the text shadow on text selections (opinionated).
|
||||
* 1. Restore the coloring undone by defining the text shadow (opinionated).
|
||||
*/
|
||||
|
||||
::-moz-selection {
|
||||
background-color: #b3d4fc; /* 1 */
|
||||
color: #000000; /* 1 */
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
::selection {
|
||||
background-color: #b3d4fc; /* 1 */
|
||||
color: #000000; /* 1 */
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
/* Embedded content (https://html.spec.whatwg.org/multipage/embedded-content.html#embedded-content)
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Change the alignment on media elements in all browers (opinionated).
|
||||
*/
|
||||
|
||||
audio,
|
||||
canvas,
|
||||
iframe,
|
||||
img,
|
||||
svg,
|
||||
video {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 9-.
|
||||
*/
|
||||
|
||||
audio,
|
||||
video {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct display in iOS 4-7.
|
||||
*/
|
||||
|
||||
audio:not([controls]) {
|
||||
display: none;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the border on images inside links in IE 10-.
|
||||
*/
|
||||
|
||||
img {
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the fill color to match the text color in all browsers (opinionated).
|
||||
*/
|
||||
|
||||
svg {
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the overflow in IE.
|
||||
*/
|
||||
|
||||
svg:not(:root) {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Tabular data (https://html.spec.whatwg.org/multipage/tables.html#tables)
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Collapse border spacing
|
||||
*/
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
/* Forms (https://html.spec.whatwg.org/multipage/forms.html#forms)
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the margin in Firefox and Safari.
|
||||
*/
|
||||
|
||||
button,
|
||||
input,
|
||||
optgroup,
|
||||
select,
|
||||
textarea {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit styling in all browsers (opinionated).
|
||||
*/
|
||||
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
background-color: transparent;
|
||||
color: inherit;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the overflow in IE.
|
||||
* 1. Show the overflow in Edge.
|
||||
*/
|
||||
|
||||
button,
|
||||
input { /* 1 */
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inheritance of text transform in Edge, Firefox, and IE.
|
||||
* 1. Remove the inheritance of text transform in Firefox.
|
||||
*/
|
||||
|
||||
button,
|
||||
select { /* 1 */
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
|
||||
* controls in Android 4.
|
||||
* 2. Correct the inability to style clickable types in iOS and Safari.
|
||||
*/
|
||||
|
||||
button,
|
||||
html [type="button"], /* 1 */
|
||||
[type="reset"],
|
||||
[type="submit"] {
|
||||
-webkit-appearance: button; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inner border and padding in Firefox.
|
||||
*/
|
||||
|
||||
button::-moz-focus-inner,
|
||||
[type="button"]::-moz-focus-inner,
|
||||
[type="reset"]::-moz-focus-inner,
|
||||
[type="submit"]::-moz-focus-inner {
|
||||
border-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the focus styles unset by the previous rule.
|
||||
*/
|
||||
|
||||
button:-moz-focusring,
|
||||
[type="button"]:-moz-focusring,
|
||||
[type="reset"]:-moz-focusring,
|
||||
[type="submit"]:-moz-focusring {
|
||||
outline: 1px dotted ButtonText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the text wrapping in Edge and IE.
|
||||
* 2. Correct the color inheritance from `fieldset` elements in IE.
|
||||
* 3. Remove the padding so developers are not caught out when they zero out
|
||||
* `fieldset` elements in all browsers.
|
||||
*/
|
||||
|
||||
legend {
|
||||
box-sizing: border-box; /* 1 */
|
||||
color: inherit; /* 2 */
|
||||
display: table; /* 1 */
|
||||
max-width: 100%; /* 1 */
|
||||
padding: 0; /* 3 */
|
||||
white-space: normal; /* 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add the correct display in IE 9-.
|
||||
* 2. Add the correct vertical alignment in Chrome, Firefox, and Opera.
|
||||
*/
|
||||
|
||||
progress {
|
||||
display: inline-block; /* 1 */
|
||||
vertical-align: baseline; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Remove the default vertical scrollbar in IE.
|
||||
* 2. Change the resize direction on textareas in all browsers (opinionated).
|
||||
*/
|
||||
|
||||
textarea {
|
||||
overflow: auto; /* 1 */
|
||||
resize: vertical; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add the correct box sizing in IE 10-.
|
||||
* 2. Remove the padding in IE 10-.
|
||||
*/
|
||||
|
||||
[type="checkbox"],
|
||||
[type="radio"] {
|
||||
box-sizing: border-box; /* 1 */
|
||||
padding: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the cursor style of increment and decrement buttons in Chrome.
|
||||
*/
|
||||
|
||||
[type="number"]::-webkit-inner-spin-button,
|
||||
[type="number"]::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the odd appearance in Chrome and Safari.
|
||||
* 2. Correct the outline style in Safari.
|
||||
*/
|
||||
|
||||
[type="search"] {
|
||||
-webkit-appearance: textfield; /* 1 */
|
||||
outline-offset: -2px; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inner padding and cancel buttons in Chrome and Safari on macOS.
|
||||
*/
|
||||
|
||||
[type="search"]::-webkit-search-cancel-button,
|
||||
[type="search"]::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inability to style clickable types in iOS and Safari.
|
||||
* 2. Change font properties to `inherit` in Safari.
|
||||
*/
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
-webkit-appearance: button; /* 1 */
|
||||
font: inherit; /* 2 */
|
||||
}
|
||||
|
||||
/* Interactive elements (https://html.spec.whatwg.org/multipage/forms.html#interactive-elements)
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Add the correct display in IE 9-.
|
||||
* 1. Add the correct display in Edge, IE, and Firefox.
|
||||
*/
|
||||
|
||||
details, /* 1 */
|
||||
menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the correct display in all browsers.
|
||||
*/
|
||||
|
||||
summary {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
/* Scripting (https://html.spec.whatwg.org/multipage/scripting.html#scripting-3)
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 9-.
|
||||
*/
|
||||
|
||||
canvas {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct display in IE.
|
||||
*/
|
||||
|
||||
template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* User interaction (https://html.spec.whatwg.org/multipage/interaction.html#editing)
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Remove the tapping delay on clickable elements (opinionated).
|
||||
* 1. Remove the tapping delay in IE 10.
|
||||
*/
|
||||
|
||||
a,
|
||||
area,
|
||||
button,
|
||||
input,
|
||||
label,
|
||||
select,
|
||||
summary,
|
||||
textarea,
|
||||
[tabindex] {
|
||||
-ms-touch-action: manipulation; /* 1 */
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 10-.
|
||||
*/
|
||||
|
||||
[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ARIA (https://w3c.github.io/html-aria/)
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Change the cursor on busy elements (opinionated).
|
||||
*/
|
||||
|
||||
[aria-busy="true"] {
|
||||
cursor: progress;
|
||||
}
|
||||
|
||||
/*
|
||||
* Change the cursor on control elements (opinionated).
|
||||
*/
|
||||
|
||||
[aria-controls] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Change the display on visually hidden accessible elements (opinionated).
|
||||
*/
|
||||
|
||||
[aria-hidden="false"][hidden]:not(:focus) {
|
||||
clip: rect(0, 0, 0, 0);
|
||||
display: inherit;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
/*
|
||||
* Change the cursor on disabled, not-editable, or otherwise
|
||||
* inoperable elements (opinionated).
|
||||
*/
|
||||
|
||||
[aria-disabled] {
|
||||
cursor: default;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
(
|
||||
echo https://devhints.io/
|
||||
(
|
||||
git ls-files \
|
||||
| grep -E '\.md$' \
|
||||
| grep -v -E 'CONTRIBUTING|README|Readme' \
|
||||
| grep -v -E '^_' \
|
||||
| sort \
|
||||
| uniq \
|
||||
| sed 's/\.md$//g'
|
||||
) \
|
||||
| sed 's#^#https://devhints.io/#g'
|
||||
) \
|
||||
| xargs curl >/dev/null
|
@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Helper to copy the latest cheatsheets to the clipboard for CloudFlare
|
||||
# purging. This ensures visitors will see new versions.
|
||||
|
||||
(
|
||||
git log "master@{3 days ago}..HEAD" --pretty="" --name-only \
|
||||
| grep -E '\.md$' \
|
||||
| grep -v -E 'CONTRIBUTING|README|Readme' \
|
||||
| grep -v -E '^_' \
|
||||
| sort \
|
||||
| uniq \
|
||||
| sed 's/\.md$//g'
|
||||
) \
|
||||
| sed 's#^#https://devhints.io/#g' \
|
||||
| xargs echo https://devhints.io/ \
|
||||
| pbcopy
|
||||
|
||||
echo "Copied to clipboard."
|
||||
echo "Purge it here:"
|
||||
echo ""
|
||||
echo " https://www.cloudflare.com/a/caching/devhints.io"
|
||||
echo ""
|
||||
echo "Then click 'Purge Individual Files'"
|
@ -1,45 +0,0 @@
|
||||
const critical = require('critical')
|
||||
|
||||
console.warn('Generating critical path styles into _includes/2017/critical/...')
|
||||
|
||||
const OPTIONS = {
|
||||
base: '_site',
|
||||
width: 1400,
|
||||
height: 900,
|
||||
minify: true,
|
||||
extract: true,
|
||||
ignore: [
|
||||
'@font-face'
|
||||
],
|
||||
include: [
|
||||
// fade-in magic (base/fade)
|
||||
/html\.WithJs/
|
||||
]
|
||||
}
|
||||
|
||||
critical.generate({
|
||||
...OPTIONS,
|
||||
src: 'index.html',
|
||||
dest: '../_includes/2017/critical/home.css',
|
||||
include: [
|
||||
...OPTIONS.include,
|
||||
|
||||
// searchbox with placeholder
|
||||
/\.search-box/
|
||||
]
|
||||
})
|
||||
|
||||
critical.generate({
|
||||
...OPTIONS,
|
||||
src: 'react.html',
|
||||
dest: '../_includes/2017/critical/sheet.css',
|
||||
include: [
|
||||
...OPTIONS.include,
|
||||
|
||||
// sections (and h3 section list), just to be sure
|
||||
/\.h3-section/,
|
||||
|
||||
// eg, -six-column in devhints.io/layout-thrashing
|
||||
/-column/
|
||||
]
|
||||
})
|
@ -1,73 +0,0 @@
|
||||
const join = require('path').resolve
|
||||
const webpack = require('webpack')
|
||||
|
||||
module.exports = {
|
||||
context: join(__dirname, '..'),
|
||||
entry: {
|
||||
app: './_js/app.js',
|
||||
vendor: [
|
||||
// Large 3rd-party libs
|
||||
'prismjs',
|
||||
|
||||
// Prism plugins
|
||||
'prismjs/plugins/line-highlight/prism-line-highlight.min.js',
|
||||
'prismjs/components/prism-jsx.min.js',
|
||||
'prismjs/components/prism-bash.min.js',
|
||||
'prismjs/components/prism-scss.min.js',
|
||||
'prismjs/components/prism-css.min.js',
|
||||
'prismjs/components/prism-elixir.min.js',
|
||||
'prismjs/components/prism-ruby.min.js',
|
||||
|
||||
// CSS
|
||||
'prismjs/plugins/line-highlight/prism-line-highlight.css',
|
||||
'hint.css/hint.min.css'
|
||||
]
|
||||
},
|
||||
output: {
|
||||
path: join(__dirname, '..', 'assets', 'packed'),
|
||||
filename: '[name].js',
|
||||
devtoolModuleFilenameTemplate: 'webpack:///[absolute-resource-path]'
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{ loader: 'babel-loader' }
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
{ loader: 'style-loader' },
|
||||
{ loader: 'css-loader' }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
// Never bundle jQuery
|
||||
'jquery': join(__dirname, '..', '_js/helpers/noop.js')
|
||||
}
|
||||
},
|
||||
stats: 'minimal',
|
||||
plugins: [
|
||||
// Optimize module ID's for vendor chunks
|
||||
new webpack.HashedModuleIdsPlugin({
|
||||
hashFunction: 'sha256',
|
||||
hashDigest: 'base64',
|
||||
hashDigestLength: 20
|
||||
}),
|
||||
|
||||
// Optimize vendor
|
||||
new webpack.optimize.CommonsChunkPlugin('vendor'),
|
||||
|
||||
// Don't include debug symbols ever
|
||||
new webpack.EnvironmentPlugin({
|
||||
NODE_ENV: 'production'
|
||||
})
|
||||
],
|
||||
devtool: 'source-map'
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
const join = require('path').resolve
|
||||
const webpack = require('webpack')
|
||||
|
||||
module.exports = {
|
||||
context: join(__dirname, '..'),
|
||||
entry: './_js/critical.js',
|
||||
output: {
|
||||
path: join(__dirname, '..', '_includes', '2017', 'critical'),
|
||||
filename: 'critical.js'
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{ loader: 'babel-loader' }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
stats: 'minimal',
|
||||
plugins: [
|
||||
new webpack.EnvironmentPlugin({
|
||||
NODE_ENV: 'production'
|
||||
})
|
||||
]
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Absinthe
|
||||
category: Hidden
|
||||
layout: 2017/sheet
|
||||
tags: [WIP]
|
||||
updated: 2017-10-10
|
||||
intro: |
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: ActiveAdmin
|
||||
category: Ruby
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### Listing scopes
|
||||
|
1
adb.md
1
adb.md
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: adb (Android Debug Bridge)
|
||||
category: CLI
|
||||
layout: 2017/sheet
|
||||
weight: -1
|
||||
authors:
|
||||
- github: ZackNeyland
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Google Analytics's analytics.js
|
||||
category: Analytics
|
||||
layout: 2017/sheet
|
||||
updated: 2017-10-29
|
||||
intro: |
|
||||
Google Analytics's analytics.js is deprecated.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Analytics libraries
|
||||
layout: 2017/sheet
|
||||
category: Analytics
|
||||
---
|
||||
|
||||
### Mixpanel
|
||||
|
15
angularjs.md
15
angularjs.md
@ -1,7 +1,18 @@
|
||||
---
|
||||
title: Angular.js
|
||||
category: JavaScript libraries
|
||||
tags: [Archived]
|
||||
archived: This describes an older version of Angular.
|
||||
---
|
||||
|
||||
### About
|
||||
{: .-intro}
|
||||
|
||||
* <https://github.com/angular/angular-seed>
|
||||
* <https://angularjs.org/>
|
||||
|
||||
### ng-app
|
||||
|
||||
```html
|
||||
<html ng-app="nameApp">
|
||||
```
|
||||
@ -88,7 +99,3 @@ In HTML will use `<name></name>` to render your template `<h1>Hello</h1>`
|
||||
})
|
||||
});
|
||||
```
|
||||
References:
|
||||
|
||||
* https://github.com/angular/angular-seed
|
||||
* https://angularjs.org/
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Animated GIFs
|
||||
category: CLI
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
## Animated GIFs
|
||||
|
62
ansi.md
62
ansi.md
@ -1,41 +1,51 @@
|
||||
---
|
||||
title: Ansi codes
|
||||
category: CLI
|
||||
intro: |
|
||||
Quick reference to ANSI color codes.
|
||||
---
|
||||
|
||||
Format
|
||||
### Format
|
||||
|
||||
\033[#m
|
||||
```
|
||||
\033[#m
|
||||
```
|
||||
|
||||
Where:
|
||||
### ANSI codes
|
||||
|
||||
0 clear
|
||||
1 bold
|
||||
4 underline
|
||||
5 blink
|
||||
```
|
||||
0 clear
|
||||
1 bold
|
||||
4 underline
|
||||
5 blink
|
||||
|
||||
30-37 fg color
|
||||
40-47 bg color
|
||||
30-37 fg color
|
||||
40-47 bg color
|
||||
|
||||
1K clear line (to beginning of line)
|
||||
2K clear line (entire line)
|
||||
2J clear screen
|
||||
0;0H move cursor to 0;0
|
||||
1K clear line (to beginning of line)
|
||||
2K clear line (entire line)
|
||||
2J clear screen
|
||||
0;0H move cursor to 0;0
|
||||
|
||||
1A move up 1 line
|
||||
1A move up 1 line
|
||||
```
|
||||
|
||||
Colors
|
||||
### Colors
|
||||
|
||||
0 black
|
||||
1 red
|
||||
2 green
|
||||
3 yellow
|
||||
4 blue
|
||||
5 magenta
|
||||
6 cyan
|
||||
7 white
|
||||
```
|
||||
0 black
|
||||
1 red
|
||||
2 green
|
||||
3 yellow
|
||||
4 blue
|
||||
5 magenta
|
||||
6 cyan
|
||||
7 white
|
||||
```
|
||||
|
||||
Stuff
|
||||
### Bash utilities
|
||||
|
||||
hide_cursor() { printf "\e[?25l"; }
|
||||
show_cursor() { printf "\e[?25h"; }
|
||||
```sh
|
||||
hide_cursor() { printf "\e[?25l"; }
|
||||
show_cursor() { printf "\e[?25h"; }
|
||||
```
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Ansible examples
|
||||
category: Ansible
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### Examples
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: "Ansible quickstart"
|
||||
category: Ansible
|
||||
layout: 2017/sheet
|
||||
description: |
|
||||
A quick guide to getting started with your first Ansible playbook.
|
||||
---
|
||||
@ -45,7 +44,7 @@ See: [Getting started](http://docs.ansible.com/ansible/latest/intro_getting_star
|
||||
This is a list of hosts you want to manage, grouped into groups. (Hint: try
|
||||
using `localhost ansible_connection=local` to deploy to your local machine.)
|
||||
|
||||
See: [Intro to Inventory](http://docs.ansible.com/ansible/latest/playbooks_intro.html)
|
||||
See: [Intro to Inventory](http://docs.ansible.com/ansible/latest/intro_inventory.html)
|
||||
|
||||
### Playbook
|
||||
|
||||
@ -68,7 +67,7 @@ See: [Intro to Inventory](http://docs.ansible.com/ansible/latest/playbooks_intro
|
||||
gem: name=bundler state=latest
|
||||
```
|
||||
|
||||
See: [Intro to Playbooks](http://docs.ansible.com/ansible/latest/intro_inventory.html)
|
||||
See: [Intro to Playbooks](http://docs.ansible.com/ansible/latest/playbooks_intro.html)
|
||||
|
||||
## Running
|
||||
|
||||
@ -103,3 +102,5 @@ ok: [127.0.0.1]
|
||||
* [Getting started](http://docs.ansible.com/ansible/latest/intro_getting_started.html) _(docs.ansible.com)_
|
||||
* [Intro to Inventory](http://docs.ansible.com/ansible/latest/intro_inventory.html) _(docs.ansible.com)_
|
||||
* [Intro to Playbooks](http://docs.ansible.com/ansible/latest/playbooks_intro.html) _(docs.ansible.com)_
|
||||
* [Ansible Tutorial for Beginners: Playbook & Examples](https://spacelift.io/blog/ansible-tutorial) _(spacelift.io)_
|
||||
* [Working with Ansible Playbooks – Tips & Tricks with Examples](https://spacelift.io/blog/ansible-playbooks) _(spacelift.io)_
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Ansible modules
|
||||
category: Ansible
|
||||
layout: 2017/sheet
|
||||
prism_languages: [yaml]
|
||||
updated: 2017-10-03
|
||||
---
|
||||
@ -97,7 +96,7 @@ Define your tasks in any of these formats. One-line format is preferred for shor
|
||||
bare: yes
|
||||
```
|
||||
|
||||
See: [git module](http://devdocs.io/ansible/git_module)
|
||||
See: [git module](https://devdocs.io/ansible/git_module)
|
||||
|
||||
### git_config
|
||||
|
||||
@ -108,7 +107,7 @@ See: [git module](http://devdocs.io/ansible/git_module)
|
||||
value: hi@example.com
|
||||
```
|
||||
|
||||
See: [git_config module](http://devdocs.io/ansible/git_config_module)
|
||||
See: [git_config module](https://devdocs.io/ansible/git_config_module)
|
||||
|
||||
### user
|
||||
|
||||
@ -122,7 +121,7 @@ See: [git_config module](http://devdocs.io/ansible/git_config_module)
|
||||
comment: "Git Version Control"
|
||||
```
|
||||
|
||||
See: [user module](http://devdocs.io/ansible/user_module)
|
||||
See: [user module](https://devdocs.io/ansible/user_module)
|
||||
|
||||
### service
|
||||
|
||||
@ -133,7 +132,7 @@ See: [user module](http://devdocs.io/ansible/user_module)
|
||||
enabled: yes # optional
|
||||
```
|
||||
|
||||
See: [service module](http://devdocs.io/ansible/service_module)
|
||||
See: [service module](https://devdocs.io/ansible/service_module)
|
||||
|
||||
## Shell
|
||||
|
||||
@ -161,7 +160,7 @@ See: [service module](http://devdocs.io/ansible/service_module)
|
||||
echo "multiple lines"
|
||||
```
|
||||
|
||||
See: [shell module](http://devdocs.io/ansible/shell_module)
|
||||
See: [shell module](https://devdocs.io/ansible/shell_module)
|
||||
|
||||
### script
|
||||
|
||||
@ -173,7 +172,7 @@ See: [shell module](http://devdocs.io/ansible/shell_module)
|
||||
chdir: /path # cd here before running
|
||||
```
|
||||
|
||||
See: [script module](http://devdocs.io/ansible/script_module)
|
||||
See: [script module](https://devdocs.io/ansible/script_module)
|
||||
|
||||
## Files
|
||||
|
||||
@ -192,7 +191,7 @@ See: [script module](http://devdocs.io/ansible/script_module)
|
||||
force: yes # ln -nfs
|
||||
```
|
||||
|
||||
See: [file module](http://devdocs.io/ansible/file_module)
|
||||
See: [file module](https://devdocs.io/ansible/file_module)
|
||||
|
||||
### copy
|
||||
|
||||
@ -208,7 +207,7 @@ See: [file module](http://devdocs.io/ansible/file_module)
|
||||
backup: yes
|
||||
```
|
||||
|
||||
See: [copy module](http://devdocs.io/ansible/copy_module)
|
||||
See: [copy module](https://devdocs.io/ansible/copy_module)
|
||||
|
||||
### template
|
||||
|
||||
@ -224,7 +223,7 @@ See: [copy module](http://devdocs.io/ansible/copy_module)
|
||||
backup: yes
|
||||
```
|
||||
|
||||
See: [template module](http://devdocs.io/ansible/template_module)
|
||||
See: [template module](https://devdocs.io/ansible/template_module)
|
||||
|
||||
## Local actions
|
||||
|
||||
@ -242,6 +241,6 @@ See: [template module](http://devdocs.io/ansible/template_module)
|
||||
msg: "Hello {{ var }}"
|
||||
```
|
||||
|
||||
See: [debug module](http://devdocs.io/ansible/debug_module)
|
||||
See: [debug module](https://devdocs.io/ansible/debug_module)
|
||||
{% endraw %}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Ansible roles
|
||||
category: Ansible
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### Structure
|
||||
|
20
ansible.md
20
ansible.md
@ -7,6 +7,11 @@ category: Ansible
|
||||
|
||||
## Getting started
|
||||
|
||||
### About
|
||||
{: .-intro}
|
||||
|
||||
- <https://www.ansible.com/>
|
||||
|
||||
### Hosts
|
||||
|
||||
$ sudo mkdir /etc/ansible
|
||||
@ -20,7 +25,9 @@ category: Ansible
|
||||
|
||||
$ ansible-playbook playbook.yml
|
||||
|
||||
## Tasks
|
||||
## Playbook files
|
||||
|
||||
### Tasks
|
||||
|
||||
- hosts: all
|
||||
user: root
|
||||
@ -39,7 +46,7 @@ category: Ansible
|
||||
handlers:
|
||||
- include: db.yml user=timmy
|
||||
|
||||
## Handlers
|
||||
### Handlers
|
||||
|
||||
handlers:
|
||||
- name: start apache2
|
||||
@ -51,7 +58,7 @@ category: Ansible
|
||||
notify:
|
||||
- start apache2
|
||||
|
||||
## Vars
|
||||
### Vars
|
||||
|
||||
- host: lol
|
||||
vars_files:
|
||||
@ -63,7 +70,7 @@ category: Ansible
|
||||
file: state=directory path=${project_root}/home/.ssh/
|
||||
only_if: "$vm == 0"
|
||||
|
||||
## Roles
|
||||
### Roles
|
||||
|
||||
- host: xxx
|
||||
roles:
|
||||
@ -91,9 +98,4 @@ category: Ansible
|
||||
vars:
|
||||
local_home: "{{ lookup('env','HOME') }}"
|
||||
|
||||
## References
|
||||
|
||||
* [Intro](http://www.ansibleworks.com/docs/intro_configuration.html)
|
||||
* [Modules](http://www.ansibleworks.com/docs/modules.html)
|
||||
|
||||
{% endraw %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Appcache
|
||||
category: HTML
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### Format
|
||||
@ -11,7 +10,7 @@ CACHE MANIFEST
|
||||
# version
|
||||
|
||||
CACHE:
|
||||
http://www.google.com/jsapi
|
||||
https://www.google.com/jsapi
|
||||
/assets/app.js
|
||||
/assets/bg.png
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: AppleScript
|
||||
updated: 2018-03-17
|
||||
layout: 2017/sheet
|
||||
updated: 2018-12-06
|
||||
category: macOS
|
||||
prism_languages: [applescript]
|
||||
---
|
||||
@ -57,3 +56,20 @@ beep
|
||||
-- beep 10 times
|
||||
beep 10
|
||||
```
|
||||
|
||||
### Delay
|
||||
|
||||
```applescript
|
||||
-- delay for 5 seconds
|
||||
delay 5
|
||||
```
|
||||
|
||||
### Handlers
|
||||
|
||||
```applescript
|
||||
on doubleNumber(n)
|
||||
return n * 2
|
||||
end doubleNumber
|
||||
|
||||
set doubledValue to my doubleNumber(2)
|
||||
```
|
||||
|
@ -3,6 +3,11 @@ title: Applinks
|
||||
category: HTML
|
||||
---
|
||||
|
||||
### About
|
||||
|
||||
- <http://applinks.org/>
|
||||
|
||||
### Applinks
|
||||
|
||||
<meta property="al:ios:url" content="applinks://docs" />
|
||||
<meta property="al:ios:app_store_id" content="12345" />
|
||||
|
11
arel.md
11
arel.md
@ -3,6 +3,13 @@ title: Arel
|
||||
category: Rails
|
||||
---
|
||||
|
||||
### About
|
||||
{: .-intro}
|
||||
|
||||
Arel is an SQL abstraction library built into Ruby on Rails.
|
||||
|
||||
* <https://github.com/rails/arel>
|
||||
|
||||
### Tables
|
||||
|
||||
```rb
|
||||
@ -123,7 +130,3 @@ all_time = photos_with_credits.count
|
||||
this_month = photos_with_credits.where(photos[:created_at].gteq(Date.today.beginning_of_month))
|
||||
recent_photos = photos_with_credits.where(photos[:created_at].gteq(Date.today.beginning_of_month)).limit(5)
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
* <http://github.com/rails/arel>
|
||||
|
@ -1,4 +0,0 @@
|
||||
---
|
||||
type: other
|
||||
---
|
||||
@import '2017/style.scss';
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,48 +0,0 @@
|
||||
.site-header, .social-list, .about-the-site,
|
||||
#see-also, #see-also+ul {
|
||||
display: none;
|
||||
}
|
||||
/*.post-headline.-cheatsheet .prelude span:before {
|
||||
content: 'cheatsheet for'
|
||||
}*/
|
||||
.post-list {
|
||||
margin: 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.post-item {
|
||||
max-width: 100%;
|
||||
}
|
||||
.post-headline.-cheatsheet .prelude {
|
||||
max-width: 300px;
|
||||
}
|
||||
.post-headline, p.prelude {
|
||||
margin-top: 0;
|
||||
}
|
||||
.post-headline.-cheatsheet .prelude {
|
||||
font-size: 0.6em;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
.post-headline {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
.post-headline.-cheatsheet .prelude span {
|
||||
padding: 0.75em 20px;
|
||||
border-bottom: solid 1.5px #111;
|
||||
}
|
||||
.post-headline.-cheatsheet h1 {
|
||||
font-size: 1.75em;
|
||||
text-shadow: none;
|
||||
}
|
||||
pre {
|
||||
border-top: solid 1px #ddd;
|
||||
border-bottom: solid 1px #ddd;
|
||||
background: none;
|
||||
}
|
||||
h3 {
|
||||
margin: 1em 0;
|
||||
}
|
||||
pre {
|
||||
margin-top: 1.1em;
|
||||
margin-bottom: 1.1em;
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
(function () {
|
||||
var tags = document.querySelectorAll('h1,h2,h3,h4,h5,h6,li,p,span');
|
||||
|
||||
for (var i=0, len=tags.length; i<len; i++) {
|
||||
var tag = tags[i];
|
||||
if ((~tag.innerHTML.indexOf('>') ||
|
||||
(!tag.innerHTML.match(/https?:\/\//))))
|
||||
continue;
|
||||
tag.innerHTML = tag.innerHTML.replace(/https?:\/\/[^ ]*/g, function (url) {
|
||||
url = url.replace(/[\.\),!]*$/, '');
|
||||
var label = url;
|
||||
label = label.replace(/^https?:\/\//, '')
|
||||
.replace(/\/$/, '');
|
||||
return "<a href='"+url+"'>"+label+"</a>";
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
/* unorphan */
|
||||
(function () {
|
||||
var els = document.querySelectorAll('h1 a, h1, h2, p.brief-intro, .pull-quote');
|
||||
for (var i = 0, len = els.length; i < len; i++) {
|
||||
var el = els[i];
|
||||
var last = el.lastChild;
|
||||
|
||||
if (last && last.nodeType === 3) {
|
||||
console.log('=>', last.nodeValue, last.nodeValue.replace(/\s+([^\s]+\s*)$/g, '\xA0$1'));
|
||||
last.nodeValue = last.nodeValue.replace(/\s+([^\s]+\s*)$/g, '\xA0$1');
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
/* loaded */
|
||||
document.documentElement.className += ' loaded';
|
||||
|
||||
/* hljs */
|
||||
(function () {
|
||||
var codes = document.querySelectorAll('pre > code');
|
||||
for (var i = 0, len = codes.length; i < len; i++) {
|
||||
var block = codes[i];
|
||||
hljs.highlightBlock(block);
|
||||
}
|
||||
})();
|
292
assets/style.css
292
assets/style.css
@ -1,292 +0,0 @@
|
||||
/*
|
||||
* pages list
|
||||
*/
|
||||
|
||||
.pages-list {
|
||||
font-size: 0.9em;
|
||||
max-width: 800px;
|
||||
margin: 60px auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pages-list a {
|
||||
display: block;
|
||||
padding: 6px 0;
|
||||
text-align: left;
|
||||
float: left;
|
||||
width: 44%;
|
||||
margin: 0 3%;
|
||||
box-shadow: none;
|
||||
transition: all 100ms linear;
|
||||
}
|
||||
|
||||
.pages-list a .title,
|
||||
.pages-list a .date {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pages-list a .title {
|
||||
font-weight: bold;
|
||||
color: #111;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.pages-list a .date {
|
||||
color: #aaa;
|
||||
font-size: 0.9em;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.pages-list a:hover .title,
|
||||
.pages-list a:focus .title {
|
||||
color: dodgerblue;
|
||||
}
|
||||
|
||||
/*
|
||||
* post headline
|
||||
*/
|
||||
|
||||
.post-headline.-cheatsheet .prelude {
|
||||
color: #111;
|
||||
font-size: 0.85em;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 2px;
|
||||
margin-bottom: 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.post-headline.-cheatsheet .prelude span {
|
||||
border-bottom: solid 3px #111;
|
||||
padding: 1.5em 20px;
|
||||
}
|
||||
|
||||
.post-headline.-cheatsheet .prelude span:before {
|
||||
content: 'Cheatsheet for';
|
||||
}
|
||||
|
||||
@media (min-width: 769px) {
|
||||
.post-headline.-cheatsheet .prelude {
|
||||
max-width: 230px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
.post-headline.-cheatsheet .prelude span {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.post-headline.-cheatsheet h1 {
|
||||
color: #111;
|
||||
font-size: 3.5em;
|
||||
text-shadow:
|
||||
2px 2px 0 white,
|
||||
3px 3px 0 #ddd;
|
||||
}
|
||||
|
||||
/*
|
||||
* about the site
|
||||
*/
|
||||
|
||||
.about-the-site {
|
||||
margin-top: 8em;
|
||||
}
|
||||
|
||||
.about-the-site .back {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* markdown
|
||||
*/
|
||||
|
||||
@media (min-width: 768px) {
|
||||
h2 {
|
||||
margin-top: 3em;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* grey code
|
||||
*/
|
||||
|
||||
.greycode td:first-child code,
|
||||
.greycode th:first-child code {
|
||||
background: white;
|
||||
padding: 6px 8px 5px 8px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.greycode td:first-child code + em,
|
||||
.greycode th:first-child code + em {
|
||||
color: #808890;
|
||||
font-size: 0.9em;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.greycode a {
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
table.greycode {
|
||||
background: #fcfcfc;
|
||||
border-radius: 4px;
|
||||
border-top: 0;
|
||||
border-bottom: solid 1px #c7d7ee;
|
||||
}
|
||||
|
||||
table.greycode:not(.wide) {
|
||||
width: calc(620px + 100px);
|
||||
margin-left: -50px;
|
||||
}
|
||||
|
||||
table.greycode thead:first-child > tr:first-child > th,
|
||||
table.greycode thead:first-child > tr:first-child > td,
|
||||
table.greycode tbody:first-child > tr:first-child > th,
|
||||
table.greycode tbody:first-child > tr:first-child > td,
|
||||
table.greycode.no-head thead:nth-child(2) > tr:first-child > th,
|
||||
table.greycode.no-head thead:nth-child(2) > tr:first-child > td,
|
||||
table.greycode.no-head tbody:nth-child(2) > tr:first-child > th,
|
||||
table.greycode.no-head tbody:nth-child(2) > tr:first-child > td {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
table.greycode thead > tr:first-child > th,
|
||||
table.greycode thead > tr:first-child > td,
|
||||
table.greycode tbody > tr:first-child > th,
|
||||
table.greycode tbody > tr:first-child > td {
|
||||
border-top: solid 1px #c7d7ee;
|
||||
}
|
||||
|
||||
table.greycode td:first-child,
|
||||
table.greycode th:first-child {
|
||||
padding-left: 50px;
|
||||
}
|
||||
|
||||
table.greycode td:last-child,
|
||||
table.greycode th:last-child {
|
||||
padding-right: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
.hljs-comment {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.key-codes code {
|
||||
background: #fdfdff;
|
||||
padding: 3px 8px 3px 8px;
|
||||
border-radius: 3px;
|
||||
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.key-codes code + code {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.key-codes pre code {
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
box-shadow: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Carbon: side
|
||||
*/
|
||||
|
||||
.side-ad {
|
||||
position: absolute;
|
||||
top: 80px;
|
||||
right: 20px;
|
||||
width: 130px;
|
||||
display: block;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
.side-ad a {
|
||||
text-decoration: none;
|
||||
box-shadow: none;
|
||||
background: rgba(255, 255, 255, .01);
|
||||
}
|
||||
|
||||
.side-ad a:hover {
|
||||
color: #111;
|
||||
}
|
||||
|
||||
.side-ad .carbon-text {
|
||||
margin-top: 5px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.side-ad .carbon-poweredby {
|
||||
display: block;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.side-ad {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Cardbon: headline
|
||||
*/
|
||||
|
||||
.headline-ad {
|
||||
width: 300px;
|
||||
min-height: 100px;
|
||||
font-size: .8em;
|
||||
margin: 0 auto 45px auto;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.headline-ad:after {
|
||||
content: '';
|
||||
display: table;
|
||||
clear: both;
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
.headline-ad a {
|
||||
text-decoration: none;
|
||||
box-shadow: none;
|
||||
display: block;
|
||||
background: rgba(255, 255, 255, .01);
|
||||
}
|
||||
|
||||
.headline-ad a:hover {
|
||||
color: #111;
|
||||
}
|
||||
|
||||
.headline-ad img {
|
||||
float: left;
|
||||
margin-right: 15px;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.headline-ad .carbon-text {
|
||||
}
|
||||
|
||||
.headline-ad .carbon-poweredby {
|
||||
display: block;
|
||||
color: #aaa;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.social-list.-collapse {
|
||||
margin-top: 0;
|
||||
position: absolute;
|
||||
top: 40vh;
|
||||
left: 30px;
|
||||
width: 32px;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.social-list.-collapse {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
34
astro.config.mjs
Normal file
34
astro.config.mjs
Normal file
@ -0,0 +1,34 @@
|
||||
import { defineConfig } from 'astro/config'
|
||||
import partytown from '@astrojs/partytown'
|
||||
|
||||
/*
|
||||
* https://astro.build/config
|
||||
*/
|
||||
import tailwind from '@astrojs/tailwind'
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
site: 'https://devhints.io',
|
||||
build: {
|
||||
format: 'file' /* generate /my-post.html instead of /my-post/index.html */,
|
||||
inlineStylesheets: 'always'
|
||||
},
|
||||
prefetch: {
|
||||
prefetchAll: true
|
||||
},
|
||||
server: {
|
||||
host: true
|
||||
} /* access from https://192.168.x.x/ */,
|
||||
integrations: [
|
||||
partytown({
|
||||
config: {
|
||||
forward: ['dataLayer.push']
|
||||
}
|
||||
}),
|
||||
tailwind()
|
||||
],
|
||||
markdown: {
|
||||
// Syntax highlighting is handled by render()
|
||||
syntaxHighlight: false
|
||||
}
|
||||
})
|
102
atom.md
102
atom.md
@ -1,53 +1,55 @@
|
||||
---
|
||||
title: Atom
|
||||
category: Apps
|
||||
layout: 2017/sheet
|
||||
updated: 2017-09-20
|
||||
updated: 2021-09-10
|
||||
---
|
||||
|
||||
Shortcuts
|
||||
---------
|
||||
## Shortcuts
|
||||
{: .-three-column}
|
||||
|
||||
### Tree
|
||||
|
||||
| Shortcut | Description |
|
||||
| --- | --- |
|
||||
| `⌘\` | Toggle tree |
|
||||
| `⌘⇧\` | Reveal current file |
|
||||
| Shortcut | Description |
|
||||
| -------- | ------------------- |
|
||||
| `⌘\` | Toggle tree |
|
||||
| `⌘⇧\` | Reveal current file |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Comments
|
||||
|
||||
| Shortcut | Description |
|
||||
| --- | --- |
|
||||
| `⌘/` | Toggle comments |
|
||||
| Shortcut | Description |
|
||||
| -------- | --------------- |
|
||||
| `⌘/` | Toggle comments |
|
||||
{: .-shortcuts}
|
||||
|
||||
### View
|
||||
|
||||
| Shortcut | Description |
|
||||
| --- | --- |
|
||||
| `⌘k` `←` | Split pane to the left |
|
||||
| --- | --- |
|
||||
| `⌘⌥=` | Grow pane |
|
||||
| `⌘⌥-` | Shrink pane |
|
||||
| --- | --- |
|
||||
| `^⇧←` | Move tab to left |
|
||||
| Shortcut | Description |
|
||||
| -------- | ---------------------- |
|
||||
| `⌘k` `←,→,↑,↓` | Split pane to the left, right, up, or down |
|
||||
| --- | --- |
|
||||
| `⌘⌥=` | Grow pane |
|
||||
| `⌘⌥-` | Shrink pane |
|
||||
| --- | --- |
|
||||
| `^⇧←`/`^⇧→` | Move tab to left/right |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Bracket matcher
|
||||
|
||||
| `^m` | Go to matching bracket |
|
||||
| `^]` | Remove brackets from selection |
|
||||
| `^⌘m` | Select inside brackets |
|
||||
| `⌥⌘.` | Close tag |
|
||||
| Shortcut | Description |
|
||||
| -------- | ------------------------------ |
|
||||
| `^m` | Go to matching bracket |
|
||||
| `^⌫` | Remove brackets from selection |
|
||||
| `^⌘m` | Select inside brackets |
|
||||
| `⌥⌘.` | Close tag |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Symbols view
|
||||
|
||||
| `^⌥↓` | Jump to declaration under cursor |
|
||||
| `^⇧r` | Show tags |
|
||||
| Shortcut | Description |
|
||||
| -------- | -------------------------------- |
|
||||
| `⌥⌘↓` | Jump to declaration under cursor |
|
||||
| `^⇧r` | Show tags |
|
||||
{: .-shortcuts}
|
||||
|
||||
Symbols view enables Ctags support for Atom.
|
||||
@ -56,40 +58,42 @@ See: [Symbols view](https://atom.io/packages/symbols-view)
|
||||
|
||||
### Git
|
||||
|
||||
| Shortcut | Description |
|
||||
| -------- | ------------------------------ |
|
||||
| `^⇧9` | Show Git pane |
|
||||
| `^⇧8` | Show GitHub pane |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Editing
|
||||
|
||||
| Shortcut | Description
|
||||
| --- | ---
|
||||
| `⌘d` | Select word
|
||||
| `⌘l` | Select line
|
||||
| --- | ---
|
||||
| `⌘↓` | Move line down
|
||||
| `⌘↑` | Move line up
|
||||
| --- | ---
|
||||
| `⌘⏎` | New line below
|
||||
| `⌘⇧⏎` | New line above
|
||||
| --- | ---
|
||||
| `⌘⇧k` | Delete line
|
||||
| `⌘⇧d` | Duplicate line
|
||||
| Shortcut | Description |
|
||||
| -------- | -------------- |
|
||||
| `⌘d` | Select word |
|
||||
| `⌘l` | Select line |
|
||||
| --- | --- |
|
||||
| `^⌘↑` | Move line up |
|
||||
| `^⌘↓` | Move line down |
|
||||
| --- | --- |
|
||||
| `⌘⏎` | New line below |
|
||||
| `⌘⇧⏎` | New line above |
|
||||
| --- | --- |
|
||||
| `^⇧k` | Delete line |
|
||||
| `⌘⇧d` | Duplicate line |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Project
|
||||
|
||||
| Shortcut | Description
|
||||
| --- | ---
|
||||
| `⌘⇧p` | Command palette
|
||||
| `⌘⇧a` | Add project folder
|
||||
| --- | ---
|
||||
| `⌘n` | New file
|
||||
| `⌘⇧n` | New window
|
||||
| --- | ---
|
||||
| `⌘f` | Find in file
|
||||
| `⌘⇧f` | Find in project
|
||||
| `⌘t` | Search files in project
|
||||
| Shortcut | Description |
|
||||
| -------- | ----------------------- |
|
||||
| `⌘⇧p` | Command palette |
|
||||
| `⌘⇧o` | Add project folder |
|
||||
| --- | --- |
|
||||
| `⌘n` | New file |
|
||||
| `⌘⇧n` | New window |
|
||||
| --- | --- |
|
||||
| `⌘f` | Find in file |
|
||||
| `⌘⇧f` | Find in project |
|
||||
| `⌘t` | Search files in project |
|
||||
{: .-shortcuts}
|
||||
|
||||
## Notes
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
title: Awesome Redux
|
||||
category: React
|
||||
layout: 2017/sheet
|
||||
updated: 2017-08-30
|
||||
updated: 2017-11-19
|
||||
---
|
||||
|
||||
### redux-actions
|
||||
|
19
awscli.md
19
awscli.md
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: AWS CLI
|
||||
category: Devops
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### EC2
|
||||
@ -9,6 +8,7 @@ layout: 2017/sheet
|
||||
```
|
||||
aws ec2 describe-instances
|
||||
aws ec2 start-instances --instance-ids i-12345678c
|
||||
aws ec2 terminate-instances --instance-ids i-12345678c
|
||||
```
|
||||
|
||||
### S3
|
||||
@ -37,6 +37,13 @@ brew install awscli
|
||||
aws configure
|
||||
```
|
||||
|
||||
### Configuration profiles
|
||||
|
||||
```
|
||||
aws configure --profile project1
|
||||
aws configure --profile project2
|
||||
```
|
||||
|
||||
## Elastic Beanstalk
|
||||
|
||||
### Configuration
|
||||
@ -48,15 +55,15 @@ aws configure
|
||||
eb config
|
||||
```
|
||||
|
||||
See: <http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html>
|
||||
See: <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html>
|
||||
|
||||
## ebextensions
|
||||
|
||||
* <http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html>
|
||||
* <http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html>
|
||||
* <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html>
|
||||
* <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html>
|
||||
|
||||
## Also see
|
||||
|
||||
* [AWS CLI](https://aws.amazon.com/cli/)
|
||||
* [Documentation](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)
|
||||
* [All commands](http://docs.aws.amazon.com/cli/latest/reference/#available-services)
|
||||
* [Documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)
|
||||
* [All commands](https://docs.aws.amazon.com/cli/latest/reference/#available-services)
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
title: Backbone.js
|
||||
layout: 2017/sheet
|
||||
updated: 2017-09-04
|
||||
updated: 2018-12-06
|
||||
category: JavaScript libraries
|
||||
---
|
||||
|
||||
### Binding events
|
||||
|
102
badges.md
102
badges.md
@ -1,102 +0,0 @@
|
||||
---
|
||||
title: Code badges
|
||||
---
|
||||
|
||||
Here are some badges for open source projects.
|
||||
|
||||
### Badge markdown
|
||||
|
||||
Travis
|
||||
[](https://travis-ci.org/rstacruz/REPO)
|
||||
|
||||
CodeClimate (shields.io)
|
||||
[](https://codeclimate.com/github/rstacruz/REPO
|
||||
"CodeClimate")
|
||||
|
||||
Coveralls (shields.io)
|
||||
[](https://coveralls.io/r/rstacruz/REPO)
|
||||
|
||||
Travis (shields.io)
|
||||
[](https://travis-ci.org/rstacruz/REPO "See test builds")
|
||||
|
||||
NPM (shields.io)
|
||||
[](https://npmjs.org/package/REPO "View this project on npm")
|
||||
|
||||
Ruby gem (shields.io)
|
||||
[](http://rubygems.org/gems/GEMNAME "View this project in Rubygems")
|
||||
|
||||
### Etc
|
||||
|
||||
Gitter chat
|
||||
[](https://gitter.im/USER/REPO "Gitter chat")
|
||||
|
||||
Gitter chat (shields.io)
|
||||
[]( https://gitter.im/USER/REPO )
|
||||
|
||||
david-dm
|
||||
[](https://david-dm.org/rstacruz/REPO)
|
||||
|
||||
[](http://opensource.org/licenses/MIT)
|
||||
|
||||
[](http://opensource.org/licenses/MIT)
|
||||
|
||||
### Support stuff
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
__Bugs and requests__: submit them through the project's issues tracker.<br>
|
||||
[]( https://github.com/USER/REPO/issues )
|
||||
|
||||
__Questions__: ask them at StackOverflow with the tag *REPO*.<br>
|
||||
[]( http://stackoverflow.com/questions/tagged/REPO )
|
||||
|
||||
__Chat__: join us at gitter.im.<br>
|
||||
[]( https://gitter.im/USER/REPO )
|
||||
|
||||
### Frontend js installation
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Add [nprogress.js] and [nprogress.css] to your project.
|
||||
|
||||
```html
|
||||
<script src='nprogress.js'></script>
|
||||
<link rel='stylesheet' href='nprogress.css'/>
|
||||
```
|
||||
|
||||
NProgress is available via [bower] and [npm].
|
||||
|
||||
$ bower install --save nprogress
|
||||
$ npm install --save nprogress
|
||||
|
||||
[bower]: http://bower.io/search/?q=nprogress
|
||||
[npm]: https://www.npmjs.org/package/nprogress
|
||||
|
||||
### Acknowledgements
|
||||
|
||||
**PROJECTNAME** © 2014+, Rico Sta. Cruz. Released under the [MIT] License.<br>
|
||||
Authored and maintained by Rico Sta. Cruz with help from contributors ([list][contributors]).
|
||||
|
||||
> [ricostacruz.com](http://ricostacruz.com) ·
|
||||
> GitHub [@rstacruz](https://github.com/rstacruz) ·
|
||||
> Twitter [@rstacruz](https://twitter.com/rstacruz)
|
||||
|
||||
[MIT]: http://mit-license.org/
|
||||
[contributors]: http://github.com/rstacruz/nprogress/contributors
|
||||
|
||||
### Links
|
||||
|
||||
* Everything: http://shields.io/
|
||||
|
||||
* Version badge (gems, npm): http://badge.fury.io/
|
||||
|
||||
* Dependencies (ruby): http://gemnasium.com/
|
||||
|
||||
* CI: http://travis-ci.org/
|
||||
|
||||
* Code quality (ruby): http://codeclimate.com/
|
||||
|
||||
* Test coverage: https://coveralls.io/
|
||||
|
577
bash.md
577
bash.md
@ -1,9 +1,8 @@
|
||||
---
|
||||
title: Bash scripting
|
||||
category: CLI
|
||||
layout: 2017/sheet
|
||||
tags: [Featured]
|
||||
updated: 2018-11-19
|
||||
updated: 2020-07-05
|
||||
keywords:
|
||||
- Variables
|
||||
- Functions
|
||||
@ -14,45 +13,61 @@ keywords:
|
||||
- Command substitution
|
||||
---
|
||||
|
||||
Getting started
|
||||
---------------
|
||||
## Getting started
|
||||
{: .-three-column}
|
||||
|
||||
### Introduction
|
||||
{: .-intro}
|
||||
|
||||
This is a quick reference to getting started with Bash scripting.
|
||||
|
||||
- [Learn bash in y minutes](https://learnxinyminutes.com/docs/bash/) _(learnxinyminutes.com)_
|
||||
- [Bash Guide](http://mywiki.wooledge.org/BashGuide) _(mywiki.wooledge.org)_
|
||||
- [Bash Hackers Wiki](https://web.archive.org/web/20230406205817/https://wiki.bash-hackers.org/) _(wiki.bash-hackers.org)_
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
NAME="John"
|
||||
echo "Hello $NAME!"
|
||||
name="John"
|
||||
echo "Hello $name!"
|
||||
```
|
||||
|
||||
### Variables
|
||||
|
||||
```bash
|
||||
NAME="John"
|
||||
echo $NAME
|
||||
echo "$NAME"
|
||||
echo "${NAME}!"
|
||||
name="John"
|
||||
echo $name # see below
|
||||
echo "$name"
|
||||
echo "${name}!"
|
||||
```
|
||||
|
||||
Generally quote your variables unless they contain wildcards to expand or command fragments.
|
||||
|
||||
```bash
|
||||
wildcard="*.txt"
|
||||
options="iv"
|
||||
cp -$options $wildcard /tmp
|
||||
```
|
||||
|
||||
### String quotes
|
||||
|
||||
```bash
|
||||
NAME="John"
|
||||
echo "Hi $NAME" #=> Hi John
|
||||
echo 'Hi $NAME' #=> Hi $NAME
|
||||
name="John"
|
||||
echo "Hi $name" #=> Hi John
|
||||
echo 'Hi $name' #=> Hi $name
|
||||
```
|
||||
|
||||
### Shell execution
|
||||
|
||||
```bash
|
||||
echo "I'm in $(pwd)"
|
||||
echo "I'm in `pwd`"
|
||||
echo "I'm in `pwd`" # obsolescent
|
||||
# Same
|
||||
```
|
||||
|
||||
See [Command substitution](http://wiki.bash-hackers.org/syntax/expansion/cmdsubst)
|
||||
See [Command substitution](https://web.archive.org/web/20230326081741/https://wiki.bash-hackers.org/syntax/expansion/cmdsubst)
|
||||
|
||||
### Conditional execution
|
||||
|
||||
@ -78,9 +93,9 @@ See: [Functions](#functions)
|
||||
{: id='conditionals-example'}
|
||||
|
||||
```bash
|
||||
if [ -z "$string" ]; then
|
||||
if [[ -z "$string" ]]; then
|
||||
echo "String is empty"
|
||||
elif [ -n "$string" ]; then
|
||||
elif [[ -n "$string" ]]; then
|
||||
echo "String is not empty"
|
||||
fi
|
||||
```
|
||||
@ -102,77 +117,102 @@ See: [Unofficial bash strict mode](http://redsymbol.net/articles/unofficial-bash
|
||||
echo {A,B}.js
|
||||
```
|
||||
|
||||
| `{A,B}` | Same as `A B` |
|
||||
| `{A,B}.js` | Same as `A.js B.js` |
|
||||
| `{1..5}` | Same as `1 2 3 4 5` |
|
||||
| Expression | Description |
|
||||
| ---------------------- | --------------------- |
|
||||
| `{A,B}` | Same as `A B` |
|
||||
| `{A,B}.js` | Same as `A.js B.js` |
|
||||
| `{1..5}` | Same as `1 2 3 4 5` |
|
||||
| <code>{{1..3},{7..9}}</code> | Same as `1 2 3 7 8 9` |
|
||||
|
||||
See: [Brace expansion](http://wiki.bash-hackers.org/syntax/expansion/brace)
|
||||
See: [Brace expansion](https://web.archive.org/web/20230207192110/https://wiki.bash-hackers.org/syntax/expansion/brace)
|
||||
|
||||
|
||||
Parameter expansions
|
||||
--------------------
|
||||
## Parameter expansions
|
||||
{: .-three-column}
|
||||
|
||||
### Basics
|
||||
|
||||
```bash
|
||||
name="John"
|
||||
echo ${name}
|
||||
echo ${name/J/j} #=> "john" (substitution)
|
||||
echo ${name:0:2} #=> "Jo" (slicing)
|
||||
echo ${name::2} #=> "Jo" (slicing)
|
||||
echo ${name::-1} #=> "Joh" (slicing)
|
||||
echo ${food:-Cake} #=> $food or "Cake"
|
||||
echo "${name}"
|
||||
echo "${name/J/j}" #=> "john" (substitution)
|
||||
echo "${name:0:2}" #=> "Jo" (slicing)
|
||||
echo "${name::2}" #=> "Jo" (slicing)
|
||||
echo "${name::-1}" #=> "Joh" (slicing)
|
||||
echo "${name:(-1)}" #=> "n" (slicing from right)
|
||||
echo "${name:(-2):1}" #=> "h" (slicing from right)
|
||||
echo "${food:-Cake}" #=> $food or "Cake"
|
||||
```
|
||||
|
||||
```bash
|
||||
length=2
|
||||
echo ${name:0:length} #=> "Jo"
|
||||
echo "${name:0:length}" #=> "Jo"
|
||||
```
|
||||
|
||||
See: [Parameter expansion](http://wiki.bash-hackers.org/syntax/pe)
|
||||
See: [Parameter expansion](https://web.archive.org/web/20230408142504/https://wiki.bash-hackers.org/syntax/pe)
|
||||
|
||||
```bash
|
||||
STR="/path/to/foo.cpp"
|
||||
echo ${STR%.cpp} # /path/to/foo
|
||||
echo ${STR%.cpp}.o # /path/to/foo.o
|
||||
str="/path/to/foo.cpp"
|
||||
echo "${str%.cpp}" # /path/to/foo
|
||||
echo "${str%.cpp}.o" # /path/to/foo.o
|
||||
echo "${str%/*}" # /path/to
|
||||
|
||||
echo ${STR##*.} # cpp (extension)
|
||||
echo ${STR##*/} # foo.cpp (basepath)
|
||||
echo "${str##*.}" # cpp (extension)
|
||||
echo "${str##*/}" # foo.cpp (basepath)
|
||||
|
||||
echo ${STR#*/} # path/to/foo.cpp
|
||||
echo ${STR##*/} # foo.cpp
|
||||
echo "${str#*/}" # path/to/foo.cpp
|
||||
echo "${str##*/}" # foo.cpp
|
||||
|
||||
echo ${STR/foo/bar} # /path/to/bar.cpp
|
||||
echo "${str/foo/bar}" # /path/to/bar.cpp
|
||||
```
|
||||
|
||||
```bash
|
||||
STR="Hello world"
|
||||
echo ${STR:6:5} # "world"
|
||||
echo ${STR:-5:5} # "world"
|
||||
str="Hello world"
|
||||
echo "${str:6:5}" # "world"
|
||||
echo "${str: -5:5}" # "world"
|
||||
```
|
||||
|
||||
```bash
|
||||
SRC="/path/to/foo.cpp"
|
||||
BASE=${SRC##*/} #=> "foo.cpp" (basepath)
|
||||
DIR=${SRC%$BASE} #=> "/path/to/" (dirpath)
|
||||
src="/path/to/foo.cpp"
|
||||
base=${src##*/} #=> "foo.cpp" (basepath)
|
||||
dir=${src%$base} #=> "/path/to/" (dirpath)
|
||||
dir=${src%/*} #=> "/path/to" (dirpath)
|
||||
```
|
||||
|
||||
### Prefix name expansion
|
||||
|
||||
```bash
|
||||
prefix_a=one
|
||||
prefix_b=two
|
||||
echo ${!prefix_*} # all variables names starting with `prefix_`
|
||||
prefix_a prefix_b
|
||||
```
|
||||
|
||||
### Indirection
|
||||
|
||||
```bash
|
||||
name=joe
|
||||
pointer=name
|
||||
echo ${!pointer}
|
||||
joe
|
||||
```
|
||||
|
||||
### Substitution
|
||||
|
||||
| Code | Description |
|
||||
| --- | --- |
|
||||
| `${FOO%suffix}` | Remove suffix |
|
||||
| `${FOO#prefix}` | Remove prefix |
|
||||
| --- | --- |
|
||||
| `${FOO%%suffix}` | Remove long suffix |
|
||||
| `${FOO##prefix}` | Remove long prefix |
|
||||
| --- | --- |
|
||||
| `${FOO/from/to}` | Replace first match |
|
||||
| `${FOO//from/to}` | Replace all |
|
||||
| --- | --- |
|
||||
| `${FOO/%from/to}` | Replace suffix |
|
||||
| `${FOO/#from/to}` | Replace prefix |
|
||||
| Code | Description |
|
||||
| ----------------- | ------------------- |
|
||||
| `${foo%suffix}` | Remove suffix |
|
||||
| `${foo#prefix}` | Remove prefix |
|
||||
| --- | --- |
|
||||
| `${foo%%suffix}` | Remove long suffix |
|
||||
| `${foo/%suffix}` | Remove long suffix |
|
||||
| `${foo##prefix}` | Remove long prefix |
|
||||
| `${foo/#prefix}` | Remove long prefix |
|
||||
| --- | --- |
|
||||
| `${foo/from/to}` | Replace first match |
|
||||
| `${foo//from/to}` | Replace all |
|
||||
| --- | --- |
|
||||
| `${foo/%from/to}` | Replace suffix |
|
||||
| `${foo/#from/to}` | Replace prefix |
|
||||
|
||||
### Comments
|
||||
|
||||
@ -190,31 +230,56 @@ comment
|
||||
|
||||
### Substrings
|
||||
|
||||
| `${FOO:0:3}` | Substring _(position, length)_ |
|
||||
| `${FOO:-3:3}` | Substring from the right |
|
||||
| Expression | Description |
|
||||
| --------------- | ------------------------------ |
|
||||
| `${foo:0:3}` | Substring _(position, length)_ |
|
||||
| `${foo:(-3):3}` | Substring from the right |
|
||||
|
||||
### Length
|
||||
|
||||
| `${#FOO}` | Length of `$FOO` |
|
||||
| Expression | Description |
|
||||
| ---------- | ---------------- |
|
||||
| `${#foo}` | Length of `$foo` |
|
||||
|
||||
### Manipulation
|
||||
|
||||
```bash
|
||||
str="HELLO WORLD!"
|
||||
echo "${str,}" #=> "hELLO WORLD!" (lowercase 1st letter)
|
||||
echo "${str,,}" #=> "hello world!" (all lowercase)
|
||||
|
||||
str="hello world!"
|
||||
echo "${str^}" #=> "Hello world!" (uppercase 1st letter)
|
||||
echo "${str^^}" #=> "HELLO WORLD!" (all uppercase)
|
||||
```
|
||||
|
||||
### Default values
|
||||
|
||||
| `${FOO:-val}` | `$FOO`, or `val` if not set |
|
||||
| `${FOO:=val}` | Set `$FOO` to `val` if not set |
|
||||
| `${FOO:+val}` | `val` if `$FOO` is set |
|
||||
| `${FOO:?message}` | Show error message and exit if `$FOO` is not set |
|
||||
| Expression | Description |
|
||||
| ----------------- | -------------------------------------------------------- |
|
||||
| `${foo:-val}` | `$foo`, or `val` if unset (or null) |
|
||||
| `${foo:=val}` | Set `$foo` to `val` if unset (or null) |
|
||||
| `${foo:+val}` | `val` if `$foo` is set (and not null) |
|
||||
| `${foo:?message}` | Show error message and exit if `$foo` is unset (or null) |
|
||||
|
||||
The `:` is optional (eg, `${FOO=word}` works)
|
||||
Omitting the `:` removes the (non)nullity checks, e.g. `${foo-val}` expands to `val` if unset otherwise `$foo`.
|
||||
|
||||
Loops
|
||||
-----
|
||||
## Loops
|
||||
{: .-three-column}
|
||||
|
||||
### Basic for loop
|
||||
|
||||
```bash
|
||||
for i in /etc/rc.*; do
|
||||
echo $i
|
||||
echo "$i"
|
||||
done
|
||||
```
|
||||
|
||||
### C-like for loop
|
||||
|
||||
```bash
|
||||
for ((i = 0 ; i < 100 ; i++)); do
|
||||
echo "$i"
|
||||
done
|
||||
```
|
||||
|
||||
@ -237,9 +302,9 @@ done
|
||||
### Reading lines
|
||||
|
||||
```bash
|
||||
cat file.txt | while read line; do
|
||||
echo $line
|
||||
done
|
||||
while read -r line; do
|
||||
echo "$line"
|
||||
done <file.txt
|
||||
```
|
||||
|
||||
### Forever
|
||||
@ -250,8 +315,7 @@ while true; do
|
||||
done
|
||||
```
|
||||
|
||||
Functions
|
||||
---------
|
||||
## Functions
|
||||
{: .-three-column}
|
||||
|
||||
### Defining functions
|
||||
@ -264,7 +328,7 @@ myfunc() {
|
||||
|
||||
```bash
|
||||
# Same as above (alternate syntax)
|
||||
function myfunc() {
|
||||
function myfunc {
|
||||
echo "hello $1"
|
||||
}
|
||||
```
|
||||
@ -278,7 +342,7 @@ myfunc "John"
|
||||
```bash
|
||||
myfunc() {
|
||||
local myresult='some value'
|
||||
echo $myresult
|
||||
echo "$myresult"
|
||||
}
|
||||
```
|
||||
|
||||
@ -304,78 +368,87 @@ fi
|
||||
|
||||
### Arguments
|
||||
|
||||
| Expression | Description |
|
||||
| --- | --- |
|
||||
| `$#` | Number of arguments |
|
||||
| `$*` | All arguments |
|
||||
| `$@` | All arguments, starting from first |
|
||||
| `$1` | First argument |
|
||||
| Expression | Description |
|
||||
| ---------- | ---------------------------------------------- |
|
||||
| `$#` | Number of arguments |
|
||||
| `$*` | All positional arguments (as a single word) |
|
||||
| `$@` | All positional arguments (as separate strings) |
|
||||
| `$1` | First argument |
|
||||
| `$_` | Last argument of the previous command |
|
||||
|
||||
See [Special parameters](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables).
|
||||
**Note**: `$@` and `$*` must be quoted in order to perform as described.
|
||||
Otherwise, they do exactly the same thing (arguments as separate strings).
|
||||
|
||||
Conditionals
|
||||
------------
|
||||
See [Special parameters](https://web.archive.org/web/20230318164746/https://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables).
|
||||
|
||||
## Conditionals
|
||||
{: .-three-column}
|
||||
|
||||
### Conditions
|
||||
|
||||
Note that `[[` is actually a command/program that returns either `0` (true) or `1` (false). Any program that obeys the same logic (like all base utils, such as `grep(1)` or `ping(1)`) can be used as condition, see examples.
|
||||
|
||||
| Condition | Description |
|
||||
| ------------------------ | --------------------- |
|
||||
| `[[ -z STRING ]]` | Empty string |
|
||||
| `[[ -n STRING ]]` | Not empty string |
|
||||
| `[[ STRING == STRING ]]` | Equal |
|
||||
| `[[ STRING != STRING ]]` | Not Equal |
|
||||
| --- | --- |
|
||||
| `[ STRING = STRING ]` | Equal |
|
||||
| `[ STRING != STRING ]` | Not Equal |
|
||||
| `[ -z STRING ]` | Empty string |
|
||||
| `[ -n STRING ]` | Not empty string |
|
||||
| --- | --- |
|
||||
| `[ NUM -eq NUM ]` | Equal |
|
||||
| `[ NUM -ne NUM ]` | Not equal |
|
||||
| `[ NUM -lt NUM ]` | Less than |
|
||||
| `[ NUM -le NUM ]` | Less than or equal |
|
||||
| `[ NUM -gt NUM ]` | Greater than |
|
||||
| `[ NUM -ge NUM ]` | Greater than or equal |
|
||||
| `[[ NUM -eq NUM ]]` | Equal |
|
||||
| `[[ NUM -ne NUM ]]` | Not equal |
|
||||
| `[[ NUM -lt NUM ]]` | Less than |
|
||||
| `[[ NUM -le NUM ]]` | Less than or equal |
|
||||
| `[[ NUM -gt NUM ]]` | Greater than |
|
||||
| `[[ NUM -ge NUM ]]` | Greater than or equal |
|
||||
| --- | --- |
|
||||
| `[[ STRING =~ STRING ]]` | Regexp |
|
||||
| --- | --- |
|
||||
| `(( NUM < NUM ))` | Numeric conditions |
|
||||
|
||||
| Condition | Description |
|
||||
| --- | --- |
|
||||
| `[ -o noclobber ]` | If OPTIONNAME is enabled |
|
||||
| --- | --- |
|
||||
| `[ ! EXPR ]` | Not |
|
||||
| `[ X ] && [ Y ]` | And |
|
||||
| `[ X ] || [ Y ]` | Or |
|
||||
#### More conditions
|
||||
|
||||
| Condition | Description |
|
||||
| -------------------- | ------------------------ |
|
||||
| `[[ -o noclobber ]]` | If OPTIONNAME is enabled |
|
||||
| --- | --- |
|
||||
| `[[ ! EXPR ]]` | Not |
|
||||
| `[[ X && Y ]]` | And |
|
||||
| `[[ X || Y ]]` | Or |
|
||||
|
||||
### File conditions
|
||||
|
||||
| Condition | Description |
|
||||
| --- | --- |
|
||||
| `[ -e FILE ]` | Exists |
|
||||
| `[ -r FILE ]` | Readable |
|
||||
| `[ -h FILE ]` | Symlink |
|
||||
| `[ -d FILE ]` | Directory |
|
||||
| `[ -w FILE ]` | Writable |
|
||||
| `[ -s FILE ]` | Size is > 0 bytes |
|
||||
| `[ -f FILE ]` | File |
|
||||
| `[ -x FILE ]` | Executable |
|
||||
| --- | --- |
|
||||
| `[ FILE1 -nt FILE2 ]` | 1 is more recent than 2 |
|
||||
| `[ FILE1 -ot FILE2 ]` | 2 is more recent than 1 |
|
||||
| `[ FILE1 -ef FILE2 ]` | Same files |
|
||||
| Condition | Description |
|
||||
| ----------------------- | ----------------------- |
|
||||
| `[[ -e FILE ]]` | Exists |
|
||||
| `[[ -r FILE ]]` | Readable |
|
||||
| `[[ -h FILE ]]` | Symlink |
|
||||
| `[[ -d FILE ]]` | Directory |
|
||||
| `[[ -w FILE ]]` | Writable |
|
||||
| `[[ -s FILE ]]` | Size is > 0 bytes |
|
||||
| `[[ -f FILE ]]` | File |
|
||||
| `[[ -x FILE ]]` | Executable |
|
||||
| --- | --- |
|
||||
| `[[ FILE1 -nt FILE2 ]]` | 1 is more recent than 2 |
|
||||
| `[[ FILE1 -ot FILE2 ]]` | 2 is more recent than 1 |
|
||||
| `[[ FILE1 -ef FILE2 ]]` | Same files |
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
# String
|
||||
if [ -z "$string" ]; then
|
||||
if [[ -z "$string" ]]; then
|
||||
echo "String is empty"
|
||||
elif [ -n "$string" ]; then
|
||||
elif [[ -n "$string" ]]; then
|
||||
echo "String is not empty"
|
||||
else
|
||||
echo "This never happens"
|
||||
fi
|
||||
```
|
||||
|
||||
```bash
|
||||
# Combinations
|
||||
if [ X ] && [ Y ]; then
|
||||
if [[ X && Y ]]; then
|
||||
...
|
||||
fi
|
||||
```
|
||||
@ -387,21 +460,22 @@ if [[ "$A" == "$B" ]]
|
||||
|
||||
```bash
|
||||
# Regex
|
||||
if [[ "A" =~ "." ]]
|
||||
if [[ "A" =~ . ]]
|
||||
```
|
||||
|
||||
```bash
|
||||
if (( $a < $b ))
|
||||
if (( $a < $b )); then
|
||||
echo "$a is smaller than $b"
|
||||
fi
|
||||
```
|
||||
|
||||
```bash
|
||||
if [ -e "file.txt" ]; then
|
||||
if [[ -e "file.txt" ]]; then
|
||||
echo "file exists"
|
||||
fi
|
||||
```
|
||||
|
||||
Arrays
|
||||
------
|
||||
## Arrays
|
||||
|
||||
### Defining arrays
|
||||
|
||||
@ -418,12 +492,14 @@ Fruits[2]="Orange"
|
||||
### Working with arrays
|
||||
|
||||
```bash
|
||||
echo ${Fruits[0]} # Element #0
|
||||
echo ${Fruits[@]} # All elements, space-separated
|
||||
echo ${#Fruits[@]} # Number of elements
|
||||
echo ${#Fruits} # String length of the 1st element
|
||||
echo ${#Fruits[3]} # String length of the Nth element
|
||||
echo ${Fruits[@]:3:2} # Range (from position 3, length 2)
|
||||
echo "${Fruits[0]}" # Element #0
|
||||
echo "${Fruits[-1]}" # Last element
|
||||
echo "${Fruits[@]}" # All elements, space-separated
|
||||
echo "${#Fruits[@]}" # Number of elements
|
||||
echo "${#Fruits}" # String length of the 1st element
|
||||
echo "${#Fruits[3]}" # String length of the Nth element
|
||||
echo "${Fruits[@]:3:2}" # Range (from position 3, length 2)
|
||||
echo "${!Fruits[@]}" # Keys of all elements, space-separated
|
||||
```
|
||||
|
||||
### Operations
|
||||
@ -431,23 +507,68 @@ echo ${Fruits[@]:3:2} # Range (from position 3, length 2)
|
||||
```bash
|
||||
Fruits=("${Fruits[@]}" "Watermelon") # Push
|
||||
Fruits+=('Watermelon') # Also Push
|
||||
Fruits=( ${Fruits[@]/Ap*/} ) # Remove by regex match
|
||||
Fruits=( "${Fruits[@]/Ap*/}" ) # Remove by regex match
|
||||
unset Fruits[2] # Remove one item
|
||||
Fruits=("${Fruits[@]}") # Duplicate
|
||||
Fruits=("${Fruits[@]}" "${Veggies[@]}") # Concatenate
|
||||
lines=(`cat "logfile"`) # Read from file
|
||||
words=($(< datafile)) # From file (split by IFS)
|
||||
```
|
||||
|
||||
### Iteration
|
||||
|
||||
```bash
|
||||
for i in "${arrayName[@]}"; do
|
||||
echo $i
|
||||
echo "$i"
|
||||
done
|
||||
```
|
||||
|
||||
Options
|
||||
-------
|
||||
## Dictionaries
|
||||
{: .-three-column}
|
||||
|
||||
### Defining
|
||||
|
||||
```bash
|
||||
declare -A sounds
|
||||
```
|
||||
|
||||
```bash
|
||||
sounds[dog]="bark"
|
||||
sounds[cow]="moo"
|
||||
sounds[bird]="tweet"
|
||||
sounds[wolf]="howl"
|
||||
```
|
||||
|
||||
Declares `sound` as a Dictionary object (aka associative array).
|
||||
|
||||
### Working with dictionaries
|
||||
|
||||
```bash
|
||||
echo "${sounds[dog]}" # Dog's sound
|
||||
echo "${sounds[@]}" # All values
|
||||
echo "${!sounds[@]}" # All keys
|
||||
echo "${#sounds[@]}" # Number of elements
|
||||
unset sounds[dog] # Delete dog
|
||||
```
|
||||
|
||||
### Iteration
|
||||
|
||||
#### Iterate over values
|
||||
|
||||
```bash
|
||||
for val in "${sounds[@]}"; do
|
||||
echo "$val"
|
||||
done
|
||||
```
|
||||
|
||||
#### Iterate over keys
|
||||
|
||||
```bash
|
||||
for key in "${!sounds[@]}"; do
|
||||
echo "$key"
|
||||
done
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### Options
|
||||
|
||||
@ -461,55 +582,60 @@ set -o nounset # Exposes unset variables
|
||||
### Glob options
|
||||
|
||||
```bash
|
||||
set -o nullglob # Non-matching globs are removed ('*.foo' => '')
|
||||
set -o failglob # Non-matching globs throw errors
|
||||
set -o nocaseglob # Case insensitive globs
|
||||
set -o globdots # Wildcards match dotfiles ("*.sh" => ".foo.sh")
|
||||
set -o globstar # Allow ** for recursive matches ('lib/**/*.rb' => 'lib/a/b/c.rb')
|
||||
shopt -s nullglob # Non-matching globs are removed ('*.foo' => '')
|
||||
shopt -s failglob # Non-matching globs throw errors
|
||||
shopt -s nocaseglob # Case insensitive globs
|
||||
shopt -s dotglob # Wildcards match dotfiles ("*.sh" => ".foo.sh")
|
||||
shopt -s globstar # Allow ** for recursive matches ('lib/**/*.rb' => 'lib/a/b/c.rb')
|
||||
```
|
||||
|
||||
Set `GLOBIGNORE` as a colon-separated list of patterns to be removed from glob
|
||||
matches.
|
||||
|
||||
History
|
||||
-------
|
||||
## History
|
||||
|
||||
### Commands
|
||||
|
||||
| `history` | Show history |
|
||||
| Command | Description |
|
||||
| --------------------- | ----------------------------------------- |
|
||||
| `history` | Show history |
|
||||
| `shopt -s histverify` | Don't execute expanded result immediately |
|
||||
|
||||
### Expansions
|
||||
|
||||
| `!$` | Expand last parameter of most recent command |
|
||||
| `!*` | Expand all parameters of most recent command |
|
||||
| `!-n` | Expand `n`th most recent command |
|
||||
| `!n` | Expand `n`th command in history |
|
||||
| Expression | Description |
|
||||
| ------------ | ---------------------------------------------------- |
|
||||
| `!$` | Expand last parameter of most recent command |
|
||||
| `!*` | Expand all parameters of most recent command |
|
||||
| `!-n` | Expand `n`th most recent command |
|
||||
| `!n` | Expand `n`th command in history |
|
||||
| `!<command>` | Expand most recent invocation of command `<command>` |
|
||||
|
||||
### Operations
|
||||
|
||||
| `!!` | Execute last command again |
|
||||
| `!!:s/<FROM>/<TO>/` | Replace first occurrence of `<FROM>` to `<TO>` in most recent command |
|
||||
| `!!:gs/<FROM>/<TO>/` | Replace all occurrences of `<FROM>` to `<TO>` in most recent command |
|
||||
| `!$:t` | Expand only basename from last parameter of most recent command |
|
||||
| `!$:h` | Expand only directory from last parameter of most recent command |
|
||||
| Code | Description |
|
||||
| -------------------- | --------------------------------------------------------------------- |
|
||||
| `!!` | Execute last command again |
|
||||
| `!!:s/<FROM>/<TO>/` | Replace first occurrence of `<FROM>` to `<TO>` in most recent command |
|
||||
| `!!:gs/<FROM>/<TO>/` | Replace all occurrences of `<FROM>` to `<TO>` in most recent command |
|
||||
| `!$:t` | Expand only basename from last parameter of most recent command |
|
||||
| `!$:h` | Expand only directory from last parameter of most recent command |
|
||||
|
||||
`!!` and `!$` can be replaced with any valid expansion.
|
||||
|
||||
### Slices
|
||||
|
||||
| `!!:n` | Expand only `n`th token from most recent command (command is `0`; first argument is `1`) |
|
||||
| `!^` | Expand first argument from most recent command |
|
||||
| `!$` | Expand last token from most recent command |
|
||||
| `!!:n-m` | Expand range of tokens from most recent command |
|
||||
| `!!:n-$` | Expand `n`th token to last from most recent command |
|
||||
| Code | Description |
|
||||
| -------- | ---------------------------------------------------------------------------------------- |
|
||||
| `!!:n` | Expand only `n`th token from most recent command (command is `0`; first argument is `1`) |
|
||||
| `!^` | Expand first argument from most recent command |
|
||||
| `!$` | Expand last token from most recent command |
|
||||
| `!!:n-m` | Expand range of tokens from most recent command |
|
||||
| `!!:n-$` | Expand `n`th token to last from most recent command |
|
||||
|
||||
`!!` can be replaced with any valid expansion i.e. `!cat`, `!-2`, `!42`, etc.
|
||||
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
## Miscellaneous
|
||||
|
||||
### Numeric calculations
|
||||
|
||||
@ -518,7 +644,12 @@ $((a + 200)) # Add 200 to $a
|
||||
```
|
||||
|
||||
```bash
|
||||
$((RANDOM%=200)) # Random number 0..200
|
||||
$(($RANDOM%200)) # Random number 0..199
|
||||
```
|
||||
|
||||
```bash
|
||||
declare -i count # Declare as type integer
|
||||
count+=1 # Increment
|
||||
```
|
||||
|
||||
### Subshells
|
||||
@ -531,16 +662,19 @@ pwd # still in first directory
|
||||
### Redirection
|
||||
|
||||
```bash
|
||||
python hello.py > output.txt # stdout to (file)
|
||||
python hello.py >> output.txt # stdout to (file), append
|
||||
python hello.py 2> error.log # stderr to (file)
|
||||
python hello.py 2>&1 # stderr to stdout
|
||||
python hello.py 2>/dev/null # stderr to (null)
|
||||
python hello.py &>/dev/null # stdout and stderr to (null)
|
||||
python hello.py > output.txt # stdout to (file)
|
||||
python hello.py >> output.txt # stdout to (file), append
|
||||
python hello.py 2> error.log # stderr to (file)
|
||||
python hello.py 2>&1 # stderr to stdout
|
||||
python hello.py 2>/dev/null # stderr to (null)
|
||||
python hello.py >output.txt 2>&1 # stdout and stderr to (file), equivalent to &>
|
||||
python hello.py &>/dev/null # stdout and stderr to (null)
|
||||
echo "$0: warning: too many users" >&2 # print diagnostic message to stderr
|
||||
```
|
||||
|
||||
```bash
|
||||
python hello.py < foo.txt
|
||||
python hello.py < foo.txt # feed foo.txt to stdin for python
|
||||
diff <(ls -r) <(ls) # Compare two stdout without files
|
||||
```
|
||||
|
||||
### Inspecting commands
|
||||
@ -592,12 +726,44 @@ source "${0%/*}/../share/foo.sh"
|
||||
```bash
|
||||
printf "Hello %s, I'm %s" Sven Olga
|
||||
#=> "Hello Sven, I'm Olga
|
||||
|
||||
printf "1 + 1 = %d" 2
|
||||
#=> "1 + 1 = 2"
|
||||
|
||||
printf "This is how you print a float: %f" 2
|
||||
#=> "This is how you print a float: 2.000000"
|
||||
|
||||
printf '%s\n' '#!/bin/bash' 'echo hello' >file
|
||||
# format string is applied to each group of arguments
|
||||
printf '%i+%i=%i\n' 1 2 3 4 5 9
|
||||
```
|
||||
|
||||
### Transform strings
|
||||
|
||||
| Command option | Description |
|
||||
| -------------- | --------------------------------------------------- |
|
||||
| `-c` | Operations apply to characters not in the given set |
|
||||
| `-d` | Delete characters |
|
||||
| `-s` | Replaces repeated characters with single occurrence |
|
||||
| `-t` | Truncates |
|
||||
| `[:upper:]` | All upper case letters |
|
||||
| `[:lower:]` | All lower case letters |
|
||||
| `[:digit:]` | All digits |
|
||||
| `[:space:]` | All whitespace |
|
||||
| `[:alpha:]` | All letters |
|
||||
| `[:alnum:]` | All letters and digits |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
echo "Welcome To Devhints" | tr '[:lower:]' '[:upper:]'
|
||||
WELCOME TO DEVHINTS
|
||||
```
|
||||
|
||||
### Directory of script
|
||||
|
||||
```bash
|
||||
DIR="${0%/*}"
|
||||
dir=${0%/*}
|
||||
```
|
||||
|
||||
### Getting options
|
||||
@ -605,7 +771,7 @@ DIR="${0%/*}"
|
||||
```bash
|
||||
while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in
|
||||
-V | --version )
|
||||
echo $version
|
||||
echo "$version"
|
||||
exit
|
||||
;;
|
||||
-s | --string )
|
||||
@ -626,25 +792,56 @@ hello world
|
||||
END
|
||||
```
|
||||
|
||||
Heredoc allows a section of your source code to be treated as a file. See [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Here-Documents).
|
||||
|
||||
### Herestring
|
||||
|
||||
```sh
|
||||
tr '[:lower:]' '[:upper:]' <<< "Will be uppercased, even $variable"
|
||||
```
|
||||
|
||||
Herestring allows a string to be treated as a standard input (stdin). See [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Here-Strings).
|
||||
|
||||
### Process substitution
|
||||
|
||||
```sh
|
||||
# loop on myfunc output lines
|
||||
while read -r line; do
|
||||
echo "$line"
|
||||
done < <(myfunc)
|
||||
|
||||
# compare content of two folders
|
||||
diff <(ls "$dir1") <(ls "$dir2")
|
||||
```
|
||||
|
||||
Process substitution allows the input (or output) of a command to be treated as a file. See [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/Process-Substitution.html).
|
||||
|
||||
### Reading input
|
||||
|
||||
```bash
|
||||
echo -n "Proceed? [y/n]: "
|
||||
read ans
|
||||
echo $ans
|
||||
read -r ans
|
||||
echo "$ans"
|
||||
```
|
||||
|
||||
The `-r` option disables a peculiar legacy behavior with backslashes.
|
||||
|
||||
```bash
|
||||
read -n 1 ans # Just one character
|
||||
```
|
||||
|
||||
### Special variables
|
||||
|
||||
| `$?` | Exit status of last task |
|
||||
| `$!` | PID of last background task |
|
||||
| `$$` | PID of shell |
|
||||
| Expression | Description |
|
||||
| ------------------ | -------------------------------------- |
|
||||
| `$?` | Exit status of last task |
|
||||
| `$!` | PID of last background task |
|
||||
| `$$` | PID of shell |
|
||||
| `$0` | Filename of the shell script |
|
||||
| `$_` | Last argument of the previous command |
|
||||
| `${PIPESTATUS[n]}` | return value of piped commands (array) |
|
||||
|
||||
See [Special parameters](http://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables).
|
||||
See [Special parameters](https://web.archive.org/web/20230318164746/https://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables).
|
||||
|
||||
### Go to previous directory
|
||||
|
||||
@ -656,9 +853,27 @@ cd -
|
||||
pwd # /home/user/foo
|
||||
```
|
||||
|
||||
### Check for command's result
|
||||
|
||||
```bash
|
||||
if ping -c 1 google.com; then
|
||||
echo "It appears you have a working internet connection"
|
||||
fi
|
||||
```
|
||||
|
||||
### Grep check
|
||||
|
||||
```bash
|
||||
if grep -q 'foo' ~/.bash_history; then
|
||||
echo "You appear to have typed 'foo' in the past"
|
||||
fi
|
||||
```
|
||||
|
||||
## Also see
|
||||
{: .-one-column}
|
||||
|
||||
* [Bash-hackers wiki](http://wiki.bash-hackers.org/) _(bash-hackers.org)_
|
||||
* [Shell vars](http://wiki.bash-hackers.org/syntax/shellvars) _(bash-hackers.org)_
|
||||
* [Learn bash in y minutes](https://learnxinyminutes.com/docs/bash/) _(learnxinyminutes.com)_
|
||||
- [Bash-hackers wiki](https://web.archive.org/web/20230406205817/https://wiki.bash-hackers.org/) _(bash-hackers.org)_
|
||||
- [Shell vars](https://web.archive.org/web/20230318164746/https://wiki.bash-hackers.org/syntax/shellvars) _(bash-hackers.org)_
|
||||
- [Learn bash in y minutes](https://learnxinyminutes.com/docs/bash/) _(learnxinyminutes.com)_
|
||||
- [Bash Guide](http://mywiki.wooledge.org/BashGuide) _(mywiki.wooledge.org)_
|
||||
- [ShellCheck](https://www.shellcheck.net/) _(shellcheck.net)_
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Blessed
|
||||
category: JavaScript libraries
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### Screen
|
||||
|
@ -1,9 +1,8 @@
|
||||
---
|
||||
title: bluebird.js
|
||||
category: JavaScript libraries
|
||||
layout: 2017/sheet
|
||||
weight: -1
|
||||
updated: 2017-09-04
|
||||
updated: 2017-09-08
|
||||
---
|
||||
|
||||
### Also see
|
||||
@ -18,7 +17,7 @@ promise
|
||||
.spread(okFn, errFn) // *
|
||||
.catch(errFn)
|
||||
.catch(TypeError, errFn) // *
|
||||
.finally(fn) // *
|
||||
.finally(fn)
|
||||
.map(function (e) { ··· }) // *
|
||||
.each(function (e) { ··· }) // *
|
||||
```
|
||||
|
41
bolt.md
Normal file
41
bolt.md
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
title: Bolt Quickstart
|
||||
category: Bolt
|
||||
updated: 2018-12-25
|
||||
authors:
|
||||
- github: lucywyman
|
||||
keywords:
|
||||
- Puppet
|
||||
- tasks
|
||||
- modules
|
||||
description: |
|
||||
A quick guide to getting started writing Bolt tasks
|
||||
---
|
||||
|
||||
### Install Bolt
|
||||
|
||||
```bash
|
||||
# On MacOS
|
||||
brew cask install puppetlabs/puppet/puppet-bolt
|
||||
# On Windows
|
||||
choco install puppet-bolt
|
||||
```
|
||||
|
||||
Bolt is available as a package for most platforms. See [installing bolt](https://puppet.com/docs/bolt/latest/bolt_installing.html)
|
||||
|
||||
### Create a module with a task
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.puppetlabs/bolt/modules/mymodule/tasks
|
||||
cp myscript.sh ~/.puppetlabs/bolt/modules/mymodule/tasks/
|
||||
```
|
||||
|
||||
Tasks can be written in any language your targets can run. See [writing tasks](https://puppet.com/docs/bolt/latest/writing_tasks.html) for more details.
|
||||
|
||||
### Run Bolt
|
||||
|
||||
```bash
|
||||
bolt task run mymodule::myscript -n node1.example.com,node2.example.com --private-key ~/.ssh/id_rsa-private
|
||||
```
|
||||
|
||||
See `bolt task run --help` for more information and command line options.
|
@ -1,21 +0,0 @@
|
||||
# bookshelf-contrib.Scopes
|
||||
#
|
||||
class Books
|
||||
scopes:
|
||||
published: (q) -> q.where(published: true)
|
||||
|
||||
Books.published().fetchAll()
|
||||
|
||||
|
||||
# bookshelf-contrib.QueryProxy
|
||||
#
|
||||
Books.query().where(published: true)
|
||||
Books.where(published: true)
|
||||
|
||||
# bookshelf-contrib.Migration
|
||||
class Migration
|
||||
up: ->
|
||||
down: ->
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@ category: JavaScript libraries
|
||||
Model
|
||||
-----
|
||||
|
||||
### Model
|
||||
```js
|
||||
Summary = bookshelf.Model.extend({
|
||||
tableName: 'summaries',
|
||||
|
@ -1,8 +1,8 @@
|
||||
---
|
||||
title: Bootstrap
|
||||
layout: 2017/sheet
|
||||
prism_languages: [scss, haml, html]
|
||||
weight: -1
|
||||
category: CSS
|
||||
description: |
|
||||
.container .row .col-md-6, @screen-sm-min, .form-control, grids, .modal-content, tooltips, and other Bootstrap CSS examples.
|
||||
---
|
||||
|
@ -3,10 +3,12 @@ title: Browsersync
|
||||
category: JavaScript libraries
|
||||
---
|
||||
|
||||
```
|
||||
npm i -g browser-sync
|
||||
```
|
||||
{:.terminal}
|
||||
### About
|
||||
{: .-intro}
|
||||
|
||||
`npm i -g browser-sync`
|
||||
|
||||
* [browsersync.io](https://browsersync.io)
|
||||
|
||||
### Start a server
|
||||
|
||||
@ -20,7 +22,3 @@ browser-sync start --server <path> --files='**/*.html, **/*.css'
|
||||
--port=N
|
||||
--proxy="http://127.0.0.1:3000"
|
||||
```
|
||||
|
||||
### Reference
|
||||
|
||||
* [browsersync.io](http://browsersync.io)
|
||||
|
@ -1,8 +1,19 @@
|
||||
---
|
||||
title: Browserify
|
||||
category: JavaScript libraries
|
||||
tags: [Archived]
|
||||
archived: Browserify has not been in active development.
|
||||
---
|
||||
|
||||
### About
|
||||
{: .-intro}
|
||||
|
||||
Browserify is a bundler for JavaScript.
|
||||
|
||||
- <https://browserify.org/>
|
||||
|
||||
### Usage
|
||||
|
||||
browserify input.js
|
||||
-o output.js
|
||||
-t coffeeify
|
||||
|
97
brunch.md
97
brunch.md
@ -1,97 +0,0 @@
|
||||
---
|
||||
title: Brunch
|
||||
category: JavaScript libraries
|
||||
---
|
||||
|
||||
## Paths
|
||||
|
||||
/
|
||||
app/
|
||||
assets/
|
||||
vendor/
|
||||
public/
|
||||
config.coffee
|
||||
|
||||
## Config
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
files: {
|
||||
javascripts: { # or 'stylesheets' or 'templates'
|
||||
order: {
|
||||
before: [ 'normalize.css' ],
|
||||
after: [ 'helpers.css' ],
|
||||
|
||||
joinTo: 'app.js',
|
||||
joinTo: {
|
||||
'js/app.js': /^app/,
|
||||
'js/vendor.js': /^vendor/
|
||||
},
|
||||
pluginHelpers: 'js/vendor.js'
|
||||
}
|
||||
}
|
||||
|
||||
paths: {
|
||||
public: 'public', # where to compile
|
||||
watched: ['app','test','vendor'], # what to monitor
|
||||
}
|
||||
|
||||
modules: {
|
||||
wrapper: 'amd',
|
||||
definition: 'amd',
|
||||
nameCleaner: (path) => path.replace(/^app\//, '')
|
||||
}
|
||||
|
||||
npm: { styles, globals }
|
||||
|
||||
plugins: {
|
||||
sass: { ... }
|
||||
}
|
||||
|
||||
// brunch w --apply testing
|
||||
// BRUNCH_ENV=testing brunch build
|
||||
overrides: {
|
||||
production: {
|
||||
optimize: true,
|
||||
sourceMaps: false,
|
||||
plugins: { autoReload: { enabled: false } }
|
||||
}
|
||||
}
|
||||
|
||||
onCompile: (files, assets) => { ... }
|
||||
```
|
||||
|
||||
## Plugins
|
||||
|
||||
plugins:
|
||||
uglify:
|
||||
mangle: true
|
||||
compress:
|
||||
global_defs:
|
||||
DEBUG: false
|
||||
|
||||
## Extensions
|
||||
|
||||
Compile to CSS
|
||||
|
||||
* stylus-brunch
|
||||
* less-brunch
|
||||
* sass-brunch
|
||||
|
||||
Compile to HTML
|
||||
|
||||
* static-jade-brunch
|
||||
|
||||
Embedded templates
|
||||
|
||||
* emblem-brunch
|
||||
|
||||
Etc
|
||||
|
||||
* uglify-js-brunch
|
||||
* jshint-brunch
|
||||
* imageoptimizer-brunch
|
||||
|
||||
## References
|
||||
|
||||
* <https://github.com/brunch/brunch/blob/master/docs/config.md>
|
1
bulma.md
1
bulma.md
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Bulma
|
||||
category: CSS
|
||||
layout: 2017/sheet
|
||||
prism_languages: [css, html]
|
||||
weight: -1
|
||||
updated: 2018-11-19
|
||||
|
@ -1,49 +1,78 @@
|
||||
---
|
||||
title: C Preprocessor
|
||||
category: C-like
|
||||
intro: |
|
||||
Quick reference for the [C macro preprocessor](https://en.m.wikipedia.org/wiki/C_preprocessor), which can be used independent of C/C++.
|
||||
---
|
||||
|
||||
## Reference
|
||||
{: .-three-column}
|
||||
|
||||
### Compiling
|
||||
|
||||
$ cpp -P file > outfile
|
||||
```
|
||||
$ cpp -P file > outfile
|
||||
```
|
||||
|
||||
### Includes
|
||||
|
||||
#include "file"
|
||||
```
|
||||
#include "file"
|
||||
```
|
||||
|
||||
### Defines
|
||||
|
||||
#define FOO
|
||||
#define FOO "hello"
|
||||
```
|
||||
#define FOO
|
||||
#define FOO "hello"
|
||||
|
||||
#undef FOO
|
||||
#undef FOO
|
||||
```
|
||||
|
||||
### If
|
||||
|
||||
#ifdef DEBUG
|
||||
console.log('hi');
|
||||
#elif defined VERBOSE
|
||||
...
|
||||
#else
|
||||
...
|
||||
#endif
|
||||
```
|
||||
#ifdef DEBUG
|
||||
console.log('hi');
|
||||
#elif defined VERBOSE
|
||||
...
|
||||
#else
|
||||
...
|
||||
#endif
|
||||
```
|
||||
|
||||
### Error
|
||||
|
||||
#if VERSION == 2.0
|
||||
#error Unsupported
|
||||
#warning Not really supported
|
||||
#endif
|
||||
```
|
||||
#if VERSION == 2.0
|
||||
#error Unsupported
|
||||
#warning Not really supported
|
||||
#endif
|
||||
```
|
||||
|
||||
### Macro
|
||||
|
||||
#define DEG(x) ((x) * 57.29)
|
||||
```
|
||||
#define DEG(x) ((x) * 57.29)
|
||||
```
|
||||
|
||||
### Token concat
|
||||
|
||||
#define DST(name) name##_s name##_t
|
||||
DST(object); #=> "object_s object_t;"
|
||||
```
|
||||
#define DST(name) name##_s name##_t
|
||||
DST(object); #=> object_s object_t;
|
||||
```
|
||||
|
||||
### Stringification
|
||||
|
||||
```
|
||||
#define STR(name) #name
|
||||
char * a = STR(object); #=> char * a = "object";
|
||||
```
|
||||
|
||||
### file and line
|
||||
|
||||
#define LOG(msg) console.log(__FILE__, __LINE__, msg)
|
||||
#=> console.log("file.txt", 3, "hey")
|
||||
```
|
||||
#define LOG(msg) console.log(__FILE__, __LINE__, msg)
|
||||
#=> console.log("file.txt", 3, "hey")
|
||||
```
|
||||
|
1
camp.md
1
camp.md
@ -1,6 +1,5 @@
|
||||
---
|
||||
title: Camp
|
||||
layout: 2017/sheet
|
||||
category: JavaScript libraries
|
||||
updated: 2017-09-21
|
||||
weight: -1
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Canvas
|
||||
category: JavaScript
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### Getting the context
|
||||
|
32
capybara.md
32
capybara.md
@ -1,9 +1,8 @@
|
||||
---
|
||||
title: Capybara
|
||||
category: Ruby libraries
|
||||
layout: 2017/sheet
|
||||
weight: -5
|
||||
updated: 2017-08-30
|
||||
updated: 2020-06-13
|
||||
tags: [Featurable]
|
||||
---
|
||||
|
||||
@ -13,9 +12,11 @@ tags: [Featurable]
|
||||
|
||||
### Clicking links and buttons
|
||||
|
||||
click 'Link Text'
|
||||
click_button
|
||||
click_link
|
||||
```ruby
|
||||
click_on 'Link Text'
|
||||
click_button
|
||||
click_link
|
||||
```
|
||||
|
||||
### Interacting with forms
|
||||
|
||||
@ -117,14 +118,14 @@ In RSpec, you can use `page.should` assertions.
|
||||
### About negatives
|
||||
|
||||
```ruby
|
||||
expect(page).to have_no_button('Save') # OK
|
||||
```
|
||||
```ruby
|
||||
expect(page).not_to have_button('Save') # Bad
|
||||
expect(page).to have_no_button('Save')
|
||||
```
|
||||
|
||||
Use `should have_no_*` versions with RSpec matchers because
|
||||
`should_not have_*` doesn't wait for a timeout from the driver.
|
||||
```ruby
|
||||
expect(page).not_to have_button('Save')
|
||||
```
|
||||
|
||||
The two above statements are functionally equivalent.
|
||||
|
||||
## RSpec
|
||||
|
||||
@ -136,6 +137,7 @@ expect(page).to \
|
||||
{: .-setup}
|
||||
|
||||
```ruby
|
||||
have_current_path(expected_path)
|
||||
have_selector '.blank-state'
|
||||
have_selector 'h1#hola', text: 'Welcome'
|
||||
have_button 'Save'
|
||||
@ -217,7 +219,7 @@ find('#x').fill_in('Street', with: 'Hello')
|
||||
### Scripting
|
||||
|
||||
```ruby
|
||||
execute_script('$("input").trigger('change')')
|
||||
execute_script('$("input").trigger("change")')
|
||||
evaluate_script('window.ga')
|
||||
```
|
||||
|
||||
@ -264,7 +266,7 @@ page.status_code == 200
|
||||
page.response_headers
|
||||
```
|
||||
|
||||
See: <http://www.rubydoc.info/github/jnicklas/capybara/master/Capybara/Session>
|
||||
See: <https://www.rubydoc.info/github/jnicklas/capybara/master/Capybara/Session>
|
||||
|
||||
### Poltergeist
|
||||
|
||||
@ -331,5 +333,5 @@ page.set_rack_session(foo: 'bar')
|
||||
## See also
|
||||
{: .-one-column}
|
||||
|
||||
- <http://rubydoc.info/github/jnicklas/capybara/Capybara/RSpecMatchers>
|
||||
- <http://www.rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Matchers>
|
||||
- <https://rubydoc.info/github/jnicklas/capybara/Capybara/RSpecMatchers>
|
||||
- <https://www.rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Matchers>
|
||||
|
@ -1,10 +1,10 @@
|
||||
---
|
||||
title: Caskroom index
|
||||
tags: [Archived]
|
||||
archived: This sheet may have outdated information.
|
||||
---
|
||||
|
||||
|
||||
# Caskroom
|
||||
|
||||
|
||||
#### A
|
||||
|
||||
|
3
chai.md
3
chai.md
@ -1,9 +1,8 @@
|
||||
---
|
||||
title: Chai.js
|
||||
category: JavaScript libraries
|
||||
layout: 2017/sheet
|
||||
weight: -3
|
||||
updated: 2017-08-30
|
||||
updated: 2018-06-25
|
||||
version: chai v4.x
|
||||
description: |
|
||||
expect(x).to.be.equal(y) 〉 assert.equal(x, y) 〉 .to.be.true 〉 jQuery, assertions, TDD and BDD, and other Chai examples.
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
title: Cheatsheet styles
|
||||
layout: 2017/sheet
|
||||
tags: [WIP]
|
||||
updated: 2017-09-22
|
||||
updated: 2017-10-26
|
||||
intro: |
|
||||
This is a reference of styles that you can use on Devhints cheatsheets. How
|
||||
meta!
|
||||
@ -22,7 +21,6 @@ Variants
|
||||
| `-two-column` | _(default)_|
|
||||
| `-three-column` | |
|
||||
| `-left-reference` | 3 columns<br>_(short first column)_ |
|
||||
| `-no-hide` | Don't hide H2 |
|
||||
|
||||
See: [H2 sections](#two-columns)
|
||||
|
||||
|
11
chef.md
11
chef.md
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Chef
|
||||
category: Devops
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### Install
|
||||
@ -14,26 +13,26 @@ $ sudo apt-get install curl
|
||||
```
|
||||
|
||||
```bash
|
||||
$ curl -L https://www.opscode.com/chef/install.sh | bash
|
||||
$ curl -L https://omnitruck.chef.io/install.sh | sudo bash
|
||||
Thank you for installing Chef!
|
||||
```
|
||||
|
||||
```bash
|
||||
$ chef-solo -v
|
||||
...
|
||||
Chef: 11.4.0
|
||||
Chef: 14.5.33
|
||||
```
|
||||
|
||||
### Start the cookbook
|
||||
|
||||
```bash
|
||||
wget http://github.com/opscode/chef-repo/tarball/master -O - | tar xzf - --strip-components=1
|
||||
wget http://github.com/chef-cookbooks/chef-repo/tarball/master -O - | tar xzf - --strip-components=1
|
||||
```
|
||||
|
||||
### Knife
|
||||
|
||||
```bash
|
||||
$ knife cookbook site download mysql
|
||||
$ knife supermarket download mysql
|
||||
```
|
||||
|
||||
### Invoking chef-solo
|
||||
@ -105,5 +104,5 @@ end
|
||||
|
||||
## Also see
|
||||
|
||||
* [Getting started with Chef](http://gettingstartedwithchef.com/) _(gettingstartedwithchef.com)_
|
||||
* [Learn Chef Rally](https://learn.chef.io) _(learn.chef.io)_
|
||||
* [install_from_source.rb recipe](https://github.com/mdxp/nodejs-cookbook/blob/master/recipes/install_from_source.rb) _(github.com)_
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: Chunky PNG
|
||||
category: Ruby libraries
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### Loading
|
||||
|
1
cidr.md
1
cidr.md
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: CIDR
|
||||
category: Misc
|
||||
layout: 2017/sheet
|
||||
updated: 2018-05-14
|
||||
---
|
||||
|
||||
|
12
circle.md
12
circle.md
@ -1,8 +1,14 @@
|
||||
---
|
||||
title: CircleCI
|
||||
category: Devops
|
||||
---
|
||||
|
||||
## circle.yml
|
||||
### About
|
||||
{: .-intro}
|
||||
|
||||
- <https://circleci.com/docs/config-sample>
|
||||
|
||||
### circle.yml
|
||||
|
||||
* __machine__: adjusting the VM to your preferences and requirements
|
||||
* __checkout__: checking out and cloning your git repo
|
||||
@ -13,7 +19,7 @@ title: CircleCI
|
||||
|
||||
See: <https://circleci.com/docs/configuration>
|
||||
|
||||
## Sample
|
||||
### Sample
|
||||
|
||||
```yml
|
||||
## Customize the test machine
|
||||
@ -90,5 +96,3 @@ notify:
|
||||
# A list of hashes representing hooks. Only the url field is supported.
|
||||
- url: https://someurl.com/hooks/circle
|
||||
```
|
||||
|
||||
See: <https://circleci.com/docs/config-sample>
|
||||
|
383
claude-code.md
Normal file
383
claude-code.md
Normal file
@ -0,0 +1,383 @@
|
||||
---
|
||||
title: Claude Code
|
||||
category: AI
|
||||
tags: [Featured]
|
||||
updated: 2025-01-08
|
||||
keywords:
|
||||
- AI assistant
|
||||
- CLI
|
||||
- Code generation
|
||||
- File operations
|
||||
- Interactive mode
|
||||
- Memory management
|
||||
---
|
||||
|
||||
## Getting started
|
||||
{: .-three-column}
|
||||
|
||||
### Introduction
|
||||
{: .-intro}
|
||||
|
||||
[Claude Code](https://claude.ai/code) is an AI-powered CLI assistant for software engineering tasks. This reference covers the most commonly used commands and features.
|
||||
|
||||
- [Claude Code docs](https://docs.anthropic.com/en/docs/claude-code) _(docs.anthropic.com)_
|
||||
- [GitHub repository](https://github.com/anthropics/claude-code) _(github.com)_
|
||||
|
||||
### Installation & Setup
|
||||
|
||||
```bash
|
||||
# Install Claude Code
|
||||
npm install -g @anthropics/claude-code
|
||||
|
||||
# Login with API key
|
||||
claude auth login
|
||||
|
||||
# Check authentication status
|
||||
claude auth status
|
||||
```
|
||||
|
||||
### Quick Start
|
||||
|
||||
```bash
|
||||
# Start interactive session
|
||||
claude
|
||||
|
||||
# Run a single command
|
||||
claude "help me write a Python function"
|
||||
|
||||
# Resume previous session
|
||||
claude --resume
|
||||
```
|
||||
|
||||
## Core Commands
|
||||
{: .-three-column}
|
||||
|
||||
### Interactive Mode
|
||||
{: .-prime}
|
||||
|
||||
| Command | Description |
|
||||
| -------------------------- | ---------------------------------- |
|
||||
| `claude` | Start interactive session |
|
||||
| `claude --resume` | Resume last session |
|
||||
| `claude --memory` | Start with memory enabled |
|
||||
| `/help` | Show help and available commands |
|
||||
| `/clear` | Clear current conversation |
|
||||
| `/exit` | Exit interactive mode |
|
||||
{: .-shortcuts}
|
||||
|
||||
### File Operations
|
||||
|
||||
| Command | Description |
|
||||
| -------------------------- | ---------------------------------- |
|
||||
| `claude "read file.py"` | Read and analyze a file |
|
||||
| `claude "edit file.py"` | Edit an existing file |
|
||||
| `claude "create file.py"` | Create a new file |
|
||||
| `claude "fix tests"` | Fix failing tests |
|
||||
| `claude "refactor code"` | Refactor existing code |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Git Integration
|
||||
|
||||
| Command | Description |
|
||||
| ------------------------------- | ---------------------------------- |
|
||||
| `claude "create commit"` | Create git commit with message |
|
||||
| `claude "create PR"` | Create pull request |
|
||||
| `claude "review changes"` | Review git changes |
|
||||
| `claude "fix merge conflicts"` | Help resolve merge conflicts |
|
||||
{: .-shortcuts}
|
||||
|
||||
## Advanced Features
|
||||
{: .-three-column}
|
||||
|
||||
### Memory Management
|
||||
|
||||
```bash
|
||||
# Enable memory for current session
|
||||
claude --memory
|
||||
|
||||
# View memory contents
|
||||
claude "show memory"
|
||||
|
||||
# Clear memory
|
||||
claude "clear memory"
|
||||
```
|
||||
|
||||
### Extended Thinking
|
||||
|
||||
```bash
|
||||
# Enable deeper analysis
|
||||
claude --think
|
||||
|
||||
# Complex problem solving
|
||||
claude "analyze this codebase and suggest improvements"
|
||||
```
|
||||
|
||||
### Image Analysis
|
||||
|
||||
```bash
|
||||
# Analyze screenshot or diagram
|
||||
claude "analyze this screenshot" --image path/to/image.png
|
||||
|
||||
# Paste image from clipboard
|
||||
claude "explain this diagram" # then paste image
|
||||
```
|
||||
|
||||
## Slash Commands
|
||||
{: .-three-column}
|
||||
|
||||
### Session Management
|
||||
|
||||
| Command | Description |
|
||||
| ------------ | ------------------------------------ |
|
||||
| `/help` | Show available commands |
|
||||
| `/clear` | Clear conversation history |
|
||||
| `/reset` | Reset conversation state |
|
||||
| `/exit` | Exit interactive mode |
|
||||
| `/version` | Show Claude Code version |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Settings
|
||||
|
||||
| Command | Description |
|
||||
| -------------- | ---------------------------------- |
|
||||
| `/settings` | Show current settings |
|
||||
| `/model` | Change AI model |
|
||||
| `/memory on` | Enable memory |
|
||||
| `/memory off` | Disable memory |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Productivity
|
||||
|
||||
| Command | Description |
|
||||
| -------------- | ---------------------------------- |
|
||||
| `/save` | Save conversation |
|
||||
| `/load` | Load previous conversation |
|
||||
| `/export` | Export conversation to file |
|
||||
{: .-shortcuts}
|
||||
|
||||
## Common Workflows
|
||||
{: .-three-column}
|
||||
|
||||
### Code Review
|
||||
|
||||
```bash
|
||||
# Review specific file
|
||||
claude "review this code for bugs" file.py
|
||||
|
||||
# Review all changes
|
||||
claude "review my git changes"
|
||||
|
||||
# Check code quality
|
||||
claude "suggest improvements" src/
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Generate tests
|
||||
claude "write tests for this function"
|
||||
|
||||
# Fix failing tests
|
||||
claude "fix these test failures"
|
||||
|
||||
# Test coverage analysis
|
||||
claude "analyze test coverage"
|
||||
```
|
||||
|
||||
### Documentation
|
||||
|
||||
```bash
|
||||
# Generate README
|
||||
claude "create README for this project"
|
||||
|
||||
# Add code comments
|
||||
claude "add documentation to this function"
|
||||
|
||||
# API documentation
|
||||
claude "generate API docs"
|
||||
```
|
||||
|
||||
### Debugging
|
||||
|
||||
```bash
|
||||
# Debug error
|
||||
claude "help debug this error: [error message]"
|
||||
|
||||
# Performance analysis
|
||||
claude "why is this code slow?"
|
||||
|
||||
# Code explanation
|
||||
claude "explain how this works" complex_function.py
|
||||
```
|
||||
|
||||
## IDE Integrations
|
||||
{: .-three-column}
|
||||
|
||||
### VS Code
|
||||
|
||||
```bash
|
||||
# Install VS Code extension
|
||||
code --install-extension anthropic.claude-code
|
||||
|
||||
# Open in VS Code
|
||||
claude --vscode
|
||||
|
||||
# VS Code commands
|
||||
Ctrl+Shift+P -> "Claude: Ask"
|
||||
Ctrl+Shift+P -> "Claude: Review"
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
```bash
|
||||
# Set default editor
|
||||
claude config set editor code
|
||||
|
||||
# Set working directory
|
||||
claude config set workdir /path/to/project
|
||||
|
||||
# View all settings
|
||||
claude config list
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
{: .-three-column}
|
||||
|
||||
### Effective Prompting
|
||||
|
||||
```bash
|
||||
# Be specific about requirements
|
||||
claude "write a Python function that validates email addresses with regex"
|
||||
|
||||
# Provide context
|
||||
claude "in this Django project, add user authentication"
|
||||
|
||||
# Ask for explanations
|
||||
claude "explain this code and suggest improvements"
|
||||
```
|
||||
|
||||
### Project Structure
|
||||
|
||||
```bash
|
||||
# Analyze entire project
|
||||
claude "analyze project structure and suggest improvements"
|
||||
|
||||
# Focus on specific areas
|
||||
claude "review the database models in models.py"
|
||||
|
||||
# Architecture decisions
|
||||
claude "should I use async here?"
|
||||
```
|
||||
|
||||
### Security
|
||||
|
||||
```bash
|
||||
# Security review
|
||||
claude "check this code for security vulnerabilities"
|
||||
|
||||
# Best practices
|
||||
claude "make this code more secure"
|
||||
|
||||
# Audit dependencies
|
||||
claude "review package.json for security issues"
|
||||
```
|
||||
|
||||
## CLI Options
|
||||
{: .-three-column}
|
||||
|
||||
### Global Options
|
||||
|
||||
| Option | Description |
|
||||
| ------------------- | ---------------------------------- |
|
||||
| `--help` | Show help information |
|
||||
| `--version` | Show version number |
|
||||
| `--resume` | Resume previous session |
|
||||
| `--memory` | Enable memory |
|
||||
| `--think` | Enable extended thinking |
|
||||
| `--no-color` | Disable colored output |
|
||||
| `--verbose` | Verbose logging |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Authentication
|
||||
|
||||
| Command | Description |
|
||||
| -------------------- | ---------------------------------- |
|
||||
| `claude auth login` | Login with API key |
|
||||
| `claude auth logout` | Logout current session |
|
||||
| `claude auth status` | Check authentication status |
|
||||
| `claude auth whoami` | Show current user info |
|
||||
{: .-shortcuts}
|
||||
|
||||
### Configuration
|
||||
|
||||
| Command | Description |
|
||||
| ---------------------- | -------------------------------- |
|
||||
| `claude config set` | Set configuration value |
|
||||
| `claude config get` | Get configuration value |
|
||||
| `claude config list` | List all configuration |
|
||||
| `claude config reset` | Reset to default configuration |
|
||||
{: .-shortcuts}
|
||||
|
||||
## Troubleshooting
|
||||
{: .-three-column}
|
||||
|
||||
### Common Issues
|
||||
|
||||
```bash
|
||||
# Clear authentication
|
||||
claude auth logout && claude auth login
|
||||
|
||||
# Reset configuration
|
||||
claude config reset
|
||||
|
||||
# Clear cache
|
||||
claude --clear-cache
|
||||
|
||||
# Debug mode
|
||||
claude --verbose --debug
|
||||
```
|
||||
|
||||
### Network Issues
|
||||
|
||||
```bash
|
||||
# Check connectivity
|
||||
claude "test connection"
|
||||
|
||||
# Use proxy
|
||||
claude --proxy http://proxy:8080
|
||||
|
||||
# Timeout settings
|
||||
claude config set timeout 30
|
||||
```
|
||||
|
||||
### Memory Issues
|
||||
|
||||
```bash
|
||||
# Clear memory
|
||||
claude "clear memory"
|
||||
|
||||
# Disable memory
|
||||
claude --no-memory
|
||||
|
||||
# Memory usage
|
||||
claude "show memory usage"
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Description |
|
||||
| --------------------- | ---------------------------------- |
|
||||
| `CLAUDE_API_KEY` | API key for authentication |
|
||||
| `CLAUDE_MODEL` | Default model to use |
|
||||
| `CLAUDE_MEMORY` | Enable memory by default |
|
||||
| `CLAUDE_EDITOR` | Default text editor |
|
||||
| `CLAUDE_WORKDIR` | Default working directory |
|
||||
| `NO_COLOR` | Disable colored output |
|
||||
|
||||
## Also see
|
||||
{: .-one-column}
|
||||
|
||||
- [Claude Code documentation](https://docs.anthropic.com/en/docs/claude-code) _(docs.anthropic.com)_
|
||||
- [GitHub repository](https://github.com/anthropics/claude-code) _(github.com)_
|
||||
- [Claude API docs](https://docs.anthropic.com/en/api) _(docs.anthropic.com)_
|
||||
- [Community discussions](https://github.com/anthropics/claude-code/discussions) _(github.com)_
|
43
clip.md
Normal file
43
clip.md
Normal file
@ -0,0 +1,43 @@
|
||||
---
|
||||
title: Command Line Interface Pages
|
||||
category: CLI
|
||||
updated: 2023-02-23
|
||||
keywords:
|
||||
- CLI
|
||||
---
|
||||
|
||||
### Page layout
|
||||
|
||||
```md
|
||||
# command
|
||||
|
||||
> Some command description
|
||||
> More information: https://some/link/to/url
|
||||
|
||||
- Some code description:
|
||||
|
||||
`command argument1 argument2`
|
||||
```
|
||||
|
||||
### [Primitive placeholders](https://github.com/command-line-interface-pages/syntax/blob/main/type-specific/cli.md#primitive-placeholders)
|
||||
|
||||
```md
|
||||
- Delay in [s]econds:
|
||||
|
||||
`sleep {int seconds: 2}s`
|
||||
```
|
||||
|
||||
### [Primitive repeated placeholders](https://github.com/command-line-interface-pages/syntax/blob/main/type-specific/cli.md#repeated-primitive-placeholders)
|
||||
|
||||
```md
|
||||
- [c]reate an archive and write it to a [f]ile:
|
||||
|
||||
`tar {option mode: --create, -c} {option: --file, -f} {/?file archive: target.tar} {/?path+ input}`
|
||||
```
|
||||
|
||||
### Also see
|
||||
{: .-one-column}
|
||||
|
||||
* [Render](https://github.com/command-line-interface-pages/v2-tooling/tree/main/clip-view)
|
||||
* [Page's repository](https://github.com/command-line-interface-pages/cli-pages)
|
||||
* [Syntax](https://github.com/command-line-interface-pages/syntax/blob/main/base.md)
|
1
co.md
1
co.md
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: co
|
||||
category: JavaScript libraries
|
||||
layout: 2017/sheet
|
||||
updated: 2017-10-27
|
||||
weight: -1
|
||||
intro: |
|
||||
|
@ -3,6 +3,9 @@ title: Command line stuff
|
||||
---
|
||||
|
||||
## List (ls)
|
||||
{: .-three-column}
|
||||
|
||||
### Usage
|
||||
|
||||
ls [options] [paths]
|
||||
|
||||
@ -18,14 +21,12 @@ title: Command line stuff
|
||||
|---
|
||||
| `-F` | Add / after directories |
|
||||
| `-G` | Color |
|
||||
{:.shortcuts}
|
||||
|
||||
### Options
|
||||
|
||||
| `-R` | Recurse |
|
||||
| `-a` | Include hidden (dotfiles) |
|
||||
| `-A` | Include hidden (but not . and ..) |
|
||||
{:.shortcuts}
|
||||
|
||||
### Sorting
|
||||
|
||||
@ -39,11 +40,11 @@ title: Command line stuff
|
||||
| `-c` | sort by time status was changed |
|
||||
|---
|
||||
| `-h` | Human-readable size (3k) |
|
||||
{:.shortcuts}
|
||||
|
||||
<br>
|
||||
|
||||
## Tail
|
||||
{: .-three-column}
|
||||
|
||||
### Usage
|
||||
|
||||
tail [-F | -f | -r] [-bN | -cN | -nN] [file ...]
|
||||
|
||||
@ -52,7 +53,6 @@ title: Command line stuff
|
||||
| `-f` | follow |
|
||||
| `-F` | follow by filename (accounts for log rotation) |
|
||||
| `-r` | Reverse order |
|
||||
{:.shortcuts}
|
||||
|
||||
### Options
|
||||
|
||||
@ -60,11 +60,13 @@ title: Command line stuff
|
||||
| `-cN` | N bytes |
|
||||
| `-nN` | N lines |
|
||||
| `+N` | Start from line N |
|
||||
{:.shortcuts}
|
||||
|
||||
<br>
|
||||
|
||||
## Sudo
|
||||
{: .-three-column}
|
||||
|
||||
### Usage
|
||||
|
||||
```
|
||||
sudo [options] <command>
|
||||
@ -73,7 +75,6 @@ sudo [options] <command>
|
||||
### Listing
|
||||
|
||||
| `-l` | List allowed commands |
|
||||
{:.shortcuts}
|
||||
|
||||
### Options
|
||||
|
||||
@ -84,17 +85,14 @@ sudo [options] <command>
|
||||
| `-n` | Don't prompt for password |
|
||||
| `-P` | Preserve group vector |
|
||||
| `-S` | Read password from stdin |
|
||||
{:.shortcuts}
|
||||
|
||||
### File descriptors
|
||||
|
||||
| `-C fd` | Close all open file descriptors |
|
||||
{:.shortcuts}
|
||||
|
||||
### Prompt
|
||||
|
||||
| `-p prompt` | Custom prompt (-p "%p password:") |
|
||||
{:.shortcuts}
|
||||
|
||||
### Interactive
|
||||
|
||||
@ -105,38 +103,33 @@ sudo [options] <command>
|
||||
|----
|
||||
| `-u user` | run as this user |
|
||||
| `-g group` | run as this group |
|
||||
{:.shortcuts}
|
||||
|
||||
### Timestamp
|
||||
|
||||
| `-v` | revalidate timestamp for 5 mins |
|
||||
| `-k` | invalidate timestamp |
|
||||
| `-K` | just like -k |
|
||||
{:.shortcuts}
|
||||
|
||||
<br>
|
||||
|
||||
## wc (Word count)
|
||||
{: .-three-column}
|
||||
|
||||
### wc
|
||||
|
||||
```
|
||||
... | wc [options]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
| `-c` | Bytes |
|
||||
| `-l` | Lines |
|
||||
| `-m` | Characters (incl multi-byte) |
|
||||
| `-w` | Words |
|
||||
{:.shortcuts}
|
||||
|
||||
<br>
|
||||
|
||||
## Search-and-replace in all files
|
||||
|
||||
perl -p -i -e 's/hello/HELLO/g' **/*
|
||||
|
||||
<br>
|
||||
|
||||
## Grep
|
||||
{: .-three-column}
|
||||
|
||||
### Usage
|
||||
|
||||
```
|
||||
grep [options] [pattern] [file ...]
|
||||
@ -164,9 +157,15 @@ grep [options] [pattern] [file ...]
|
||||
| `-r, -R` | --recursive |
|
||||
| `-v` | --invert-match |
|
||||
| `-i` | --ignore-case |
|
||||
{:.shortcuts}
|
||||
|
||||
### Synonyms
|
||||
|
||||
egrep => grep -E
|
||||
fgrep => grep -F
|
||||
|
||||
## Other recipes
|
||||
{: .-three-column}
|
||||
|
||||
### Search-and-replace in all files
|
||||
|
||||
perl -p -i -e 's/hello/HELLO/g' **/*
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
title: Commander.js
|
||||
category: Hidden
|
||||
redirect_to: /commander.js
|
||||
---
|
@ -3,6 +3,11 @@ title: Commander.js
|
||||
category: JavaScript libraries
|
||||
---
|
||||
|
||||
### About
|
||||
{: .-intro}
|
||||
|
||||
- <https://github.com/tj/commander.js/>
|
||||
|
||||
### Initialize
|
||||
|
||||
var cli = require('commander');
|
||||
|
79
composer.md
79
composer.md
@ -1,49 +1,84 @@
|
||||
---
|
||||
title: composer
|
||||
category: CLI
|
||||
layout: 2017/sheet
|
||||
weight: -1
|
||||
authors:
|
||||
- github: benolot
|
||||
updated: 2018-03-06
|
||||
updated: 2020-02-23
|
||||
description: |
|
||||
Basic guide on how to use Composer, the PHP Package manager.
|
||||
---
|
||||
|
||||
All composer commands, depending on your install, may need to use `php composer.phar` in the install folder for composer, instead of plain `composer`.
|
||||
|
||||
### Package management
|
||||
All composer commands, depending on your install, may need to use `php composer.phar` in the install folder for composer, instead of global/plain `composer`.
|
||||
|
||||
### Installing dependencies
|
||||
|
||||
| Command | Description |
|
||||
| --- | --- |
|
||||
| `composer install` | Install everything in composer.json |
|
||||
| `composer install` | Downloads and installs all the libraries and dependencies outlined in the `composer.lock` file. If the file does not exist it will look for composer.json and do the same, creating a `composer.lock` file. |
|
||||
| --- | --- |
|
||||
| `composer install laravel` | Install a package |
|
||||
| `composer install laravel --dry-run` | Simulates the install without installing anything |
|
||||
| `composer install laravel --no-scripts`| Skips post-download scripts |
|
||||
| `composer install --dry-run` | Simulates the install without installing anything |
|
||||
|
||||
### Updating
|
||||
This command doesn't change any file. If `composer.lock` is not present, it will create it.
|
||||
|
||||
| Command | Description |
|
||||
| --- | --- |
|
||||
| `composer update` | Update all packages |
|
||||
| --- | --- |
|
||||
| `composer update laravel` | Update a certain package |
|
||||
| `composer update vendor/*`| Update all packages in a folder |
|
||||
| `composer update --lock` | Update lock file hash without updating any packages |
|
||||
`composer.lock` **should always** be committed to the repository. It has all the information needed to bring the
|
||||
local dependencies to the last committed state. If that file is modified on the repository, you will need to run
|
||||
`composer install` again after fetching the changes to update your local dependencies to those on that file.
|
||||
|
||||
### Updating packages
|
||||
|
||||
| Command | Description |
|
||||
| --- | --- |
|
||||
| `composer update` | Updates all packages |
|
||||
| `composer update --with-dependencies` | Updates all packages and its dependencies |
|
||||
| --- | --- |
|
||||
| `composer update vendor/package` | Updates a certain `package` from `vendor` |
|
||||
| `composer update vendor/*` | Updates all packages from `vendor` |
|
||||
| `composer update --lock` | Updates `composer.lock` hash without updating any packages |
|
||||
|
||||
### Requiring
|
||||
This command changes only the `composer.lock` file.
|
||||
|
||||
### Updating autoloader
|
||||
|
||||
| Command | Description |
|
||||
| --- | --- |
|
||||
| `composer dumpautoload -o` | Generates optimized autoload files |
|
||||
|
||||
### Adding packages
|
||||
|
||||
| Command | Description |
|
||||
| --- | --- |
|
||||
| `composer require laravel`. | Add new package to composer.json and install it |
|
||||
| `composer require vendor/package` | Adds `package` from `vendor` to composer.json's `require` section and installs it |
|
||||
| --- | --- |
|
||||
| `composer require laravel --dev` | Add new package to `require-dev` and install it. |
|
||||
| `composer require vendor/package --dev` | Adds `package` from `vendor` to composer.json's `require-dev` section and installs it. |
|
||||
|
||||
### Removing
|
||||
This command changes both the `composer.json` and `composer.lock` files.
|
||||
|
||||
### Passing versions
|
||||
|
||||
| Command | Description |
|
||||
| ----------------------------------------------- | ---------------------------------------- |
|
||||
| `composer require vendor/pkg "1.3.2"` | Installs `1.3.2` |
|
||||
| `composer require vendor/pkg ">=1.3.2"` | Above or equal `1.3.2` |
|
||||
| `composer require vendor/pkg "<1.3.2"` | Below `1.3.2` |
|
||||
| `composer require vendor/pkg "1.3.*"` | Latest of `>=1.3.0 <1.4.0` |
|
||||
| `composer require vendor/pkg "~1.3.2"` | Latest of `>=1.3.2 <1.4.0` |
|
||||
| `composer require vendor/pkg "~1.3"` | Latest of `>=1.3.0 <2.0.0` |
|
||||
| `composer require vendor/pkg "^1.3.2"` | Latest of `>=1.3.2 <2.0.0` |
|
||||
| `composer require vendor/pkg "^1.3"` | Latest of `>=1.3.0 <2.0.0` |
|
||||
| `composer require vendor/pkg "^0.3.2"` | Latest of `>=0.3.0 <0.4.0` (for pre-1.0) |
|
||||
| `composer require vendor/pkg "dev-BRANCH_NAME"` | From the branch `BRANCH_NAME` |
|
||||
|
||||
### Removing packages
|
||||
|
||||
| Command | Description |
|
||||
| --- | --- |
|
||||
| `composer remove laravel` | Remove new package from composer.json and uninstall it |
|
||||
| `composer remove vendor/package` | Removes `vendor/package` from composer.json and uninstalls it |
|
||||
|
||||
This command changes both the `composer.json` and `composer.lock` files.
|
||||
|
||||
### Verifying
|
||||
|
||||
| Command | Description |
|
||||
| ---------------------------- | -------------------------------------------------------------------------- |
|
||||
| `composer outdated --direct` | Show only packages that are outdated directly required by the root package |
|
||||
|
38
cordova.md
38
cordova.md
@ -1,25 +1,33 @@
|
||||
---
|
||||
title: Cordova
|
||||
title: Apache Cordova
|
||||
intro: |
|
||||
A quick reference to common [Apache Cordova](https://cordova.apache.org/) commands.
|
||||
---
|
||||
|
||||
cordova plugin ls
|
||||
cordova plugin search facebook
|
||||
cordova plugin add com.phonegap.plugins.facebookconnect
|
||||
### Common commands
|
||||
|
||||
cordova platform add ios
|
||||
cordova platform ls
|
||||
cordova platform update ios
|
||||
cordova platform check
|
||||
```
|
||||
cordova plugin ls
|
||||
cordova plugin search facebook
|
||||
cordova plugin add com.phonegap.plugins.facebookconnect
|
||||
```
|
||||
|
||||
### Some plugins
|
||||
```
|
||||
cordova platform add ios
|
||||
cordova platform ls
|
||||
cordova platform update ios
|
||||
cordova platform check
|
||||
```
|
||||
|
||||
You'll likely need these:
|
||||
### Common plugins
|
||||
|
||||
* [org.apache.cordova.console](https://github.com/apache/cordova-plugin-console)
|
||||
* [org.apache.cordova.inappbrowser](https://github.com/apache/cordova-plugin-inappbrowser)
|
||||
* [org.apache.cordova.statusbar](https://github.com/apache/cordova-plugin-statusbar)
|
||||
* org.apache.cordova.splashscreen
|
||||
Some commonly-used plugins:
|
||||
|
||||
- [org.apache.cordova.console](https://github.com/apache/cordova-plugin-console)
|
||||
- [org.apache.cordova.inappbrowser](https://github.com/apache/cordova-plugin-inappbrowser)
|
||||
- [org.apache.cordova.statusbar](https://github.com/apache/cordova-plugin-statusbar)
|
||||
- org.apache.cordova.splashscreen
|
||||
|
||||
Also:
|
||||
|
||||
* com.phonegap.plugins.facebookconnect
|
||||
- com.phonegap.plugins.facebookconnect
|
||||
|
53
cron.md
53
cron.md
@ -1,8 +1,7 @@
|
||||
---
|
||||
title: Cron
|
||||
category: CLI
|
||||
layout: 2017/sheet
|
||||
updated: 2017-08-26
|
||||
updated: 2024-03-17
|
||||
weight: -3
|
||||
---
|
||||
|
||||
@ -30,30 +29,50 @@ Min Hour Day Mon Weekday
|
||||
```
|
||||
{: .-setup.-box-chars}
|
||||
|
||||
### Operators
|
||||
|
||||
| Operator | Description |
|
||||
| --- | --- |
|
||||
| `*` | all values |
|
||||
| `,` | separate individual values |
|
||||
| `-` | a range of values |
|
||||
| `/` | divide a value into steps |
|
||||
|
||||
### Special strings
|
||||
|
||||
| String | Description |
|
||||
| --- | --- |
|
||||
| `@reboot` | every rebot |
|
||||
| `@hourly` | once every hour - same as `0 * * * *` |
|
||||
| `@daily` | once every day - same as `0 0 * * *` |
|
||||
| `@midnight` | once every midnight - same as `@daily` |
|
||||
| `@weekly` | once every week - same as `0 0 * * 0` |
|
||||
| `@monthly` | once every month - same as `0 0 1 * *` |
|
||||
| `@yearly` | once every year - same as `0 0 1 1 *` |
|
||||
|
||||
### Examples
|
||||
|
||||
| Example | Description |
|
||||
| --- | --- |
|
||||
| `0 * * * *` | every hour |
|
||||
| `*/15 * * * *` | every 15 mins |
|
||||
| `0 */2 * * *` | every 2 hours |
|
||||
| `0 0 * * 0` | every Sunday midnight |
|
||||
| --- | --- |
|
||||
| `@reboot` | every reboot |
|
||||
| Example | Description |
|
||||
| --- | --- |
|
||||
| `0 * * * *` | every hour |
|
||||
| `*/15 * * * *` | every 15 mins |
|
||||
| `0 */2 * * *` | every 2 hours |
|
||||
| `0 18 * * 0-6` | every week Mon-Sat at 6pm |
|
||||
| `10 2 * * 6,7` | every Sat and Sun on 2:10am |
|
||||
| `0 0 * * 0` | every Sunday midnight |
|
||||
|
||||
### Crontab
|
||||
|
||||
```bash
|
||||
# Adding tasks easily
|
||||
echo "@reboot echo hi" | crontab
|
||||
```
|
||||
|
||||
```bash
|
||||
# Open in editor
|
||||
crontab -e
|
||||
```
|
||||
# Open in editor - optional for another user
|
||||
crontab -e [-u user]
|
||||
|
||||
```bash
|
||||
# List tasks
|
||||
# List tasks - optional for another user
|
||||
crontab -l [-u user]
|
||||
|
||||
# Delete crontab file - optional for another user
|
||||
crontab -r [-u user]
|
||||
```
|
||||
|
@ -1,9 +0,0 @@
|
||||
---
|
||||
title: Cryptography
|
||||
---
|
||||
|
||||
* [PBKDF2](http://en.wikipedia.org/wiki/PBKDF2) - password-based key derivation
|
||||
function
|
||||
|
||||
* [HMAC](http://en.wikipedia.org/wiki/HMAC) - Hash-based message authentication
|
||||
code
|
194
csharp7.md
Normal file
194
csharp7.md
Normal file
@ -0,0 +1,194 @@
|
||||
---
|
||||
title: C# 7
|
||||
category: C-like
|
||||
updated: 2018-12-06
|
||||
prism_languages: [csharp]
|
||||
description: |
|
||||
A quick overview of C# 7
|
||||
---
|
||||
|
||||
### Out Variables
|
||||
|
||||
```csharp
|
||||
public void PrintCoordinates(Point p)
|
||||
{
|
||||
p.GetCoordinates(out int x, out int y);
|
||||
WriteLine($"({x}, {y})");
|
||||
}
|
||||
```
|
||||
|
||||
`out` is used to declare a variable at the point where it is passed as an argument.
|
||||
|
||||
### Pattern Matching
|
||||
|
||||
#### Is-expressions with patterns
|
||||
|
||||
```csharp
|
||||
public void PrintStars(object o)
|
||||
{
|
||||
if (o is null) return; // constant pattern "null"
|
||||
if (!(o is int i)) return; // type pattern "int i"
|
||||
WriteLine(new string('*', i));
|
||||
}
|
||||
```
|
||||
|
||||
#### Switch statements with patterns
|
||||
|
||||
```csharp
|
||||
switch(shape)
|
||||
{
|
||||
case Circle c:
|
||||
WriteLine($"circle with radius {c.Radius}");
|
||||
break;
|
||||
case Rectangle s when (s.Length == s.Height):
|
||||
WriteLine($"{s.Length} x {s.Height} square");
|
||||
break;
|
||||
case Rectangle r:
|
||||
WriteLine($"{r.Length} x {r.Height} rectangle");
|
||||
break;
|
||||
default:
|
||||
WriteLine("<unknown shape>");
|
||||
break;
|
||||
case null:
|
||||
throw new ArgumentNullException(nameof(shape));
|
||||
}
|
||||
```
|
||||
|
||||
### Tuples
|
||||
|
||||
#### Tuple type
|
||||
|
||||
```csharp
|
||||
(string, string, string) LookupName(long id) // tuple return type
|
||||
{
|
||||
... // retrieve first, middle and last from data storage
|
||||
return (first, middle, last); // tuple literal
|
||||
}
|
||||
```
|
||||
|
||||
```csharp
|
||||
var names = LookupName(id);
|
||||
WriteLine($"found {names.Item1} {names.Item3}.");
|
||||
```
|
||||
|
||||
#### Tuple elements with name
|
||||
|
||||
```csharp
|
||||
(string first, string middle, string last) LookupName(long id) // tuple elements have names
|
||||
```
|
||||
|
||||
```csharp
|
||||
var names = LookupName(id);
|
||||
WriteLine($"found {names.first} {names.last}.");
|
||||
```
|
||||
|
||||
#### Tuple Literals
|
||||
|
||||
```csharp
|
||||
return (first: first, middle: middle, last: last); // named tuple elements in a literal
|
||||
```
|
||||
|
||||
#### Tuple Deconstruction
|
||||
|
||||
```csharp
|
||||
(var first, var middle, var last) = LookupName(id1);
|
||||
WriteLine($"found {first} {last}.");
|
||||
```
|
||||
or
|
||||
```csharp
|
||||
var (first, middle, last) = LookupName(id1); // var outside
|
||||
```
|
||||
or
|
||||
```csharp
|
||||
(first, middle, last) = LookupName(id2); // assign onto existing variables
|
||||
```
|
||||
|
||||
|
||||
### Local Functions
|
||||
|
||||
```csharp
|
||||
public int Fibonacci(int x)
|
||||
{
|
||||
if (x < 0) throw new ArgumentException("Less negativity please!", nameof(x));
|
||||
return Fib(x).current;
|
||||
|
||||
(int current, int previous) Fib(int i)
|
||||
{
|
||||
if (i == 0) return (1, 0);
|
||||
var (p, pp) = Fib(i - 1);
|
||||
return (p + pp, p);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Literal Improvements
|
||||
|
||||
#### Digit Separator inside numbers literals
|
||||
|
||||
```csharp
|
||||
var d = 123_456;
|
||||
var x = 0xAB_CD_EF;
|
||||
```
|
||||
|
||||
#### Binary Literals
|
||||
|
||||
```csharp
|
||||
var b = 0b1010_1011_1100_1101_1110_1111;
|
||||
```
|
||||
|
||||
### Ref Returns and Locals
|
||||
|
||||
```csharp
|
||||
public ref int Find(int number, int[] numbers)
|
||||
{
|
||||
for (int i = 0; i < numbers.Length; i++)
|
||||
{
|
||||
if (numbers[i] == number)
|
||||
{
|
||||
return ref numbers[i]; // return the storage location, not the value
|
||||
}
|
||||
}
|
||||
throw new IndexOutOfRangeException($"{nameof(number)} not found");
|
||||
}
|
||||
|
||||
int[] array = { 1, 15, -39, 0, 7, 14, -12 };
|
||||
ref int place = ref Find(7, array); // aliases 7's place in the array
|
||||
place = 9; // replaces 7 with 9 in the array
|
||||
WriteLine(array[4]); // prints 9
|
||||
```
|
||||
|
||||
### More Expression Bodied Members
|
||||
|
||||
C# 7.0 adds accessors, constructors and finalizers to the list of things that can have expression bodies:
|
||||
|
||||
```csharp
|
||||
class Person
|
||||
{
|
||||
private static ConcurrentDictionary<int, string> names = new ConcurrentDictionary<int, string>();
|
||||
private int id = GetId();
|
||||
|
||||
public Person(string name) => names.TryAdd(id, name); // constructors
|
||||
~Person() => names.TryRemove(id, out *); // destructors
|
||||
public string Name
|
||||
{
|
||||
get => names[id]; // getters
|
||||
set => names[id] = value; // setters
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Throw Expressions
|
||||
|
||||
```csharp
|
||||
class Person
|
||||
{
|
||||
public string Name { get; }
|
||||
public Person(string name) => Name = name ?? throw new ArgumentNullException(name);
|
||||
public string GetFirstName()
|
||||
{
|
||||
var parts = Name.Split(" ");
|
||||
return (parts.Length > 0) ? parts[0] : throw new InvalidOperationException("No name!");
|
||||
}
|
||||
public string GetLastName() => throw new NotImplementedException();
|
||||
}
|
||||
```
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
title: CSS animations
|
||||
category: Hidden
|
||||
redirect_to: /css#animation
|
||||
---
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
title: CSS antialiasing
|
||||
category: CSS
|
||||
layout: 2017/sheet
|
||||
updated: 2017-08-26
|
||||
updated: 2017-10-13
|
||||
intro: |
|
||||
Here's a 4-line snippet on how to get beautiful, antialiased text with CSS.
|
||||
---
|
||||
|
@ -1,6 +0,0 @@
|
||||
---
|
||||
title: CSS background
|
||||
category: Hidden
|
||||
redirect_to: /css#background
|
||||
---
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
title: CSS flexbox
|
||||
category: CSS
|
||||
layout: 2017/sheet
|
||||
updated: 2017-08-29
|
||||
updated: 2020-06-13
|
||||
prism_languages: [css]
|
||||
weight: -3
|
||||
---
|
||||
@ -53,9 +52,12 @@ weight: -3
|
||||
```
|
||||
|
||||
```css
|
||||
justify-content: flex-start; /* horizontal alignment - default */
|
||||
justify-content: flex-end;
|
||||
justify-content: center;
|
||||
justify-content: flex-start; /* [xxx ] */
|
||||
justify-content: center; /* [ xxx ] */
|
||||
justify-content: flex-end; /* [ xxx] */
|
||||
justify-content: space-between; /* [x x x] */
|
||||
justify-content: space-around; /* [ x x x ] */
|
||||
justify-content: space-evenly; /* [ x x x ] */
|
||||
```
|
||||
|
||||
```css
|
||||
@ -191,4 +193,4 @@ Vertically-center all items.
|
||||
{: .-one-column}
|
||||
|
||||
* [MDN: Using CSS flexbox](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes)
|
||||
* [Ultimate flexbox cheatsheet](http://www.sketchingwithcss.com/samplechapter/cheatsheet.html)
|
||||
* [Ultimate flexbox cheatsheet](https://www.sketchingwithcss.com/samplechapter/cheatsheet.html)
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
title: CSS font
|
||||
category: Hidden
|
||||
redirect_to: /css#fonts
|
||||
---
|
255
css-grid.md
Normal file
255
css-grid.md
Normal file
@ -0,0 +1,255 @@
|
||||
---
|
||||
title: CSS Grid
|
||||
category: CSS
|
||||
updated: 2019-08-23
|
||||
prism_languages: [css]
|
||||
---
|
||||
|
||||
### Container
|
||||
|
||||
```css
|
||||
.grid-container {
|
||||
```
|
||||
{: .-setup}
|
||||
|
||||
```css
|
||||
/* Display properties */
|
||||
display: grid;
|
||||
display: inline-grid;
|
||||
```
|
||||
|
||||
```css
|
||||
/* Columns and rows */
|
||||
grid-template-columns: 1rem 2rem 1rem; /* Measurement units */
|
||||
grid-template-columns: 25% 50% 25%; /* Percentage units */
|
||||
grid-template-columns: 1rem auto 1rem 2fr; /* Fill remaining widths with auto or fr units */
|
||||
grid-template-columns: repeat(12, 1fr); /* Repeat columns without needing to write them */
|
||||
grid-template-columns: subgrid; /* Use column tracks defined on parent grid */
|
||||
|
||||
grid-template-rows: 1rem 10% auto repeat(5, 10px); /* Mix any group, same rules work for rows */
|
||||
grid-template-rows: subgrid; /* Use row tracks defined on parent grid */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Automatic columns and rows */
|
||||
|
||||
grid-auto-columns: 10px; /* No matter how many columns of content end up in the grid, each column will be this same width */
|
||||
grid-auto-rows: 1rem; /* No matter how many rows of content end up in the grid, each row will be this same height */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Areas */
|
||||
grid-template-areas:
|
||||
"header header"
|
||||
"main aside"
|
||||
"footer footer"; /* Grid-style */
|
||||
|
||||
grid-template-areas: "header header" "main aside" "footer footer"; /* Inline-style */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Template shorthand */
|
||||
grid-template:
|
||||
"header header" auto
|
||||
"main aside" 100vh
|
||||
"footer footer" 10rem
|
||||
/ 80% 20%;
|
||||
|
||||
/* The above is the same as below long-hand */
|
||||
grid-template-columns: 80% 20%;
|
||||
grid-template-rows: auto 100vh 10rem;
|
||||
grid-template-areas:
|
||||
"header header"
|
||||
"main aside"
|
||||
"footer footer";
|
||||
```
|
||||
|
||||
```css
|
||||
/* Gaps */
|
||||
grid-row-gap: 1rem;
|
||||
grid-column-gap: 0.5rem; /* Define values separately */
|
||||
|
||||
grid-gap: 1rem 0.5rem; /* Short-hand for row / column */
|
||||
grid-gap: 1rem; /* Gap in both dimensions */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Item justification (horizontal or column alignment) */
|
||||
justify-items: start; /* Align items to the left */
|
||||
justify-items: center; /* Align items centered within its column */
|
||||
justify-items: end; /* Align items to the right */
|
||||
justify-items: stretch; /* (default) Fills available area (horizontally) */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Item alignment (vertical or row alignment) */
|
||||
align-items: start; /* Align items to the top */
|
||||
align-items: center; /* Align items centered within its row */
|
||||
align-items: end; /* Align items to the bottom */
|
||||
align-items: stretch; /* (default) Fills available area (vertically) */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Place item shorthand */
|
||||
place-items: start stretch;
|
||||
|
||||
/* The above is the same as below long-hand */
|
||||
align-items: start;
|
||||
justify-items: stretch;
|
||||
```
|
||||
|
||||
```css
|
||||
/* Content justification (horizontal or column alignment) */
|
||||
justify-content: start; /* Align content to the left */
|
||||
justify-content: center; /* Align content centered horizontally within the grid */
|
||||
justify-content: end; /* Align content to the right */
|
||||
justify-content: stretch; /* (default) Fills available area (horizontally) */
|
||||
|
||||
justify-content: space-around; /* Chooses a space for both sides of the columns like a left and right margin */
|
||||
justify-content: space-between; /* Chooses a space to go between columns, no margins on outside of content */
|
||||
justify-content: space-evenly; /* Chooses a space that goes between all columns and edges consistently */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Content alignment (horizontal or column alignment) */
|
||||
align-content: start; /* Align content to the top */
|
||||
align-content: center; /* Align content centered vertically within the grid */
|
||||
align-content: end; /* Align content to the bottom */
|
||||
align-content: stretch; /* (default) Fills available area (vertically) */
|
||||
|
||||
align-content: space-around; /* Chooses a space for the top and bottom of the rows like a top and bottom margin */
|
||||
align-content: space-between; /* Chooses a space to go between rows, no margins on outside of content */
|
||||
align-content: space-evenly; /* Chooses a space that goes between all rows and edges consistently */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Place item shorthand */
|
||||
place-content: center start;
|
||||
|
||||
/* The above is the same as below long-hand */
|
||||
align-content: center;
|
||||
justify-content: start;
|
||||
```
|
||||
|
||||
```css
|
||||
/* Automatic grid positioning */
|
||||
|
||||
grid-auto-flow: row; /* Left-to-right rows, then top-to-bottom*/
|
||||
grid-auto-flow: column; /* Top-to-bottom columns, then left-to-right */
|
||||
grid-auto-flow: dense; /* Responds with best-guess on left-to-right, top-to-bottom order with advanced layouts */
|
||||
```
|
||||
|
||||
```css
|
||||
/* There is one final shorthand for all container properties in one */
|
||||
|
||||
/* Explicit grid columns, rows, and areas */
|
||||
grid:
|
||||
"header header" auto
|
||||
"main aside" 100vh
|
||||
"footer footer" 10rem
|
||||
/ 80% 20%; /* You can include a template as the only value, which is equivalent to below */
|
||||
grid-template:
|
||||
"header header" auto
|
||||
"main aside" 100vh
|
||||
"footer footer" 10rem
|
||||
/ 80% 20%; /* Which is again equivalent to below */
|
||||
grid-template-columns: 80% 20%;
|
||||
grid-template-rows: auto 100vh 10rem;
|
||||
grid-template-areas:
|
||||
"header header"
|
||||
"main aside"
|
||||
"footer footer";
|
||||
|
||||
/* Automatic grid flows */
|
||||
grid: 1rem / auto-flow dense 1fr; /* You can include rows, a flow, and automatic columns, which is equivalent to below */
|
||||
grid-template-rows: 1rem;
|
||||
grid-auto-flow: dense;
|
||||
grid-auto-columns: 1fr;
|
||||
|
||||
grid: auto-flow dense 1rem / repeat(10, 10%); /* Conversely, you can do the same thing with automatic rows, and defined columns */
|
||||
grid-auto-flow: dense;
|
||||
grid-auto-rows: 1rem;
|
||||
grid-template-columns: repeat(10, 10%);
|
||||
```
|
||||
|
||||
```css
|
||||
}
|
||||
```
|
||||
{: .-setup}
|
||||
|
||||
### Child
|
||||
|
||||
```css
|
||||
.grid-child {
|
||||
```
|
||||
{: .-setup}
|
||||
|
||||
```css
|
||||
/* Column position */
|
||||
grid-column-start: 1;
|
||||
grid-column-end: 2;
|
||||
|
||||
grid-column: 1 / 2; /* Short hand */
|
||||
grid-column: 1 / span 2; /* Span 2 columns without explicitly defining an endpoint */
|
||||
grid-column: 1; /* Start in and occupy a single column */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Row position */
|
||||
grid-row-start: 2;
|
||||
grid-row-end: 4;
|
||||
|
||||
grid-row: 2 / 4; /* Short hand */
|
||||
grid-row: 2 / span 3;/* Span 3 rows without explicitly defining an endpoint */
|
||||
grid-row: 1; /* Start in and occupy a single row */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Area positioning */
|
||||
grid-area: header; /* You can use a named grid area from the container */
|
||||
|
||||
grid-area: 2 / 1 / 4 / 2; /* Or you can use positioning. This is equivalent to... */
|
||||
grid-row-start: 2;
|
||||
grid-column-start: 1;
|
||||
grid-row-end: 4;
|
||||
grid-column-end: 2;
|
||||
```
|
||||
|
||||
```css
|
||||
/* Self justification (horizontal or column alignment) */
|
||||
justify-self: start; /* Align item to the left */
|
||||
justify-self: center; /* Align item centered within its column */
|
||||
justify-self: end; /* Align item to the right */
|
||||
justify-self: stretch; /* (default) Fills available area (horizontally) */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Self alignment (vertical or row alignment) */
|
||||
align-self: start; /* Align item to the top */
|
||||
align-self: center; /* Align item centered within its row */
|
||||
align-self: end; /* Align item to the bottom */
|
||||
align-self: stretch; /* (default) Fills available area (vertically) */
|
||||
```
|
||||
|
||||
```css
|
||||
/* Placement shorthand */
|
||||
place-self: start stretch;
|
||||
|
||||
/* The above is the same as below long-hand */
|
||||
align-self: start;
|
||||
justify-self: stretch;
|
||||
```
|
||||
|
||||
```css
|
||||
}
|
||||
```
|
||||
{: .-setup}
|
||||
|
||||
|
||||
## References
|
||||
{: .-one-column}
|
||||
|
||||
* [GRID: A simple visual cheatsheet](http://grid.malven.co/)
|
||||
* [CSS Tricks: A Complete Guide to Grid](https://css-tricks.com/snippets/css/complete-guide-grid/)
|
||||
* [Browser support](https://caniuse.com/#feat=css-grid)
|
||||
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
title: CSS selectors
|
||||
category: Hidden
|
||||
redirect_to: /css#selectors
|
||||
---
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: "CSS system fonts"
|
||||
category: CSS
|
||||
layout: 2017/sheet
|
||||
weight: -3
|
||||
tags: [Featurable]
|
||||
---
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: CSS tricks
|
||||
category: CSS
|
||||
layout: 2017/sheet
|
||||
---
|
||||
|
||||
### Heading kerning pairs and ligature
|
||||
|
66
css.md
66
css.md
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: CSS
|
||||
category: CSS
|
||||
layout: 2017/sheet
|
||||
weight: -1
|
||||
keywords:
|
||||
- "margin, padding, border"
|
||||
@ -24,13 +23,14 @@ keywords:
|
||||
```
|
||||
{: .-setup}
|
||||
|
||||
| Selector | Description |
|
||||
| ----------------- | ----------- |
|
||||
| `div` | Element |
|
||||
| `.class` | Class |
|
||||
| `#id` | ID |
|
||||
| `[disabled]` | Attribute |
|
||||
| `[role="dialog"]` | Attribute |
|
||||
| Selector | Description |
|
||||
| ----------------- | ------------ |
|
||||
| `*` | All elements |
|
||||
| `div` | Element |
|
||||
| `.class` | Class |
|
||||
| `#id` | ID |
|
||||
| `[disabled]` | Attribute |
|
||||
| `[role="dialog"]` | Attribute |
|
||||
|
||||
### Combinators
|
||||
|
||||
@ -40,34 +40,40 @@ keywords:
|
||||
| `.parent > .child` | Direct descendant |
|
||||
| `.child + .sibling` | Adjacent sibling |
|
||||
| `.child ~ .sibling` | Far sibling |
|
||||
| `.class1.class2` | Have both classes |
|
||||
|
||||
### Attribute selectors
|
||||
|
||||
| Selector | Description |
|
||||
| ----------------- | ----------------------------------- |
|
||||
| `[role="dialog"]` | `=` Exact |
|
||||
| `[class~="box"]` | `~=` Has word |
|
||||
| `[class|="box"]` | `|=` Exact or prefix (eg, `value-`) |
|
||||
| `[href$=".doc"]` | `$=` Ends in |
|
||||
| `[class*="-is-"]` | `*=` Contains |
|
||||
| Selector | Description |
|
||||
| ------------------ | ----------------------------------- |
|
||||
| `[role="dialog"]` | `=` Exact |
|
||||
| `[class~="box"]` | `~=` Has word |
|
||||
| `[class|="box"]` | `|=` Exact or prefix (eg, `value-`) |
|
||||
| `[href$=".doc"]` | `$=` Ends in |
|
||||
| `[href^="/index"]` | `^=` Begins with |
|
||||
| `[class*="-is-"]` | `*=` Contains |
|
||||
|
||||
### Pseudo-classes
|
||||
|
||||
| Selector | Description |
|
||||
| -------------------- | ------------------------ |
|
||||
| `:target` | eg, `h2#foo:target` |
|
||||
| --- | --- |
|
||||
| `:disabled` | |
|
||||
| `:focus` | |
|
||||
| `:active` | |
|
||||
| --- | --- |
|
||||
| `:nth-child(3)` | 3rd child |
|
||||
| `:nth-child(3n+2)` | 2nd child in groups of 3 |
|
||||
| `:nth-child(-n+4)` | |
|
||||
| --- | --- |
|
||||
| `:nth-last-child(2)` | |
|
||||
| `:nth-of-type(2)` | |
|
||||
| --- | --- |
|
||||
| Selector | Description |
|
||||
| -------------------- | ------------------------------------------ |
|
||||
| `:target` | eg, `h2#foo:target` |
|
||||
| --- | --- |
|
||||
| `:focus` | |
|
||||
| `:active` | |
|
||||
| --- | --- |
|
||||
| `:nth-child(3)` | 3rd child |
|
||||
| `:nth-child(3n+2)` | 2nd child in groups of 3 |
|
||||
| `:nth-child(-n+4)` | |
|
||||
| --- | --- |
|
||||
| `:nth-last-child(2)` | |
|
||||
| `:nth-of-type(2)` | |
|
||||
| --- | --- |
|
||||
| `:checked` | Checked inputs |
|
||||
| `:disabled` | Disabled elements |
|
||||
| `:default` | Default element in a group |
|
||||
| --- | --- |
|
||||
| `:empty` | Elements without children |
|
||||
|
||||
### Pseudo-class variations
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
title: cssnext
|
||||
category: CSS
|
||||
layout: 2017/sheet
|
||||
updated: 2017-08-30
|
||||
updated: 2017-10-30
|
||||
tags: [Featurable]
|
||||
weight: -3
|
||||
---
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user