mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 11:13:33 +01:00
Compare commits
680 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
417b5b4e42 | ||
|
|
9b92261604 | ||
|
|
ca1ec0e38d | ||
|
|
52403dbe4a | ||
|
|
5ad1a3c39f | ||
|
|
d4a8a79628 | ||
|
|
007c9f9efe | ||
|
|
f61203ac1b | ||
|
|
f1db4ee378 | ||
|
|
366d63afdc | ||
|
|
c1551683a3 | ||
|
|
09aad6f8ea | ||
|
|
adb5a43810 | ||
|
|
cab039a9d8 | ||
|
|
97e80beceb | ||
|
|
1969423b5c | ||
|
|
4497ce1b84 | ||
|
|
5eee02bc40 | ||
|
|
2d50c6a6eb | ||
|
|
6f919fd675 | ||
|
|
fd1465ee38 | ||
|
|
00ec2c130d | ||
|
|
8eafa5adfe | ||
|
|
b604027205 | ||
|
|
2a19755804 | ||
|
|
cc85a4bdb1 | ||
|
|
7908a678df | ||
|
|
7c0eacb53d | ||
|
|
4bf804ac60 | ||
|
|
33c5918087 | ||
|
|
d34177729d | ||
|
|
7fa50328d7 | ||
|
|
1790aec85d | ||
|
|
6bf51e758f | ||
|
|
242da8c89a | ||
|
|
2294f40ee0 | ||
|
|
fe25019b14 | ||
|
|
bfb071c0b2 | ||
|
|
95a4e31b6c | ||
|
|
0d9c92c8c0 | ||
|
|
16c50bb659 | ||
|
|
1a85c9e9c8 | ||
|
|
c9ccefa607 | ||
|
|
3a6b6e58f0 | ||
|
|
2edc0ee299 | ||
|
|
bd9fa1ba70 | ||
|
|
bb85e611f4 | ||
|
|
a2f538f114 | ||
|
|
80c91cbdee | ||
|
|
ede2d2dbaa | ||
|
|
db3d7e53a4 | ||
|
|
06c4ff52fc | ||
|
|
cbc2638d96 | ||
|
|
fd93da799d | ||
|
|
5c5ed7344f | ||
|
|
d773383f70 | ||
|
|
2717044b62 | ||
|
|
2d635293c5 | ||
|
|
f0bfeda47a | ||
|
|
f1540290a7 | ||
|
|
0b80a608c3 | ||
|
|
3c1e24a0e8 | ||
|
|
2a6586b41b | ||
|
|
6421953183 | ||
|
|
0c47f44ff9 | ||
|
|
77f9c3fdd0 | ||
|
|
b53a14b1a7 | ||
|
|
f1e8602369 | ||
|
|
ddbe710881 | ||
|
|
d598d96fce | ||
|
|
4fdec50487 | ||
|
|
9de866dfb6 | ||
|
|
eb99a070ce | ||
|
|
73f80bde48 | ||
|
|
8130b2f3bd | ||
|
|
f4e6c76e58 | ||
|
|
85f5ae8ec7 | ||
|
|
484b447391 | ||
|
|
cfd1702bc6 | ||
|
|
7406ebfb5e | ||
|
|
0737af2fec | ||
|
|
a23d372d1f | ||
|
|
fe66ff3768 | ||
|
|
7fed1f63a6 | ||
|
|
a297d1619c | ||
|
|
ef1da90a77 | ||
|
|
d8f405c112 | ||
|
|
f8403ff241 | ||
|
|
65f6be3fd8 | ||
|
|
1cb53697d2 | ||
|
|
14f321b0e6 | ||
|
|
d3250fda79 | ||
|
|
c482488c41 | ||
|
|
fe8f39013e | ||
|
|
1016b20ef2 | ||
|
|
def8985dcd | ||
|
|
e6f12147df | ||
|
|
a8c2c396ed | ||
|
|
35262df4f2 | ||
|
|
12ffa4cb5c | ||
|
|
d9c602f9e1 | ||
|
|
b67ff8b6a8 | ||
|
|
a500a621a1 | ||
|
|
23b6928874 | ||
|
|
9de39fb12b | ||
|
|
ad501c4cbe | ||
|
|
f17de401e5 | ||
|
|
2c097adeda | ||
|
|
b825e0f535 | ||
|
|
8385277b28 | ||
|
|
768d55e5d4 | ||
|
|
6aedc5c116 | ||
|
|
e881bb1f97 | ||
|
|
501f9c66ad | ||
|
|
a2aa82d9f3 | ||
|
|
018bce7ad5 | ||
|
|
17acefdd9b | ||
|
|
37918e09a4 | ||
|
|
86967873a8 | ||
|
|
d237d98c15 | ||
|
|
eb9b3e7798 | ||
|
|
b0a351033d | ||
|
|
1eb44e8809 | ||
|
|
55b18b4897 | ||
|
|
883a17092f | ||
|
|
4f2a57fce8 | ||
|
|
ecc96c64f9 | ||
|
|
a81dd96ff4 | ||
|
|
fb538baba5 | ||
|
|
1a7b5c6127 | ||
|
|
cdddfbb516 | ||
|
|
4ef4c35d8c | ||
|
|
a58294859e | ||
|
|
606092e288 | ||
|
|
233a9de1aa | ||
|
|
aa16f68620 | ||
|
|
367673d5d9 | ||
|
|
08fb9e11a9 | ||
|
|
3f4d4bddb2 | ||
|
|
6c6753b35c | ||
|
|
0718b606e1 | ||
|
|
857119b443 | ||
|
|
f421483eea | ||
|
|
4adddbf504 | ||
|
|
b9c86b6975 | ||
|
|
0b21ccf6f8 | ||
|
|
a3ad8c5101 | ||
|
|
bacb74929a | ||
|
|
82e1c27494 | ||
|
|
45beeb2edb | ||
|
|
c2c479b36c | ||
|
|
cb0243e7fc | ||
|
|
e5d04d41ea | ||
|
|
2474ea4fb1 | ||
|
|
7467c9fbc0 | ||
|
|
dfba3da003 | ||
|
|
ad7ad64a75 | ||
|
|
c4dcfd5da0 | ||
|
|
278a5d9154 | ||
|
|
9fa0c466fd | ||
|
|
4e9b2928b3 | ||
|
|
fa5eb44be8 | ||
|
|
49afd7c16b | ||
|
|
59d5c96c24 | ||
|
|
8e602b0e93 | ||
|
|
fb04cb1fcd | ||
|
|
d42726101e | ||
|
|
93b3a711f5 | ||
|
|
9c3d41c8bd | ||
|
|
4eeec6c868 | ||
|
|
1b17ab1914 | ||
|
|
477650ee44 | ||
|
|
c4dd3b52fd | ||
|
|
e8a0ea0dc3 | ||
|
|
992ee66a56 | ||
|
|
c9840c2d6f | ||
|
|
bd53768f67 | ||
|
|
8092687956 | ||
|
|
16ade50672 | ||
|
|
62c80d76eb | ||
|
|
3e67eaa3b7 | ||
|
|
38b13655fe | ||
|
|
749d5c1182 | ||
|
|
521f83377c | ||
|
|
b15ff10537 | ||
|
|
5288bd0c1c | ||
|
|
bddbee4158 | ||
|
|
ce27cf2cc0 | ||
|
|
5733b1d6d4 | ||
|
|
2d221050d8 | ||
|
|
ce37b670c7 | ||
|
|
47a9eeb4fd | ||
|
|
be56c9cf0c | ||
|
|
7be57cb01c | ||
|
|
8453af8601 | ||
|
|
6e388c3693 | ||
|
|
b13246978a | ||
|
|
a39d36cd34 | ||
|
|
87cba04ff2 | ||
|
|
bc623da74b | ||
|
|
a6c25d4b9c | ||
|
|
e24ac2b385 | ||
|
|
e0c35a74d4 | ||
|
|
3e4c1818a9 | ||
|
|
7b4a268ebd | ||
|
|
f7183aa17a | ||
|
|
1ce6c29e6a | ||
|
|
219db679e1 | ||
|
|
53177cb09d | ||
|
|
ef7a41f9a9 | ||
|
|
008316d030 | ||
|
|
a59c019642 | ||
|
|
57225442be | ||
|
|
2c7ce48859 | ||
|
|
a3fe4f40bb | ||
|
|
506fb8be15 | ||
|
|
408e944eea | ||
|
|
8a313b92ca | ||
|
|
6912771c39 | ||
|
|
d4c6200702 | ||
|
|
9251849d23 | ||
|
|
313b5ebd27 | ||
|
|
ca91b25b02 | ||
|
|
bbf6af50b1 | ||
|
|
9f05442bce | ||
|
|
3fc4c2f89e | ||
|
|
9e88ff2642 | ||
|
|
e3764b81e7 | ||
|
|
3786ac96a5 | ||
|
|
4cb7a3b42c | ||
|
|
ff6a866abe | ||
|
|
2e7ccb2a68 | ||
|
|
126231db1f | ||
|
|
91f0d02de2 | ||
|
|
815e714fb4 | ||
|
|
bd3986a051 | ||
|
|
f47b75edc0 | ||
|
|
180ee20f77 | ||
|
|
9b86c583f8 | ||
|
|
e1f7828869 | ||
|
|
7f3ae2ab30 | ||
|
|
bbd03a1bb8 | ||
|
|
326c54147b | ||
|
|
efcedaedec | ||
|
|
301cbefb0c | ||
|
|
9a481f7e75 | ||
|
|
e2920bd922 | ||
|
|
973a1f59ea | ||
|
|
3afea0972c | ||
|
|
f86633ca1c | ||
|
|
a01a3491a4 | ||
|
|
daa43d3867 | ||
|
|
e94a1e22df | ||
|
|
5046975a0f | ||
|
|
198156a299 | ||
|
|
a7067279df | ||
|
|
a8e6fdb18a | ||
|
|
bbfa4efdb7 | ||
|
|
741ad91389 | ||
|
|
573d43a7e6 | ||
|
|
879e8f2be4 | ||
|
|
eab3c14f1f | ||
|
|
9a6130b6b7 | ||
|
|
aeaf01e1de | ||
|
|
09c29a322f | ||
|
|
0525b2331b | ||
|
|
27a4991a3a | ||
|
|
4dda412dcb | ||
|
|
bfb60764ad | ||
|
|
3a97c680bb | ||
|
|
edc0fe41ef | ||
|
|
9e49bf8e9c | ||
|
|
50dc3c8b29 | ||
|
|
e08a4f3cec | ||
|
|
d6ebe0799d | ||
|
|
51aaaf3423 | ||
|
|
197ff58796 | ||
|
|
b8f512aae8 | ||
|
|
e7a1a296e3 | ||
|
|
f7c093bec0 | ||
|
|
c47b7f81aa | ||
|
|
52081b97ac | ||
|
|
1dda796e7c | ||
|
|
67469b0afa | ||
|
|
4f8431a600 | ||
|
|
5301442f7c | ||
|
|
cd45efcdec | ||
|
|
c31786fc5b | ||
|
|
934c36ad77 | ||
|
|
2c0099c28a | ||
|
|
33ac3d34d1 | ||
|
|
10af84dc10 | ||
|
|
8d532bcdee | ||
|
|
a13ad99241 | ||
|
|
1a8345f326 | ||
|
|
472e1f84f5 | ||
|
|
659e0a8eff | ||
|
|
d19f0e1c5d | ||
|
|
0f9861f825 | ||
|
|
36960fc164 | ||
|
|
749173f1f6 | ||
|
|
217566efc5 | ||
|
|
33e33dc7b7 | ||
|
|
201cd1d629 | ||
|
|
e5114a3e76 | ||
|
|
307c4e6ad6 | ||
|
|
1333703a49 | ||
|
|
184c200936 | ||
|
|
f1837b4c59 | ||
|
|
77d0f6d9a0 | ||
|
|
5b2518b3fe | ||
|
|
60bf61c82f | ||
|
|
b1dabec129 | ||
|
|
d10290541d | ||
|
|
12e8059025 | ||
|
|
ea07b6ad0e | ||
|
|
c50b236b80 | ||
|
|
42a39449b3 | ||
|
|
087a076f74 | ||
|
|
a15ea7fc3e | ||
|
|
f33e6cd602 | ||
|
|
95f648cc2d | ||
|
|
0db660347b | ||
|
|
432461a075 | ||
|
|
93df3b3f20 | ||
|
|
c548ded02d | ||
|
|
4c12d66546 | ||
|
|
6ce53370e7 | ||
|
|
bde74c701f | ||
|
|
fdc414ede3 | ||
|
|
5c23f374e4 | ||
|
|
c1fceb5f0d | ||
|
|
d0faf1a3e3 | ||
|
|
fdddedb8bd | ||
|
|
5487314676 | ||
|
|
ec360ccddd | ||
|
|
bb7dfd1028 | ||
|
|
b348724082 | ||
|
|
5053f07fd8 | ||
|
|
f692c8e1d8 | ||
|
|
89bb9aaf13 | ||
|
|
574deeabc0 | ||
|
|
482161f8e9 | ||
|
|
4dd55105d2 | ||
|
|
6148d64599 | ||
|
|
cde8bcaa1d | ||
|
|
fcb82778e4 | ||
|
|
da92421948 | ||
|
|
d6c7863573 | ||
|
|
5812bca6b7 | ||
|
|
074dba6e99 | ||
|
|
9d1dd15387 | ||
|
|
caf355f142 | ||
|
|
2728ce4757 | ||
|
|
6ae76799f7 | ||
|
|
0b523a769f | ||
|
|
f29cf03b68 | ||
|
|
4347114e19 | ||
|
|
edc67e7819 | ||
|
|
aa33a36491 | ||
|
|
8aac10dd8b | ||
|
|
9931b78c5f | ||
|
|
a37577ee85 | ||
|
|
3ad923eff0 | ||
|
|
ba47dc2cbc | ||
|
|
df21731c02 | ||
|
|
a657699a24 | ||
|
|
5793c1845a | ||
|
|
e2b5728283 | ||
|
|
d61e4e7c34 | ||
|
|
145a81dcd6 | ||
|
|
7c4fc54681 | ||
|
|
878d7e7e1b | ||
|
|
928637c9db | ||
|
|
ab87bb11c4 | ||
|
|
8f757d7735 | ||
|
|
c922ef4c8d | ||
|
|
574a7ec3c9 | ||
|
|
5ae49228b7 | ||
|
|
09acdf1a69 | ||
|
|
9ea60d12ff | ||
|
|
f7d747e101 | ||
|
|
3b207b4d51 | ||
|
|
5e1d3abce8 | ||
|
|
ad25e16dc6 | ||
|
|
92c07c0137 | ||
|
|
7e35263e90 | ||
|
|
1b6b5b79b7 | ||
|
|
b377984b59 | ||
|
|
e319332138 | ||
|
|
13c0ea7525 | ||
|
|
87448c49fa | ||
|
|
80b8cfc06b | ||
|
|
8a8f30679d | ||
|
|
4d19505b79 | ||
|
|
a2e028fd19 | ||
|
|
5eec6bf040 | ||
|
|
3a4c2a887d | ||
|
|
879a58b721 | ||
|
|
7814de96d2 | ||
|
|
a651426075 | ||
|
|
c4c935a6a5 | ||
|
|
df86142b8e | ||
|
|
60b05c8781 | ||
|
|
22b64d2d08 | ||
|
|
1224908445 | ||
|
|
28a2902e20 | ||
|
|
730c488854 | ||
|
|
ba9051e3cd | ||
|
|
7c7278ac8b | ||
|
|
e1fdca231e | ||
|
|
6b796adaf7 | ||
|
|
95843e4674 | ||
|
|
2b58300d84 | ||
|
|
bf1be86fb9 | ||
|
|
35c4a8d639 | ||
|
|
6910adae90 | ||
|
|
b47b4bc1d1 | ||
|
|
ea7e71b002 | ||
|
|
d576eef13b | ||
|
|
bec516b30a | ||
|
|
f0b3f8037b | ||
|
|
3938032595 | ||
|
|
f35cfa084e | ||
|
|
cdb22f310d | ||
|
|
6d1eff16a1 | ||
|
|
9241de04d6 | ||
|
|
8ac1851a69 | ||
|
|
cccf37c284 | ||
|
|
15f70c2cc3 | ||
|
|
cebe3de389 | ||
|
|
8ec51d3194 | ||
|
|
500dbbbd4a | ||
|
|
66ebae4ed5 | ||
|
|
5a83a22888 | ||
|
|
62a2bf3c2d | ||
|
|
4b6dc22c0a | ||
|
|
cd46559250 | ||
|
|
03fb44159a | ||
|
|
f0bd3ba4e6 | ||
|
|
72f8c88394 | ||
|
|
2fcc808e63 | ||
|
|
4aef22f457 | ||
|
|
146b671412 | ||
|
|
feab7a9706 | ||
|
|
a5b0132b08 | ||
|
|
ce1f4a099c | ||
|
|
0e84cae79e | ||
|
|
93180c3852 | ||
|
|
795bcaffcb | ||
|
|
d6f12c4397 | ||
|
|
8ccc8bd546 | ||
|
|
c29a3dfdc1 | ||
|
|
7e94f1e0ba | ||
|
|
ff1227bca8 | ||
|
|
b0aa272b49 | ||
|
|
130cf1d830 | ||
|
|
f93ca8f7ce | ||
|
|
c0fe871b33 | ||
|
|
b210fbca5f | ||
|
|
45c0dad364 | ||
|
|
544d11aebc | ||
|
|
51f7a42ece | ||
|
|
cd6826d5d4 | ||
|
|
c09f0b0c6c | ||
|
|
3fe72a03cc | ||
|
|
0c0d924df6 | ||
|
|
aa1e12625e | ||
|
|
d09353bfca | ||
|
|
81e80c87a1 | ||
|
|
3d498d5ce7 | ||
|
|
d90d509702 | ||
|
|
b46f5b2c34 | ||
|
|
e2d63e7603 | ||
|
|
67f52f8317 | ||
|
|
67134b9240 | ||
|
|
c67adb1422 | ||
|
|
c2aa5e0148 | ||
|
|
332f0bd4ee | ||
|
|
b303bc0028 | ||
|
|
02f79ddd13 | ||
|
|
9c53e2ba10 | ||
|
|
71680c6586 | ||
|
|
a240413eb9 | ||
|
|
cde64e3ea4 | ||
|
|
0b0bc441c6 | ||
|
|
2aa37432cb | ||
|
|
89de3705b0 | ||
|
|
d12718b8c4 | ||
|
|
900e083b99 | ||
|
|
d048ea5a10 | ||
|
|
837e0b5b71 | ||
|
|
30d2a77a6c | ||
|
|
1a8cdf84f4 | ||
|
|
181403e7ac | ||
|
|
2c10955690 | ||
|
|
4319b8e699 | ||
|
|
57dff86a44 | ||
|
|
761bf2eb2f | ||
|
|
aa4f6daf77 | ||
|
|
d7272c50c4 | ||
|
|
cdf573a725 | ||
|
|
eb6dfaad39 | ||
|
|
f8d2ce516e | ||
|
|
e5bf9146fe | ||
|
|
d6dc39c687 | ||
|
|
fb5ec798fa | ||
|
|
866eb68d64 | ||
|
|
e17f60e4d5 | ||
|
|
ed2ef113f0 | ||
|
|
432379d1e6 | ||
|
|
7089bef7cc | ||
|
|
aa57371819 | ||
|
|
921db35400 | ||
|
|
852db958a4 | ||
|
|
d58bbba1f8 | ||
|
|
e5ffcf65e4 | ||
|
|
d59ac66f1c | ||
|
|
f4f8592933 | ||
|
|
c540a600b2 | ||
|
|
9224216581 | ||
|
|
2da5c2b710 | ||
|
|
e468f8d0a0 | ||
|
|
cdee0e44cd | ||
|
|
efcd687070 | ||
|
|
ae309c7dc4 | ||
|
|
86ba22e7b8 | ||
|
|
2a6ec9cef5 | ||
|
|
2d59026b0d | ||
|
|
bcb0d71dd3 | ||
|
|
d1526ede16 | ||
|
|
374d381c00 | ||
|
|
1f3f9828c3 | ||
|
|
5d3f89924c | ||
|
|
74808845a5 | ||
|
|
517bf9599b | ||
|
|
7716827dfc | ||
|
|
c65fde1b3a | ||
|
|
bb3c4105cb | ||
|
|
edd7b5e806 | ||
|
|
7abb663bf4 | ||
|
|
f6f1233b12 | ||
|
|
b9241efab1 | ||
|
|
8019325f1e | ||
|
|
7209f2c929 | ||
|
|
068d117bef | ||
|
|
9ead66461d | ||
|
|
d00bd87dd1 | ||
|
|
dd8b20a17a | ||
|
|
84e42e7f2f | ||
|
|
a59e91ead7 | ||
|
|
f495a4dfd9 | ||
|
|
10dd0e9a8b | ||
|
|
d06e5bab6f | ||
|
|
aa9403d432 | ||
|
|
75b2555710 | ||
|
|
632da2024a | ||
|
|
1baa6d39c0 | ||
|
|
8cad76943a | ||
|
|
a6ec02c296 | ||
|
|
7392787e31 | ||
|
|
208dd24a0c | ||
|
|
df34774a7a | ||
|
|
8d65424ffb | ||
|
|
597acec6ac | ||
|
|
7d4150b937 | ||
|
|
5df5b1ab49 | ||
|
|
f1c8017342 | ||
|
|
8f2912e5da | ||
|
|
3139796524 | ||
|
|
bcd4563bf3 | ||
|
|
5cd5387a47 | ||
|
|
c8f0e6295b | ||
|
|
31e442d7f9 | ||
|
|
05400a92ed | ||
|
|
034c1a2415 | ||
|
|
dab8645394 | ||
|
|
352a760561 | ||
|
|
6be87e2d42 | ||
|
|
403d715127 | ||
|
|
0edd1450dc | ||
|
|
d87a26ce4f | ||
|
|
cdf240b70e | ||
|
|
809c6d77bc | ||
|
|
be543450c7 | ||
|
|
9889d77adb | ||
|
|
354376340f | ||
|
|
d82eee726c | ||
|
|
9a23458a2d | ||
|
|
32802c2907 | ||
|
|
2a6d34de35 | ||
|
|
f1253031f2 | ||
|
|
76fa9cfc23 | ||
|
|
0a54b2a2ff | ||
|
|
6a1742984c | ||
|
|
80d2a09456 | ||
|
|
5121fece91 | ||
|
|
e8d32102cb | ||
|
|
eff042d50b | ||
|
|
f000756f2c | ||
|
|
ef1dfb2168 | ||
|
|
3c1b5c5860 | ||
|
|
3494827403 | ||
|
|
f0879831c5 | ||
|
|
8c056d09e9 | ||
|
|
dd8d0ae58b | ||
|
|
6cc99a2b6a | ||
|
|
70ad22c12e | ||
|
|
b28e6a84ac | ||
|
|
bf4f1c80ca | ||
|
|
9cf1a5761d | ||
|
|
13fdcec332 | ||
|
|
b2feeab4e8 | ||
|
|
c4b7fd507f | ||
|
|
b77aa0974b | ||
|
|
3be95142ed | ||
|
|
bb324e94a4 | ||
|
|
7084ce2f45 | ||
|
|
905006f09c | ||
|
|
06a368fb1f | ||
|
|
6a9422502a | ||
|
|
41332f1d8a | ||
|
|
b6d54b135c | ||
|
|
a3c682729e | ||
|
|
f38da23741 | ||
|
|
20d985d993 | ||
|
|
09f821835c | ||
|
|
7e5e4315e5 | ||
|
|
869e7095f3 | ||
|
|
6dd8faf26a | ||
|
|
c0585ee55c | ||
|
|
c0d755e102 | ||
|
|
49e1fc46f4 | ||
|
|
3d90b26b04 | ||
|
|
3b73b9b06b | ||
|
|
74d1bc1ec7 | ||
|
|
78c76dc75a | ||
|
|
f204ed66e1 | ||
|
|
29c53b754d | ||
|
|
5a7fdfcca7 | ||
|
|
c3f082eccf | ||
|
|
808a2585ef | ||
|
|
c0aad062ec | ||
|
|
8ffeaa4211 | ||
|
|
c1d4c768de | ||
|
|
a063c7bb64 | ||
|
|
d058ee087e | ||
|
|
35c38be120 | ||
|
|
cc86f23dba | ||
|
|
54086bf8d6 | ||
|
|
429ed25aba | ||
|
|
128f28ac99 | ||
|
|
420a320839 | ||
|
|
e3f435a78a | ||
|
|
dcc01bb980 | ||
|
|
6f27a3e614 | ||
|
|
36b078c9f6 | ||
|
|
73c1842866 | ||
|
|
ceb3707d28 | ||
|
|
f9e8e041ef | ||
|
|
b59e83e706 | ||
|
|
bfa813a0b8 | ||
|
|
c179ef64c6 | ||
|
|
14a4ee867e | ||
|
|
70ef6239fe | ||
|
|
1b55a238df | ||
|
|
eeb2c92576 | ||
|
|
c1fbeffde5 | ||
|
|
b6137cac8b | ||
|
|
711fd02195 | ||
|
|
248f5a0526 | ||
|
|
8e7ce511bd | ||
|
|
ba7ebc8392 | ||
|
|
6670785a2a | ||
|
|
aabaab1185 | ||
|
|
22eb1f2df4 | ||
|
|
a519ea163e | ||
|
|
6a2eda80d4 | ||
|
|
20d52376f9 | ||
|
|
d897a8a8ea |
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Force LF line endings for mock/test data files to ensure consistent
|
||||||
|
# behavior across platforms (Windows git autocrlf converts to CRLF otherwise)
|
||||||
|
mocks/** text eol=lf
|
||||||
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Submit a bug report
|
||||||
|
title: ''
|
||||||
|
labels: 'bug'
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Thanks for submitting a bug report. Please provide the following information:
|
||||||
|
|
||||||
|
**A description of the problem**
|
||||||
|
Describe the problem here.
|
||||||
|
|
||||||
|
**cheat version info**
|
||||||
|
Please paste the output of `cheat -v` here.
|
||||||
|
|
||||||
|
**cheat configuration info**
|
||||||
|
If your bug pertains to how cheatsheets are loaded and/or displayed, please
|
||||||
|
paste here the following information:
|
||||||
|
|
||||||
|
1. The output of `cheat -d`
|
||||||
|
2. The contents of your `conf.yml` file
|
||||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: 'enhancement'
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
7
.github/dependabot.yml
vendored
Normal file
7
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: gomod
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
open-pull-requests-limit: 10
|
||||||
38
.github/workflows/build.yml
vendored
Normal file
38
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: stable
|
||||||
|
- name: Install revive
|
||||||
|
run: go install github.com/mgechev/revive@latest
|
||||||
|
- name: Lint
|
||||||
|
run: revive -exclude vendor/... ./...
|
||||||
|
- name: Vet
|
||||||
|
run: go vet ./...
|
||||||
|
- name: Check formatting
|
||||||
|
run: test -z "$(gofmt -l . | grep -v vendor/)"
|
||||||
|
|
||||||
|
test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: stable
|
||||||
|
- name: Build
|
||||||
|
run: go build -mod vendor ./cmd/cheat
|
||||||
|
- name: Test
|
||||||
|
run: go test ./...
|
||||||
30
.github/workflows/codeql-analysis.yml
vendored
Normal file
30
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
name: CodeQL
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
schedule:
|
||||||
|
- cron: '45 23 * * 0'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [go]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v3
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v3
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v3
|
||||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,5 +1,5 @@
|
|||||||
*.pyc
|
|
||||||
MANIFEST
|
|
||||||
build
|
|
||||||
cheat.egg-info
|
|
||||||
dist
|
dist
|
||||||
|
tags
|
||||||
|
.tmp
|
||||||
|
*.test
|
||||||
|
.claude
|
||||||
|
|||||||
105
.test-mutations.json
Normal file
105
.test-mutations.json
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0",
|
||||||
|
"test_command": "go test ./...",
|
||||||
|
"last_updated": "2026-02-15T00:00:00Z",
|
||||||
|
"modules": {
|
||||||
|
"internal/sheet/parse.go": {
|
||||||
|
"status": "completed",
|
||||||
|
"covering_tests": ["internal/sheet/parse_test.go", "internal/sheet/parse_extended_test.go"],
|
||||||
|
"last_tested": "2026-02-15T00:00:00Z",
|
||||||
|
"mutations_applied": 8,
|
||||||
|
"mutations_killed": 8,
|
||||||
|
"mutation_score": 100.0,
|
||||||
|
"notes": "Originally 7/8 (87.5%). Added TestHasMalformedYAML to kill YAML unmarshal error survivor."
|
||||||
|
},
|
||||||
|
"internal/config/validate.go": {
|
||||||
|
"status": "completed",
|
||||||
|
"covering_tests": ["internal/config/validate_test.go"],
|
||||||
|
"last_tested": "2026-02-15T00:00:00Z",
|
||||||
|
"mutations_applied": 8,
|
||||||
|
"mutations_killed": 8,
|
||||||
|
"mutation_score": 100.0,
|
||||||
|
"notes": "Originally 7/8 (87.5%). Added TestInvalidateInvalidCheatpath to kill cheatpath.Validate() delegation survivor."
|
||||||
|
},
|
||||||
|
"internal/sheets/filter.go": {
|
||||||
|
"status": "completed",
|
||||||
|
"covering_tests": ["internal/sheets/filter_test.go"],
|
||||||
|
"last_tested": "2026-02-15T00:00:00Z",
|
||||||
|
"mutations_applied": 7,
|
||||||
|
"mutations_killed": 5,
|
||||||
|
"mutation_score": 71.4,
|
||||||
|
"notes": "Survivors relate to UTF-8 condition ordering and OR→AND on dead code path. Not actionable — logically equivalent mutations."
|
||||||
|
},
|
||||||
|
"internal/config/paths.go": {
|
||||||
|
"status": "completed",
|
||||||
|
"covering_tests": ["internal/config/paths_test.go"],
|
||||||
|
"last_tested": "2026-02-15T00:00:00Z",
|
||||||
|
"mutations_applied": 8,
|
||||||
|
"mutations_killed": 8,
|
||||||
|
"mutation_score": 100.0,
|
||||||
|
"notes": "Perfect score. Excellent existing coverage."
|
||||||
|
},
|
||||||
|
"internal/sheet/colorize.go": {
|
||||||
|
"status": "completed",
|
||||||
|
"covering_tests": ["internal/sheet/colorize_test.go"],
|
||||||
|
"last_tested": "2026-02-15T00:00:00Z",
|
||||||
|
"mutations_applied": 5,
|
||||||
|
"mutations_killed": 5,
|
||||||
|
"mutation_score": 100.0,
|
||||||
|
"notes": "Originally 2/5 (40%). Added TestColorizeDefaultSyntax and TestColorizeExplicitSyntax. All 5 mutations now killed."
|
||||||
|
},
|
||||||
|
"internal/sheets/consolidate.go": {
|
||||||
|
"status": "completed",
|
||||||
|
"covering_tests": ["internal/sheets/consolidate_test.go"],
|
||||||
|
"last_tested": "2026-02-15T00:00:00Z",
|
||||||
|
"mutations_applied": 2,
|
||||||
|
"mutations_killed": 2,
|
||||||
|
"mutation_score": 100.0,
|
||||||
|
"notes": "Override semantics well-tested."
|
||||||
|
},
|
||||||
|
"internal/display/indent.go": {
|
||||||
|
"status": "completed",
|
||||||
|
"covering_tests": ["internal/display/indent_test.go"],
|
||||||
|
"last_tested": "2026-02-15T00:00:00Z",
|
||||||
|
"mutations_applied": 3,
|
||||||
|
"mutations_killed": 3,
|
||||||
|
"mutation_score": 100.0,
|
||||||
|
"notes": "Originally 2/3 (66.7%). Added TestIndentTrimsWhitespace to kill TrimSpace survivor."
|
||||||
|
},
|
||||||
|
"internal/display/faint.go": {
|
||||||
|
"status": "completed",
|
||||||
|
"covering_tests": ["internal/display/faint_test.go"],
|
||||||
|
"last_tested": "2026-02-15T00:00:00Z",
|
||||||
|
"mutations_applied": 3,
|
||||||
|
"mutations_killed": 3,
|
||||||
|
"mutation_score": 100.0,
|
||||||
|
"notes": "Perfect score."
|
||||||
|
},
|
||||||
|
"internal/sheets/tags.go": {
|
||||||
|
"status": "completed",
|
||||||
|
"covering_tests": ["internal/sheets/tags_test.go"],
|
||||||
|
"last_tested": "2026-02-15T00:00:00Z",
|
||||||
|
"mutations_applied": 2,
|
||||||
|
"mutations_killed": 2,
|
||||||
|
"mutation_score": 100.0,
|
||||||
|
"notes": "UTF-8 validation and sort order both tested."
|
||||||
|
},
|
||||||
|
"internal/sheet/validate.go": {
|
||||||
|
"status": "completed",
|
||||||
|
"covering_tests": ["internal/sheet/validate_test.go"],
|
||||||
|
"last_tested": "2026-02-15T00:00:00Z",
|
||||||
|
"mutations_applied": 10,
|
||||||
|
"mutations_killed": 10,
|
||||||
|
"mutation_score": 100.0,
|
||||||
|
"notes": "Perfect score. All security checks well-tested."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"global_statistics": {
|
||||||
|
"total_modules": 10,
|
||||||
|
"completed_modules": 10,
|
||||||
|
"total_mutations": 56,
|
||||||
|
"total_killed": 54,
|
||||||
|
"total_survived": 2,
|
||||||
|
"overall_score": 96.4
|
||||||
|
}
|
||||||
|
}
|
||||||
123
CLAUDE.md
Normal file
123
CLAUDE.md
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
|
||||||
|
## Common Development Commands
|
||||||
|
|
||||||
|
### Building
|
||||||
|
```bash
|
||||||
|
# Build for your architecture
|
||||||
|
make build
|
||||||
|
|
||||||
|
# Build release binaries for all platforms
|
||||||
|
make build-release
|
||||||
|
|
||||||
|
# Install cheat to your PATH
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Testing and Quality Checks
|
||||||
|
```bash
|
||||||
|
# Run all tests
|
||||||
|
make test
|
||||||
|
go test ./...
|
||||||
|
|
||||||
|
# Run a single test
|
||||||
|
go test -run TestFunctionName ./internal/package_name
|
||||||
|
|
||||||
|
# Generate test coverage report
|
||||||
|
make coverage
|
||||||
|
|
||||||
|
# Run linter (revive)
|
||||||
|
make lint
|
||||||
|
|
||||||
|
# Run go vet
|
||||||
|
make vet
|
||||||
|
|
||||||
|
# Format code
|
||||||
|
make fmt
|
||||||
|
|
||||||
|
# Run all checks (vendor, fmt, lint, vet, test)
|
||||||
|
make check
|
||||||
|
```
|
||||||
|
|
||||||
|
### Development Setup
|
||||||
|
```bash
|
||||||
|
# Install development dependencies (revive linter, scc)
|
||||||
|
make setup
|
||||||
|
|
||||||
|
# Update and verify vendored dependencies
|
||||||
|
make vendor-update
|
||||||
|
```
|
||||||
|
|
||||||
|
## Architecture Overview
|
||||||
|
|
||||||
|
The `cheat` command-line tool is organized into several key packages:
|
||||||
|
|
||||||
|
### Command Layer (`cmd/cheat/`)
|
||||||
|
- `main.go`: Entry point, cobra command definition, flag registration, command routing
|
||||||
|
- `cmd_*.go`: Individual command implementations (view, edit, list, search, etc.)
|
||||||
|
- `completions.go`: Dynamic shell completion functions for cheatsheet names, tags, and paths
|
||||||
|
- Commands are routed via a `switch` block in the cobra `RunE` handler
|
||||||
|
|
||||||
|
### Core Internal Packages
|
||||||
|
|
||||||
|
1. **`internal/config`**: Configuration management
|
||||||
|
- Loads YAML config from platform-specific paths
|
||||||
|
- Manages editor, pager, colorization settings
|
||||||
|
- Validates and expands cheatpath configurations
|
||||||
|
|
||||||
|
2. **`internal/cheatpath`**: Cheatsheet path management
|
||||||
|
- Represents collections of cheatsheets on filesystem
|
||||||
|
- Handles read-only vs writable paths
|
||||||
|
- Supports filtering and validation
|
||||||
|
|
||||||
|
3. **`internal/sheet`**: Individual cheatsheet handling
|
||||||
|
- Parses YAML frontmatter for tags and syntax
|
||||||
|
- Implements syntax highlighting via Chroma
|
||||||
|
- Provides search functionality within sheets
|
||||||
|
|
||||||
|
4. **`internal/sheets`**: Collection operations
|
||||||
|
- Loads sheets from multiple cheatpaths
|
||||||
|
- Consolidates duplicates (local overrides global)
|
||||||
|
- Filters by tags and sorts results
|
||||||
|
|
||||||
|
5. **`internal/display`**: Output formatting
|
||||||
|
- Writes to stdout or pager
|
||||||
|
- Handles text formatting and indentation
|
||||||
|
|
||||||
|
6. **`internal/installer`**: First-run installer
|
||||||
|
- Prompts user for initial configuration choices
|
||||||
|
- Generates default `conf.yml` and downloads community cheatsheets
|
||||||
|
|
||||||
|
7. **`internal/repo`**: Git repository management
|
||||||
|
- Clones community cheatsheet repositories
|
||||||
|
- Updates existing repositories
|
||||||
|
|
||||||
|
### Key Design Patterns
|
||||||
|
|
||||||
|
- **Filesystem-based storage**: Cheatsheets are plain text files
|
||||||
|
- **Override mechanism**: Local sheets override community sheets with same name
|
||||||
|
- **Tag system**: Sheets can be categorized with tags in frontmatter
|
||||||
|
- **Multiple cheatpaths**: Supports personal, community, and directory-scoped sheets
|
||||||
|
- **Directory-scoped discovery**: Walks up from cwd to find the nearest `.cheat` directory (like `.git` discovery)
|
||||||
|
|
||||||
|
### Sheet Format
|
||||||
|
|
||||||
|
Cheatsheets are plain text files optionally prefixed with YAML frontmatter:
|
||||||
|
```
|
||||||
|
---
|
||||||
|
syntax: bash
|
||||||
|
tags: [ networking, ssh ]
|
||||||
|
---
|
||||||
|
# SSH tunneling example
|
||||||
|
ssh -L 8080:localhost:80 user@remote
|
||||||
|
```
|
||||||
|
|
||||||
|
### Working with the Codebase
|
||||||
|
|
||||||
|
- Always check for `.git` directories and skip them during filesystem walks
|
||||||
|
- Use `go-git` for repository operations, not exec'ing git commands
|
||||||
|
- Platform-specific paths are handled in `internal/config/paths.go`
|
||||||
|
- Color output uses ANSI codes via the Chroma library
|
||||||
|
- Test files use the `mocks` package for test data
|
||||||
@@ -1,9 +1,17 @@
|
|||||||
Contributing
|
# Contributing
|
||||||
============
|
|
||||||
If you would like to contribute cheetsheets or program functionality, please
|
|
||||||
fork this repository, make your changes, and send me a pull request.
|
|
||||||
|
|
||||||
Python code show follow the standards laid out by [PEP 8][].
|
Thank you for your interest in `cheat`.
|
||||||
|
|
||||||
|
Pull requests are no longer being accepted, and have been disabled on this
|
||||||
|
repository. The maintainer is not currently reviewing or merging external code
|
||||||
|
contributions.
|
||||||
|
|
||||||
[PEP 8]: http://legacy.python.org/dev/peps/pep-0008/
|
Bug reports are still welcome. If you've found a bug, please open an issue in
|
||||||
|
the [issue tracker][issues]. Before doing so, please search through the
|
||||||
|
existing open issues to make sure it hasn't already been reported.
|
||||||
|
|
||||||
|
Feature requests may be filed, but are unlikely to be implemented. The project
|
||||||
|
is now mature and the maintainer considers its feature set to be essentially
|
||||||
|
complete.
|
||||||
|
|
||||||
|
[issues]: https://github.com/cheat/cheat/issues
|
||||||
|
|||||||
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# NB: this image isn't used anywhere in the build pipeline. It exists to
|
||||||
|
# conveniently facilitate ad-hoc experimentation in a sandboxed environment
|
||||||
|
# during development.
|
||||||
|
FROM golang:1.26-alpine
|
||||||
|
|
||||||
|
RUN apk add git less make
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
241
HACKING.md
Normal file
241
HACKING.md
Normal file
@@ -0,0 +1,241 @@
|
|||||||
|
# Hacking Guide
|
||||||
|
|
||||||
|
This document provides a comprehensive guide for developing `cheat`, including setup, architecture overview, and code patterns.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### 1. Install system dependencies
|
||||||
|
|
||||||
|
The following are required and must be available on your `PATH`:
|
||||||
|
- `git`
|
||||||
|
- `go` (>= 1.19 is recommended)
|
||||||
|
- `make`
|
||||||
|
|
||||||
|
Optional dependencies:
|
||||||
|
- `docker`
|
||||||
|
- `pandoc` (necessary to generate a `man` page)
|
||||||
|
|
||||||
|
### 2. Install utility applications
|
||||||
|
Run `make setup` to install `scc` and `revive`, which are used by various `make` targets.
|
||||||
|
|
||||||
|
### 3. Development workflow
|
||||||
|
|
||||||
|
1. Make changes to the `cheat` source code
|
||||||
|
2. Run `make test` to run unit-tests
|
||||||
|
3. Fix compiler errors and failing tests as necessary
|
||||||
|
4. Run `make build`. A `cheat` executable will be written to the `dist` directory
|
||||||
|
5. Use the new executable by running `dist/cheat <command>`
|
||||||
|
6. Run `make install` to install `cheat` to your `PATH`
|
||||||
|
7. Run `make build-release` to build cross-platform binaries in `dist`
|
||||||
|
8. Run `make clean` to clean the `dist` directory when desired
|
||||||
|
|
||||||
|
You may run `make help` to see a list of available `make` commands.
|
||||||
|
|
||||||
|
### 4. Testing
|
||||||
|
|
||||||
|
#### Unit Tests
|
||||||
|
Run unit tests with:
|
||||||
|
```bash
|
||||||
|
make test
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Integration Tests
|
||||||
|
Integration tests that require network access are separated using build tags. Run them with:
|
||||||
|
```bash
|
||||||
|
make test-integration
|
||||||
|
```
|
||||||
|
|
||||||
|
To run all tests (unit and integration):
|
||||||
|
```bash
|
||||||
|
make test-all
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Test Coverage
|
||||||
|
Generate a coverage report with:
|
||||||
|
```bash
|
||||||
|
make coverage # HTML report
|
||||||
|
make coverage-text # Terminal output
|
||||||
|
```
|
||||||
|
|
||||||
|
## Architecture Overview
|
||||||
|
|
||||||
|
### Package Structure
|
||||||
|
|
||||||
|
The `cheat` application follows a clean architecture with well-separated concerns:
|
||||||
|
|
||||||
|
- **`cmd/cheat/`**: Command layer (cobra-based CLI, flag registration, command routing, shell completions)
|
||||||
|
- **`internal/config`**: Configuration management (YAML loading, validation, paths)
|
||||||
|
- **`internal/cheatpath`**: Cheatsheet path management (collections, filtering)
|
||||||
|
- **`internal/sheet`**: Individual cheatsheet handling (parsing, search, highlighting)
|
||||||
|
- **`internal/sheets`**: Collection operations (loading, consolidation, filtering)
|
||||||
|
- **`internal/display`**: Output formatting (pager integration, colorization)
|
||||||
|
- **`internal/repo`**: Git repository management for community sheets
|
||||||
|
|
||||||
|
### Key Design Patterns
|
||||||
|
|
||||||
|
- **Filesystem-based storage**: Cheatsheets are plain text files
|
||||||
|
- **Override mechanism**: Local sheets override community sheets with same name
|
||||||
|
- **Tag system**: Sheets can be categorized with tags in frontmatter
|
||||||
|
- **Multiple cheatpaths**: Supports personal, community, and directory-scoped sheets
|
||||||
|
|
||||||
|
## Core Types and Functions
|
||||||
|
|
||||||
|
### Config (`internal/config`)
|
||||||
|
|
||||||
|
The main configuration structure:
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Config struct {
|
||||||
|
Colorize bool `yaml:"colorize"`
|
||||||
|
Editor string `yaml:"editor"`
|
||||||
|
Cheatpaths []cp.Path `yaml:"cheatpaths"`
|
||||||
|
Style string `yaml:"style"`
|
||||||
|
Formatter string `yaml:"formatter"`
|
||||||
|
Pager string `yaml:"pager"`
|
||||||
|
Path string
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Key functions:
|
||||||
|
- `New(confPath, resolve)` - Load config from file
|
||||||
|
- `Validate()` - Validate configuration values
|
||||||
|
- `Editor()` - Get editor from environment or defaults (package-level function)
|
||||||
|
- `Pager()` - Get pager from environment or defaults (package-level function)
|
||||||
|
|
||||||
|
### Cheatpath (`internal/cheatpath`)
|
||||||
|
|
||||||
|
Represents a directory containing cheatsheets:
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Path struct {
|
||||||
|
Name string // Friendly name (e.g., "personal")
|
||||||
|
Path string // Filesystem path
|
||||||
|
Tags []string // Tags applied to all sheets in this path
|
||||||
|
ReadOnly bool // Whether sheets can be modified
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sheet (`internal/sheet`)
|
||||||
|
|
||||||
|
Represents an individual cheatsheet:
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Sheet struct {
|
||||||
|
Title string // Sheet name (from filename)
|
||||||
|
CheatPath string // Name of the cheatpath this sheet belongs to
|
||||||
|
Path string // Full filesystem path
|
||||||
|
Text string // Content (without frontmatter)
|
||||||
|
Tags []string // Combined tags (from frontmatter + cheatpath)
|
||||||
|
Syntax string // Syntax for highlighting
|
||||||
|
ReadOnly bool // Whether sheet can be edited
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Key methods:
|
||||||
|
- `New(title, cheatpath, path, tags, readOnly)` - Load from file
|
||||||
|
- `Search(reg)` - Search content with a compiled regexp
|
||||||
|
- `Colorize(conf)` - Apply syntax highlighting (modifies sheet in place)
|
||||||
|
- `Tagged(needle)` - Check if sheet has the given tag
|
||||||
|
|
||||||
|
## Common Operations
|
||||||
|
|
||||||
|
### Loading and Displaying a Sheet
|
||||||
|
|
||||||
|
```go
|
||||||
|
// Load sheet
|
||||||
|
s, err := sheet.New("tar", "personal", "/path/to/tar", []string{"personal"}, false)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply syntax highlighting (modifies sheet in place)
|
||||||
|
s.Colorize(conf)
|
||||||
|
|
||||||
|
// Display with pager
|
||||||
|
display.Write(s.Text, conf)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Working with Sheet Collections
|
||||||
|
|
||||||
|
```go
|
||||||
|
// Load all sheets from cheatpaths (returns a slice of maps, one per cheatpath)
|
||||||
|
allSheets, err := sheets.Load(conf.Cheatpaths)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consolidate to handle duplicates (later cheatpaths take precedence)
|
||||||
|
consolidated := sheets.Consolidate(allSheets)
|
||||||
|
|
||||||
|
// Filter by tag (operates on the slice of maps)
|
||||||
|
filtered := sheets.Filter(allSheets, []string{"networking"})
|
||||||
|
|
||||||
|
// Sort alphabetically (returns a sorted slice)
|
||||||
|
sorted := sheets.Sort(consolidated)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sheet Format
|
||||||
|
|
||||||
|
Cheatsheets are plain text files that may begin with YAML frontmatter:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
syntax: bash
|
||||||
|
tags: [networking, linux, ssh]
|
||||||
|
---
|
||||||
|
# Connect to remote server
|
||||||
|
ssh user@hostname
|
||||||
|
|
||||||
|
# Copy files over SSH
|
||||||
|
scp local_file user@hostname:/remote/path
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
Run tests with:
|
||||||
|
```bash
|
||||||
|
make test # Run all tests
|
||||||
|
make coverage # Generate coverage report
|
||||||
|
go test ./... # Go test directly
|
||||||
|
```
|
||||||
|
|
||||||
|
Test files follow Go conventions:
|
||||||
|
- `*_test.go` files in same package
|
||||||
|
- Table-driven tests for multiple scenarios
|
||||||
|
- Mock data in `mocks` package
|
||||||
|
|
||||||
|
## Error Handling
|
||||||
|
|
||||||
|
The codebase follows consistent error handling patterns:
|
||||||
|
- Functions return explicit errors
|
||||||
|
- Errors are wrapped with context using `fmt.Errorf`
|
||||||
|
- User-facing errors are written to stderr
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```go
|
||||||
|
sheet, err := sheet.New(path, tags, false)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load sheet: %w", err)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Developing with Docker
|
||||||
|
|
||||||
|
It may be useful to test your changes within a pristine environment. An Alpine-based docker container has been provided for that purpose.
|
||||||
|
|
||||||
|
Build the docker container:
|
||||||
|
```bash
|
||||||
|
make docker-setup
|
||||||
|
```
|
||||||
|
|
||||||
|
Shell into the container:
|
||||||
|
```bash
|
||||||
|
make docker-sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The `cheat` source code will be mounted at `/app` within the container.
|
||||||
|
|
||||||
|
To destroy the container:
|
||||||
|
```bash
|
||||||
|
make distclean
|
||||||
|
```
|
||||||
76
INSTALLING.md
Normal file
76
INSTALLING.md
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# Installing
|
||||||
|
`cheat` has no runtime dependencies. As such, installing it is generally
|
||||||
|
straightforward. There are a few methods available:
|
||||||
|
|
||||||
|
## Install manually
|
||||||
|
### Unix-like
|
||||||
|
On Unix-like systems, you may simply paste the following snippet into your terminal:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd /tmp \
|
||||||
|
&& wget https://github.com/cheat/cheat/releases/download/5.0.0/cheat-linux-amd64.gz \
|
||||||
|
&& gunzip cheat-linux-amd64.gz \
|
||||||
|
&& chmod +x cheat-linux-amd64 \
|
||||||
|
&& sudo mv cheat-linux-amd64 /usr/local/bin/cheat
|
||||||
|
```
|
||||||
|
|
||||||
|
You may need to need to change the version number (`5.0.0`) and the archive
|
||||||
|
(`cheat-linux-amd64.gz`) depending on your platform.
|
||||||
|
|
||||||
|
See the [releases page][releases] for a list of supported platforms.
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
On Windows, download the appropriate binary from the [releases page][releases],
|
||||||
|
unzip the archive, and place the `cheat.exe` executable on your `PATH`.
|
||||||
|
|
||||||
|
## Install via `go install`
|
||||||
|
If you have `go` version `>=1.17` available on your `PATH`, you can install
|
||||||
|
`cheat` via `go install`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
go install github.com/cheat/cheat/cmd/cheat@latest
|
||||||
|
```
|
||||||
|
|
||||||
|
## Install via package manager
|
||||||
|
Several community-maintained packages are also available:
|
||||||
|
|
||||||
|
Package manager | Package(s)
|
||||||
|
---------------- | -----------
|
||||||
|
aur | [cheat][pkg-aur-cheat], [cheat-bin][pkg-aur-cheat-bin]
|
||||||
|
brew | [cheat][pkg-brew]
|
||||||
|
docker | [docker-cheat][pkg-docker]
|
||||||
|
nix | [nixos.cheat][pkg-nix]
|
||||||
|
snap | [cheat][pkg-snap]
|
||||||
|
|
||||||
|
## Configuring
|
||||||
|
Three things must be done before you can use `cheat`:
|
||||||
|
1. A config file must be generated
|
||||||
|
2. [`cheatpaths`][cheatpaths] must be configured
|
||||||
|
3. [Community cheatsheets][community] must be downloaded
|
||||||
|
|
||||||
|
On first run, `cheat` will run an installer that will do all of the above
|
||||||
|
automatically. After the installer is complete, it is strongly advised that you
|
||||||
|
view the configuration file that was generated, as you may want to change some
|
||||||
|
of its default values (to enable colorization, change the paginator, etc).
|
||||||
|
|
||||||
|
### conf.yml
|
||||||
|
`cheat` is configured by a YAML file that will be auto-generated on first run.
|
||||||
|
|
||||||
|
By default, the config file is assumed to exist on an XDG-compliant
|
||||||
|
configuration path like `~/.config/cheat/conf.yml`. If you would like to store
|
||||||
|
it elsewhere, you may export a `CHEAT_CONFIG_PATH` environment variable that
|
||||||
|
specifies its path:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export CHEAT_CONFIG_PATH="~/.dotfiles/cheat/conf.yml"
|
||||||
|
```
|
||||||
|
|
||||||
|
[cheatpaths]: README.md#cheatpaths
|
||||||
|
[community]: https://github.com/cheat/cheatsheets/
|
||||||
|
[pkg-aur-cheat-bin]: https://aur.archlinux.org/packages/cheat-bin
|
||||||
|
[pkg-aur-cheat]: https://aur.archlinux.org/packages/cheat
|
||||||
|
[pkg-brew]: https://formulae.brew.sh/formula/cheat
|
||||||
|
[pkg-docker]: https://github.com/bannmann/docker-cheat
|
||||||
|
[pkg-nix]: https://search.nixos.org/packages?channel=unstable&show=cheat&from=0&size=50&sort=relevance&type=packages&query=cheat
|
||||||
|
[pkg-snap]: https://snapcraft.io/cheat
|
||||||
|
[releases]: https://github.com/cheat/cheat/releases
|
||||||
678
LICENSE
678
LICENSE
@@ -1,678 +0,0 @@
|
|||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. [http://fsf.org/]
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
{one line to give the program's name and a brief idea of what it does.}
|
|
||||||
Copyright (C) {year} {name of author}
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see [http://www.gnu.org/licenses/].
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
{project} Copyright (C) {year} {fullname}
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
[http://www.gnu.org/licenses/].
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
[http://www.gnu.org/philosophy/why-not-lgpl.html].
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
19
LICENSE.txt
Normal file
19
LICENSE.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright 2013 Christopher Allen Lane
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
281
Makefile
Normal file
281
Makefile
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
# paths
|
||||||
|
makefile := $(realpath $(lastword $(MAKEFILE_LIST)))
|
||||||
|
cmd_dir := ./cmd/cheat
|
||||||
|
dist_dir := ./dist
|
||||||
|
|
||||||
|
# parallel jobs for build-release (can be overridden)
|
||||||
|
JOBS ?= 8
|
||||||
|
|
||||||
|
# executables
|
||||||
|
CAT := cat
|
||||||
|
COLUMN := column
|
||||||
|
CTAGS := ctags
|
||||||
|
DOCKER := docker
|
||||||
|
GO := go
|
||||||
|
GREP := grep
|
||||||
|
GZIP := gzip --best
|
||||||
|
LINT := revive
|
||||||
|
MAN := man
|
||||||
|
MKDIR := mkdir -p
|
||||||
|
PANDOC := pandoc
|
||||||
|
RM := rm
|
||||||
|
SCC := scc
|
||||||
|
SED := sed
|
||||||
|
SORT := sort
|
||||||
|
ZIP := zip -m
|
||||||
|
|
||||||
|
docker_image := cheat-devel:latest
|
||||||
|
|
||||||
|
# build flags
|
||||||
|
export CGO_ENABLED := 0
|
||||||
|
BUILD_FLAGS := -ldflags="-s -w" -mod vendor -trimpath
|
||||||
|
GOBIN :=
|
||||||
|
TMPDIR := /tmp
|
||||||
|
|
||||||
|
# release binaries
|
||||||
|
releases := \
|
||||||
|
$(dist_dir)/cheat-darwin-amd64 \
|
||||||
|
$(dist_dir)/cheat-darwin-arm64 \
|
||||||
|
$(dist_dir)/cheat-linux-386 \
|
||||||
|
$(dist_dir)/cheat-linux-amd64 \
|
||||||
|
$(dist_dir)/cheat-linux-arm5 \
|
||||||
|
$(dist_dir)/cheat-linux-arm6 \
|
||||||
|
$(dist_dir)/cheat-linux-arm64 \
|
||||||
|
$(dist_dir)/cheat-linux-arm7 \
|
||||||
|
$(dist_dir)/cheat-netbsd-amd64 \
|
||||||
|
$(dist_dir)/cheat-openbsd-amd64 \
|
||||||
|
$(dist_dir)/cheat-solaris-amd64 \
|
||||||
|
$(dist_dir)/cheat-windows-amd64.exe
|
||||||
|
|
||||||
|
## build: build an executable for your architecture
|
||||||
|
.PHONY: build
|
||||||
|
build: | clean $(dist_dir) fmt lint vet vendor man
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $(dist_dir)/cheat $(cmd_dir)
|
||||||
|
|
||||||
|
## build-release: build release executables
|
||||||
|
# Runs prepare once, then builds all binaries in parallel
|
||||||
|
# Override jobs with: make build-release JOBS=16
|
||||||
|
.PHONY: build-release
|
||||||
|
build-release: prepare
|
||||||
|
$(MAKE) -j$(JOBS) $(releases)
|
||||||
|
|
||||||
|
# cheat-darwin-amd64
|
||||||
|
$(dist_dir)/cheat-darwin-amd64:
|
||||||
|
GOARCH=amd64 GOOS=darwin \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-darwin-arm64
|
||||||
|
$(dist_dir)/cheat-darwin-arm64:
|
||||||
|
GOARCH=arm64 GOOS=darwin \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-linux-386
|
||||||
|
$(dist_dir)/cheat-linux-386:
|
||||||
|
GOARCH=386 GOOS=linux \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-linux-amd64
|
||||||
|
$(dist_dir)/cheat-linux-amd64:
|
||||||
|
GOARCH=amd64 GOOS=linux \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-linux-arm5
|
||||||
|
$(dist_dir)/cheat-linux-arm5:
|
||||||
|
GOARCH=arm GOOS=linux GOARM=5 \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-linux-arm6
|
||||||
|
$(dist_dir)/cheat-linux-arm6:
|
||||||
|
GOARCH=arm GOOS=linux GOARM=6 \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-linux-arm7
|
||||||
|
$(dist_dir)/cheat-linux-arm7:
|
||||||
|
GOARCH=arm GOOS=linux GOARM=7 \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-linux-arm64
|
||||||
|
$(dist_dir)/cheat-linux-arm64:
|
||||||
|
GOARCH=arm64 GOOS=linux \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-netbsd-amd64
|
||||||
|
$(dist_dir)/cheat-netbsd-amd64:
|
||||||
|
GOARCH=amd64 GOOS=netbsd \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-openbsd-amd64
|
||||||
|
$(dist_dir)/cheat-openbsd-amd64:
|
||||||
|
GOARCH=amd64 GOOS=openbsd \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-solaris-amd64
|
||||||
|
$(dist_dir)/cheat-solaris-amd64:
|
||||||
|
GOARCH=amd64 GOOS=solaris \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-windows-amd64
|
||||||
|
$(dist_dir)/cheat-windows-amd64.exe:
|
||||||
|
GOARCH=amd64 GOOS=windows \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(ZIP) $@.zip $@ -j
|
||||||
|
|
||||||
|
# ./dist
|
||||||
|
$(dist_dir):
|
||||||
|
$(MKDIR) $(dist_dir)
|
||||||
|
|
||||||
|
# .tmp
|
||||||
|
.tmp:
|
||||||
|
$(MKDIR) .tmp
|
||||||
|
|
||||||
|
## install: build and install cheat on your PATH
|
||||||
|
.PHONY: install
|
||||||
|
install: build
|
||||||
|
$(GO) install $(BUILD_FLAGS) $(GOBIN) $(cmd_dir)
|
||||||
|
|
||||||
|
## clean: remove compiled executables
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
$(RM) -f $(dist_dir)/*
|
||||||
|
$(RM) -rf .tmp
|
||||||
|
|
||||||
|
## distclean: remove the tags file
|
||||||
|
.PHONY: distclean
|
||||||
|
distclean:
|
||||||
|
$(RM) -f tags
|
||||||
|
@$(DOCKER) image rm -f $(docker_image)
|
||||||
|
|
||||||
|
## setup: install revive (linter) and scc (sloc tool)
|
||||||
|
.PHONY: setup
|
||||||
|
setup:
|
||||||
|
$(GO) install github.com/boyter/scc@latest
|
||||||
|
$(GO) install github.com/mgechev/revive@latest
|
||||||
|
|
||||||
|
## sloc: count "semantic lines of code"
|
||||||
|
.PHONY: sloc
|
||||||
|
sloc:
|
||||||
|
$(SCC) --exclude-dir=vendor
|
||||||
|
|
||||||
|
## tags: build a tags file
|
||||||
|
.PHONY: tags
|
||||||
|
tags:
|
||||||
|
$(CTAGS) -R --exclude=vendor --languages=go
|
||||||
|
|
||||||
|
## man: build a man page
|
||||||
|
# NB: pandoc may not be installed, so we're ignoring this error on failure
|
||||||
|
.PHONY: man
|
||||||
|
man:
|
||||||
|
-$(PANDOC) -s -t man doc/cheat.1.md -o doc/cheat.1
|
||||||
|
|
||||||
|
## vendor: download, tidy, and verify dependencies
|
||||||
|
.PHONY: vendor
|
||||||
|
vendor:
|
||||||
|
$(GO) mod vendor && $(GO) mod tidy && $(GO) mod verify
|
||||||
|
|
||||||
|
## vendor-update: update vendored dependencies
|
||||||
|
.PHONY: vendor-update
|
||||||
|
vendor-update:
|
||||||
|
$(GO) get -t -u ./... && $(GO) mod vendor && $(GO) mod tidy && $(GO) mod verify
|
||||||
|
|
||||||
|
## fmt: run go fmt
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt:
|
||||||
|
$(GO) fmt ./...
|
||||||
|
|
||||||
|
## lint: lint go source files
|
||||||
|
.PHONY: lint
|
||||||
|
lint: vendor
|
||||||
|
$(LINT) -exclude vendor/... ./...
|
||||||
|
|
||||||
|
## vet: vet go source files
|
||||||
|
.PHONY: vet
|
||||||
|
vet:
|
||||||
|
$(GO) vet ./...
|
||||||
|
|
||||||
|
## test: run unit-tests
|
||||||
|
.PHONY: test
|
||||||
|
test:
|
||||||
|
$(GO) test ./...
|
||||||
|
|
||||||
|
## test-integration: run integration tests (requires network)
|
||||||
|
.PHONY: test-integration
|
||||||
|
test-integration:
|
||||||
|
$(GO) test -tags=integration -count=1 ./...
|
||||||
|
|
||||||
|
## test-all: run all tests (unit and integration)
|
||||||
|
.PHONY: test-all
|
||||||
|
test-all: test test-integration
|
||||||
|
|
||||||
|
## test-fuzz: run quick fuzz tests for security-critical functions
|
||||||
|
.PHONY: test-fuzz
|
||||||
|
test-fuzz:
|
||||||
|
@./test/fuzz.sh 15s
|
||||||
|
|
||||||
|
## test-fuzz-long: run extended fuzz tests (10 minutes each)
|
||||||
|
.PHONY: test-fuzz-long
|
||||||
|
test-fuzz-long:
|
||||||
|
@./test/fuzz.sh 10m
|
||||||
|
|
||||||
|
## coverage: generate a test coverage report
|
||||||
|
.PHONY: coverage
|
||||||
|
coverage: .tmp
|
||||||
|
$(GO) test ./... -coverprofile=.tmp/cheat-coverage.out && \
|
||||||
|
$(GO) tool cover -html=.tmp/cheat-coverage.out -o .tmp/cheat-coverage.html && \
|
||||||
|
echo "Coverage report generated: .tmp/cheat-coverage.html" && \
|
||||||
|
(sensible-browser .tmp/cheat-coverage.html 2>/dev/null || \
|
||||||
|
xdg-open .tmp/cheat-coverage.html 2>/dev/null || \
|
||||||
|
open .tmp/cheat-coverage.html 2>/dev/null || \
|
||||||
|
echo "Please open .tmp/cheat-coverage.html in your browser")
|
||||||
|
|
||||||
|
## coverage-text: show test coverage by function in terminal
|
||||||
|
.PHONY: coverage-text
|
||||||
|
coverage-text: .tmp
|
||||||
|
$(GO) test ./... -coverprofile=.tmp/cheat-coverage.out && \
|
||||||
|
$(GO) tool cover -func=.tmp/cheat-coverage.out | $(SORT) -k3 -n
|
||||||
|
|
||||||
|
## benchmark: run performance benchmarks
|
||||||
|
.PHONY: benchmark
|
||||||
|
benchmark: .tmp
|
||||||
|
$(GO) test -tags=integration -bench=. -benchtime=10s -benchmem ./test/integration | tee .tmp/benchmark-latest.txt && \
|
||||||
|
$(RM) -f integration.test
|
||||||
|
|
||||||
|
## benchmark-cpu: run benchmarks with CPU profiling
|
||||||
|
.PHONY: benchmark-cpu
|
||||||
|
benchmark-cpu: .tmp
|
||||||
|
$(GO) test -tags=integration -bench=. -benchtime=10s -cpuprofile=.tmp/cpu.prof ./test/integration && \
|
||||||
|
$(RM) -f integration.test && \
|
||||||
|
echo "CPU profile saved to .tmp/cpu.prof" && \
|
||||||
|
echo "View with: go tool pprof -http=:8080 .tmp/cpu.prof"
|
||||||
|
|
||||||
|
## benchmark-mem: run benchmarks with memory profiling
|
||||||
|
.PHONY: benchmark-mem
|
||||||
|
benchmark-mem: .tmp
|
||||||
|
$(GO) test -tags=integration -bench=. -benchtime=10s -benchmem -memprofile=.tmp/mem.prof ./test/integration && \
|
||||||
|
$(RM) -f integration.test && \
|
||||||
|
echo "Memory profile saved to .tmp/mem.prof" && \
|
||||||
|
echo "View with: go tool pprof -http=:8080 .tmp/mem.prof"
|
||||||
|
|
||||||
|
## check: format, lint, vet, vendor, and run unit-tests
|
||||||
|
.PHONY: check
|
||||||
|
check: | vendor fmt lint vet test
|
||||||
|
|
||||||
|
.PHONY: prepare
|
||||||
|
prepare: | clean $(dist_dir) vendor fmt lint vet test
|
||||||
|
|
||||||
|
## docker-setup: create a docker image for use during development
|
||||||
|
.PHONY: docker-setup
|
||||||
|
docker-setup:
|
||||||
|
$(DOCKER) build -t $(docker_image) -f Dockerfile .
|
||||||
|
|
||||||
|
## docker-sh: shell into the docker development container
|
||||||
|
.PHONY: docker-sh
|
||||||
|
docker-sh:
|
||||||
|
$(DOCKER) run -v $(shell pwd):/app -ti $(docker_image) /bin/ash
|
||||||
|
|
||||||
|
## help: display this help text
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
@$(CAT) $(makefile) | \
|
||||||
|
$(SORT) | \
|
||||||
|
$(GREP) "^##" | \
|
||||||
|
$(SED) 's/## //g' | \
|
||||||
|
$(COLUMN) -t -s ':'
|
||||||
247
README.md
247
README.md
@@ -1,5 +1,7 @@
|
|||||||
cheat
|

|
||||||
=====
|
|
||||||
|
# cheat
|
||||||
|
|
||||||
`cheat` allows you to create and view interactive cheatsheets on the
|
`cheat` allows you to create and view interactive cheatsheets on the
|
||||||
command-line. It was designed to help remind \*nix system administrators of
|
command-line. It was designed to help remind \*nix system administrators of
|
||||||
options for commands that they use frequently, but not frequently enough to
|
options for commands that they use frequently, but not frequently enough to
|
||||||
@@ -7,147 +9,204 @@ remember.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
`cheat` depends only on `python` and `pip`.
|
Use `cheat` with [cheatsheets][].
|
||||||
|
|
||||||
PyPI status:
|
## Example
|
||||||
|
|
||||||
[](https://pypi.python.org/pypi/cheat/)
|
|
||||||
[](https://pypi.python.org/pypi/cheat/)
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
The next time you're forced to disarm a nuclear weapon without consulting
|
The next time you're forced to disarm a nuclear weapon without consulting
|
||||||
Google, you may run:
|
Google, you may run:
|
||||||
|
|
||||||
cheat tar
|
```sh
|
||||||
|
cheat tar
|
||||||
You will be presented with a cheatsheet resembling:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
# To extract an uncompressed archive:
|
|
||||||
tar -xvf /path/to/foo.tar
|
You will be presented with a cheatsheet resembling the following:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# To extract an uncompressed archive:
|
||||||
|
tar -xvf '/path/to/foo.tar'
|
||||||
|
|
||||||
# To extract a .gz archive:
|
# To extract a .gz archive:
|
||||||
tar -xzvf /path/to/foo.tgz
|
tar -xzvf '/path/to/foo.tgz'
|
||||||
|
|
||||||
# To create a .gz archive:
|
# To create a .gz archive:
|
||||||
tar -czvf /path/to/foo.tgz /path/to/foo/
|
tar -czvf '/path/to/foo.tgz' '/path/to/foo/'
|
||||||
|
|
||||||
# To extract a .bz2 archive:
|
# To extract a .bz2 archive:
|
||||||
tar -xjvf /path/to/foo.tgz
|
tar -xjvf '/path/to/foo.tgz'
|
||||||
|
|
||||||
# To create a .bz2 archive:
|
# To create a .bz2 archive:
|
||||||
tar -cjvf /path/to/foo.tgz /path/to/foo/
|
tar -cjvf '/path/to/foo.tgz' '/path/to/foo/'
|
||||||
```
|
```
|
||||||
|
|
||||||
To see what cheatsheets are availble, run `cheat -l`.
|
## Installing
|
||||||
|
For installation and configuration instructions, see [INSTALLING.md][].
|
||||||
|
|
||||||
Note that, while `cheat` was designed primarily for *nix system administrators,
|
## Usage
|
||||||
it is agnostic as to what content it stores. If you would like to use `cheat`
|
To view a cheatsheet:
|
||||||
to store notes on your favorite cookie recipes, feel free.
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cheat tar # a "top-level" cheatsheet
|
||||||
|
cheat foo/bar # a "nested" cheatsheet
|
||||||
|
```
|
||||||
|
|
||||||
Installing
|
To edit a cheatsheet:
|
||||||
----------
|
|
||||||
|
|
||||||
### Using pip ###
|
|
||||||
|
|
||||||
sudo pip install cheat
|
```sh
|
||||||
|
cheat -e tar # opens the "tar" cheatsheet for editing, or creates it if it does not exist
|
||||||
|
cheat -e foo/bar # nested cheatsheets are accessed like this
|
||||||
|
```
|
||||||
|
|
||||||
### Using homebrew ###
|
To view the configured cheatpaths:
|
||||||
|
|
||||||
brew install cheat
|
```sh
|
||||||
|
cheat -d
|
||||||
### Manually ###
|
```
|
||||||
|
|
||||||
First install the required python dependencies with:
|
To list all available cheatsheets:
|
||||||
|
|
||||||
sudo pip install docopt pygments
|
```sh
|
||||||
|
cheat -l
|
||||||
|
```
|
||||||
|
|
||||||
Then, clone this repository, `cd` into it, and run:
|
To briefly list all cheatsheets (names and tags only):
|
||||||
|
|
||||||
sudo python setup.py install
|
```sh
|
||||||
|
cheat -b
|
||||||
|
```
|
||||||
|
|
||||||
|
To list all cheatsheets that are tagged with "networking":
|
||||||
|
|
||||||
Modifying Cheatsheets
|
```sh
|
||||||
---------------------
|
cheat -l -t networking
|
||||||
The value of `cheat` is that it allows you to create your own cheatsheets - the
|
```
|
||||||
defaults are meant to serve only as a starting point, and can and should be
|
|
||||||
modified.
|
|
||||||
|
|
||||||
Cheatsheets are stored in the `~/.cheat/` directory, and are named on a
|
To list all cheatsheets on the "personal" path:
|
||||||
per-keyphrase basis. In other words, the content for the `tar` cheatsheet lives
|
|
||||||
in the `~/.cheat/tar` file.
|
|
||||||
|
|
||||||
Provided that you have an `EDITOR` environment variable set, you may edit
|
```sh
|
||||||
cheatsheets with:
|
cheat -l -p personal
|
||||||
|
```
|
||||||
|
|
||||||
cheat -e foo
|
To search for the phrase "ssh" among cheatsheets:
|
||||||
|
|
||||||
If the 'foo' cheatsheet already exists, it will be opened for editing.
|
```sh
|
||||||
Otherwise, it will be created automatically.
|
cheat -s ssh
|
||||||
|
```
|
||||||
|
|
||||||
After you've customized your cheatsheets, I urge you to track `~/.cheat/` along
|
To search (by regex) for cheatsheets that contain an IP address:
|
||||||
with your [dotfiles][].
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cheat -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
||||||
|
```
|
||||||
|
|
||||||
Configuring
|
Flags may be combined in intuitive ways. Example: to search sheets on the
|
||||||
-----------
|
"personal" cheatpath that are tagged with "networking" and match a regex:
|
||||||
|
|
||||||
### Setting a DEFAULT_CHEAT_DIR ###
|
```sh
|
||||||
Personal cheatsheets are saved in the `~/.cheat` directory by default, but you
|
cheat -p personal -t networking --regex -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
||||||
can specify a different default by exporting a `DEFAULT_CHEAT_DIR` environment
|
```
|
||||||
variable:
|
|
||||||
|
|
||||||
export DEFAULT_CHEAT_DIR=/path/to/my/cheats
|
## Cheatsheets
|
||||||
|
Cheatsheets are plain-text files with no file extension, and are named
|
||||||
|
according to the command used to view them:
|
||||||
|
|
||||||
### Setting a CHEATPATH ###
|
```sh
|
||||||
You can additionally instruct `cheat` to look for cheatsheets in other
|
cheat tar # file is named "tar"
|
||||||
directories by exporting a `CHEATPATH` environment variable:
|
cheat foo/bar # file is named "bar", in a "foo" subdirectory
|
||||||
|
```
|
||||||
|
|
||||||
export CHEATPATH=/path/to/my/cheats
|
Cheatsheet text may optionally be preceded by a YAML frontmatter header that
|
||||||
|
assigns tags and specifies syntax:
|
||||||
|
|
||||||
You may, of course, append multiple directories to your `CHEATPATH`:
|
```
|
||||||
|
---
|
||||||
|
syntax: javascript
|
||||||
|
tags: [ array, map ]
|
||||||
|
---
|
||||||
|
// To map over an array:
|
||||||
|
const squares = [1, 2, 3, 4].map(x => x * x);
|
||||||
|
```
|
||||||
|
|
||||||
export CHEATPATH=$CHEATPATH:/path/to/more/cheats
|
Syntax highlighting is provided by [Chroma][], and the `syntax` value may be
|
||||||
|
set to any lexer name that Chroma supports. See Chroma's [supported
|
||||||
|
languages][] for a complete list.
|
||||||
|
|
||||||
You may view which directories are on your `CHEATPATH` with `cheat -d`.
|
The `cheat` executable includes no cheatsheets, but [community-sourced
|
||||||
|
cheatsheets are available][cheatsheets]. You will be asked if you would like to
|
||||||
|
install the community-sourced cheatsheets the first time you run `cheat`.
|
||||||
|
|
||||||
### Enabling Syntax Highlighting ###
|
## Cheatpaths
|
||||||
`cheat` can apply syntax highlighting to your cheatsheets if so desired. To
|
Cheatsheets are stored on "cheatpaths", which are directories that contain
|
||||||
enable this feature, set a `CHEATCOLORS` environment variable:
|
cheatsheets. Cheatpaths are specified in the `conf.yml` file.
|
||||||
|
|
||||||
export CHEATCOLORS=true
|
It can be useful to configure `cheat` against multiple cheatpaths. A common
|
||||||
|
pattern is to store cheatsheets from multiple repositories on individual
|
||||||
|
cheatpaths:
|
||||||
|
|
||||||
### Enabling Command-line Autocompletion ###
|
```yaml
|
||||||
The `cheat/autocompletion` directory contains scripts to enable command-line
|
# conf.yml:
|
||||||
autocompletion for various shells. To activate autocompletion, simply copy the
|
# ...
|
||||||
appropriate script to the appropriate path on your system. (The "appropriate
|
cheatpaths:
|
||||||
path" will vary on a per-platform basis, so this documentation shall not
|
- name: community # a name for the cheatpath
|
||||||
speculate as to where that may be.)
|
path: ~/documents/cheat/community # the path's location on the filesystem
|
||||||
|
tags: [ community ] # these tags will be applied to all sheets on the path
|
||||||
|
readonly: true # if true, `cheat` will not create new cheatsheets here
|
||||||
|
|
||||||
|
- name: personal
|
||||||
|
path: ~/documents/cheat/personal # this is a separate directory and repository than above
|
||||||
|
tags: [ personal ]
|
||||||
|
readonly: false # new sheets may be written here
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
Related Projects
|
The `readonly` option instructs `cheat` not to edit (or create) any cheatsheets
|
||||||
----------------
|
on the path. This is useful to prevent merge-conflicts from arising on upstream
|
||||||
|
cheatsheet repositories.
|
||||||
|
|
||||||
- [lucaswerkmeister/cheats][1]: An implementation of this concept in pure bash
|
If a user attempts to edit a cheatsheet on a read-only cheatpath, `cheat` will
|
||||||
that also allows not only for numerical indexing of subcomands but also
|
transparently copy that sheet to a writeable directory before opening it for
|
||||||
supports running commands interactively.
|
editing.
|
||||||
|
|
||||||
- [jahendrie/cheat][2]: A bash-only implementation that additionally allows for
|
### Directory-scoped Cheatpaths
|
||||||
cheatsheets to be created and `grep` searched from the command-line.
|
At times, it can be useful to closely associate cheatsheets with a directory on
|
||||||
([jahendrie][] contributed key ideas to this project as well.)
|
your filesystem. `cheat` facilitates this by searching for a `.cheat` directory
|
||||||
|
in the current working directory and its ancestors (similar to how `git` locates
|
||||||
|
`.git` directories). The nearest `.cheat` directory found will (temporarily) be
|
||||||
|
added to the cheatpaths. This means you can place a `.cheat` directory at your
|
||||||
|
project root and it will be available from any subdirectory within that project.
|
||||||
|
|
||||||
- [`cheat` RubyGem][3]: A clever gem from 2006 that clearly had similar
|
## Autocompletion
|
||||||
motivations. It is unclear whether or not it is currently maintained.
|
`cheat` can generate shell completion scripts for `bash`, `zsh`, `fish`, and
|
||||||
|
`powershell` via the `--completion` flag:
|
||||||
|
|
||||||
- [`tldr`][tldr]: "Simplified and community-driven man pages".
|
```sh
|
||||||
|
cheat --completion bash
|
||||||
|
cheat --completion zsh
|
||||||
|
cheat --completion fish
|
||||||
|
cheat --completion powershell
|
||||||
|
```
|
||||||
|
|
||||||
|
Pipe the output to the appropriate location for your shell. For example:
|
||||||
|
|
||||||
[dotfiles]: http://dotfiles.github.io/
|
```sh
|
||||||
[jahendrie]: https://github.com/jahendrie
|
# bash (user-local)
|
||||||
[1]: https://github.com/lucaswerkmeister/cheats
|
mkdir -p ~/.local/share/bash-completion/completions
|
||||||
[2]: https://github.com/jahendrie/cheat
|
cheat --completion bash > ~/.local/share/bash-completion/completions/cheat
|
||||||
[3]: http://errtheblog.com/posts/21-cheat
|
|
||||||
[4]: https://github.com/chrisallenlane/cheat/pull/77
|
# bash (system-wide)
|
||||||
[tldr]: https://github.com/tldr-pages/tldr
|
cheat --completion bash > /etc/bash_completion.d/cheat
|
||||||
|
|
||||||
|
# zsh (ensure the directory is on your fpath)
|
||||||
|
cheat --completion zsh > "${fpath[1]}/_cheat"
|
||||||
|
|
||||||
|
# fish
|
||||||
|
cheat --completion fish > ~/.config/fish/completions/cheat.fish
|
||||||
|
```
|
||||||
|
|
||||||
|
Completions are dynamically generated and include cheatsheet names, tags, and
|
||||||
|
cheatpath names.
|
||||||
|
|
||||||
|
[INSTALLING.md]: INSTALLING.md
|
||||||
|
[Releases]: https://github.com/cheat/cheat/releases
|
||||||
|
[cheatsheets]: https://github.com/cheat/cheatsheets
|
||||||
|
[Chroma]: https://github.com/alecthomas/chroma
|
||||||
|
[supported languages]: https://github.com/alecthomas/chroma#supported-languages
|
||||||
|
|||||||
169
adr/001-path-traversal-protection.md
Normal file
169
adr/001-path-traversal-protection.md
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
# ADR-001: Path Traversal Protection for Cheatsheet Names
|
||||||
|
|
||||||
|
Date: 2025-01-21
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
Accepted
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
The `cheat` tool allows users to create, edit, and remove cheatsheets using commands like:
|
||||||
|
- `cheat --edit <name>`
|
||||||
|
- `cheat --rm <name>`
|
||||||
|
|
||||||
|
Without validation, a user could potentially provide malicious names like:
|
||||||
|
- `../../../etc/passwd` (directory traversal)
|
||||||
|
- `/etc/passwd` (absolute path)
|
||||||
|
- `~/.ssh/authorized_keys` (home directory expansion)
|
||||||
|
|
||||||
|
While `cheat` is a local tool run by the user themselves (not a network service), path traversal could still lead to:
|
||||||
|
1. Accidental file overwrites outside cheatsheet directories
|
||||||
|
2. Confusion about where files are being created
|
||||||
|
3. Potential security issues in shared environments
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
We implemented input validation for cheatsheet names to prevent directory traversal attacks. The validation rejects names that:
|
||||||
|
|
||||||
|
1. Contain `..` (parent directory references)
|
||||||
|
2. Are absolute paths (start with `/` on Unix)
|
||||||
|
3. Start with `~` (home directory expansion)
|
||||||
|
4. Are empty
|
||||||
|
5. Start with `.` (hidden files - these are not displayed by cheat)
|
||||||
|
|
||||||
|
The validation is performed at the application layer before any file operations occur.
|
||||||
|
|
||||||
|
## Implementation Details
|
||||||
|
|
||||||
|
### Validation Function
|
||||||
|
|
||||||
|
The validation is implemented in `internal/sheet/validate.go`:
|
||||||
|
|
||||||
|
```go
|
||||||
|
func Validate(name string) error {
|
||||||
|
// Reject empty names
|
||||||
|
if name == "" {
|
||||||
|
return fmt.Errorf("cheatsheet name cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reject names containing directory traversal
|
||||||
|
if strings.Contains(name, "..") {
|
||||||
|
return fmt.Errorf("cheatsheet name cannot contain '..'")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reject absolute paths
|
||||||
|
if filepath.IsAbs(name) {
|
||||||
|
return fmt.Errorf("cheatsheet name cannot be an absolute path")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reject names that start with ~ (home directory expansion)
|
||||||
|
if strings.HasPrefix(name, "~") {
|
||||||
|
return fmt.Errorf("cheatsheet name cannot start with '~'")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reject hidden files (files that start with a dot)
|
||||||
|
filename := filepath.Base(name)
|
||||||
|
if strings.HasPrefix(filename, ".") {
|
||||||
|
return fmt.Errorf("cheatsheet name cannot start with '.' (hidden files are not supported)")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Integration Points
|
||||||
|
|
||||||
|
The validation is called in:
|
||||||
|
- `cmd/cheat/cmd_edit.go` - before creating or editing a cheatsheet
|
||||||
|
- `cmd/cheat/cmd_remove.go` - before removing a cheatsheet
|
||||||
|
|
||||||
|
### Allowed Patterns
|
||||||
|
|
||||||
|
The following patterns are explicitly allowed:
|
||||||
|
- Simple names: `docker`, `git`
|
||||||
|
- Nested paths: `docker/compose`, `lang/go/slice`
|
||||||
|
- Current directory references: `./mysheet`
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
### Positive
|
||||||
|
|
||||||
|
1. **Safety**: Prevents accidental or intentional file operations outside cheatsheet directories
|
||||||
|
2. **Simplicity**: Validation happens early, before any file operations
|
||||||
|
3. **User-friendly**: Clear error messages explain why a name was rejected
|
||||||
|
4. **Performance**: Minimal overhead - simple string checks
|
||||||
|
5. **Compatibility**: Doesn't break existing valid cheatsheet names
|
||||||
|
|
||||||
|
### Negative
|
||||||
|
|
||||||
|
1. **Limitation**: Users cannot use `..` in cheatsheet names even if legitimate
|
||||||
|
2. **No symlink support**: Cannot create cheatsheets through symlinks outside the cheatpath
|
||||||
|
|
||||||
|
### Neutral
|
||||||
|
|
||||||
|
1. Uses Go's `filepath.IsAbs()` which handles platform differences (Windows vs Unix)
|
||||||
|
2. No attempt to resolve or canonicalize paths - validation is purely syntactic
|
||||||
|
|
||||||
|
## Security Considerations
|
||||||
|
|
||||||
|
### Threat Model
|
||||||
|
|
||||||
|
`cheat` is a local command-line tool, not a network service. The primary threats are:
|
||||||
|
- User error (accidentally overwriting important files)
|
||||||
|
- Malicious scripts that invoke `cheat` with crafted arguments
|
||||||
|
- Shared system scenarios where cheatsheets might be shared
|
||||||
|
|
||||||
|
### What This Protects Against
|
||||||
|
|
||||||
|
- Directory traversal using `../`
|
||||||
|
- Absolute path access to system files
|
||||||
|
- Shell expansion of `~` to home directory
|
||||||
|
- Empty names that might cause unexpected behavior
|
||||||
|
- Hidden files that wouldn't be displayed anyway
|
||||||
|
|
||||||
|
### What This Does NOT Protect Against
|
||||||
|
|
||||||
|
- Users with filesystem permissions can still directly edit any file
|
||||||
|
- Symbolic links within the cheatpath pointing outside
|
||||||
|
- Race conditions (TOCTOU) - though minimal risk for a local tool
|
||||||
|
- Malicious content within cheatsheets themselves
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
Comprehensive tests ensure the validation works correctly:
|
||||||
|
|
||||||
|
1. **Unit tests** (`internal/sheet/validate_test.go`) verify the validation logic
|
||||||
|
2. **Integration tests** verify the actual binary blocks malicious inputs
|
||||||
|
3. **No system files are accessed** during testing - all tests use isolated directories
|
||||||
|
|
||||||
|
Example test cases:
|
||||||
|
```bash
|
||||||
|
# These are blocked:
|
||||||
|
cheat --edit "../../../etc/passwd"
|
||||||
|
cheat --edit "/etc/passwd"
|
||||||
|
cheat --edit "~/.ssh/config"
|
||||||
|
cheat --rm ".."
|
||||||
|
|
||||||
|
# These are allowed:
|
||||||
|
cheat --edit "docker"
|
||||||
|
cheat --edit "docker/compose"
|
||||||
|
cheat --edit "./local"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Alternative Approaches Considered
|
||||||
|
|
||||||
|
1. **Path resolution and verification**: Resolve the final path and check if it's within the cheatpath
|
||||||
|
- Rejected: More complex, potential race conditions, platform-specific edge cases
|
||||||
|
|
||||||
|
2. **Chroot/sandbox**: Run file operations in a restricted environment
|
||||||
|
- Rejected: Overkill for a local tool, platform compatibility issues
|
||||||
|
|
||||||
|
3. **Filename allowlist**: Only allow alphanumeric characters and specific symbols
|
||||||
|
- Rejected: Too restrictive, would break existing cheatsheets with valid special characters
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- OWASP Path Traversal: https://owasp.org/www-community/attacks/Path_Traversal
|
||||||
|
- CWE-22: Improper Limitation of a Pathname to a Restricted Directory
|
||||||
|
- Go filepath package documentation: https://pkg.go.dev/path/filepath
|
||||||
100
adr/002-environment-variable-parsing.md
Normal file
100
adr/002-environment-variable-parsing.md
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
# ADR-002: No Defensive Checks for Environment Variable Parsing
|
||||||
|
|
||||||
|
Date: 2025-01-21
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
Accepted
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
In the `envVars()` function in `cmd/cheat/main.go`, the code parses environment variables assuming they all contain an equals sign:
|
||||||
|
|
||||||
|
```go
|
||||||
|
for _, e := range os.Environ() {
|
||||||
|
pair := strings.SplitN(e, "=", 2)
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
pair[0] = strings.ToUpper(pair[0])
|
||||||
|
}
|
||||||
|
envvars[pair[0]] = pair[1] // Could panic if pair has < 2 elements
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If `os.Environ()` returned a string without an equals sign, `strings.SplitN` would return a slice with only one element, causing a panic when accessing `pair[1]`.
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
We will **not** add defensive checks for this condition. The current code that assumes all environment strings contain "=" will remain unchanged.
|
||||||
|
|
||||||
|
## Rationale
|
||||||
|
|
||||||
|
### Go Runtime Guarantees
|
||||||
|
|
||||||
|
Go's official documentation guarantees that `os.Environ()` returns environment variables in the form "key=value". This is a documented contract of the Go runtime that has been stable since Go 1.0.
|
||||||
|
|
||||||
|
### Empirical Evidence
|
||||||
|
|
||||||
|
Testing across platforms confirms:
|
||||||
|
- All environment variables returned by `os.Environ()` contain at least one "="
|
||||||
|
- Empty environment variables appear as "KEY=" (with an empty value)
|
||||||
|
- Even Windows special variables like "=C:=C:\path" maintain the format
|
||||||
|
|
||||||
|
### Cost-Benefit Analysis
|
||||||
|
|
||||||
|
Adding defensive code would:
|
||||||
|
- **Cost**: Add complexity and cognitive overhead
|
||||||
|
- **Cost**: Suggest uncertainty about Go's documented behavior
|
||||||
|
- **Cost**: Create dead code that can never execute under normal conditions
|
||||||
|
- **Benefit**: Protect against a theoretical scenario that violates Go's guarantees
|
||||||
|
|
||||||
|
The only scenarios where this could panic are:
|
||||||
|
1. A bug in Go's runtime (extremely unlikely, would affect all Go programs)
|
||||||
|
2. Corrupted OS-level environment (would cause broader system issues)
|
||||||
|
3. Breaking change in future Go version (would break many programs, unlikely)
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
### Positive
|
||||||
|
- Simpler, more readable code
|
||||||
|
- Trust in platform guarantees reduces unnecessary defensive programming
|
||||||
|
- No performance overhead from unnecessary checks
|
||||||
|
|
||||||
|
### Negative
|
||||||
|
- Theoretical panic if Go's guarantees are violated
|
||||||
|
|
||||||
|
### Neutral
|
||||||
|
- Follows Go community standards of trusting standard library contracts
|
||||||
|
|
||||||
|
## Alternatives Considered
|
||||||
|
|
||||||
|
### 1. Add Defensive Check
|
||||||
|
```go
|
||||||
|
if len(pair) < 2 {
|
||||||
|
continue // or pair[1] = ""
|
||||||
|
}
|
||||||
|
```
|
||||||
|
**Rejected**: Adds complexity for a condition that should never occur.
|
||||||
|
|
||||||
|
### 2. Add Panic with Clear Message
|
||||||
|
```go
|
||||||
|
if len(pair) < 2 {
|
||||||
|
panic("os.Environ() contract violation: " + e)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
**Rejected**: Would crash the program for the same theoretical issue.
|
||||||
|
|
||||||
|
### 3. Add Comment Documenting Assumption
|
||||||
|
```go
|
||||||
|
// os.Environ() guarantees "key=value" format, so pair[1] is safe
|
||||||
|
envvars[pair[0]] = pair[1]
|
||||||
|
```
|
||||||
|
**Rejected**: While documentation is good, this particular guarantee is fundamental to Go.
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
If Go ever changes this behavior (extremely unlikely as it would break compatibility), it would be caught immediately in testing as the program would panic on startup. This would be a clear signal to revisit this decision.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- Go os.Environ() documentation: https://pkg.go.dev/os#Environ
|
||||||
|
- Go os.Environ() source code and tests
|
||||||
104
adr/003-search-parallelization.md
Normal file
104
adr/003-search-parallelization.md
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
# ADR-003: No Parallelization for Search Operations
|
||||||
|
|
||||||
|
Date: 2025-01-22
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
Accepted
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
We investigated optimizing cheat's search performance through parallelization. Initial assumptions suggested that I/O operations (reading multiple cheatsheet files) would be the primary bottleneck, making parallel processing beneficial.
|
||||||
|
|
||||||
|
Performance benchmarks were implemented to measure search operations, and a parallel search implementation using goroutines was created and tested.
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
We will **not** implement parallel search. The sequential implementation will remain unchanged.
|
||||||
|
|
||||||
|
## Rationale
|
||||||
|
|
||||||
|
### Performance Profile Analysis
|
||||||
|
|
||||||
|
CPU profiling revealed that search performance is dominated by:
|
||||||
|
- **Process creation overhead** (~30% in `os/exec.(*Cmd).Run`)
|
||||||
|
- **System calls** (~30% in `syscall.Syscall6`)
|
||||||
|
- **Process management** (fork, exec, pipe setup)
|
||||||
|
|
||||||
|
The actual search logic (regex matching, file reading) was negligible in the profile, indicating our optimization efforts were targeting the wrong bottleneck.
|
||||||
|
|
||||||
|
### Benchmark Results
|
||||||
|
|
||||||
|
Parallel implementation showed minimal improvements:
|
||||||
|
- Simple search: 17ms → 15.3ms (10% improvement)
|
||||||
|
- Regex search: 15ms → 14.9ms (minimal improvement)
|
||||||
|
- Colorized search: 19.5ms → 16.8ms (14% improvement)
|
||||||
|
- Complex regex: 20ms → 15.3ms (24% improvement)
|
||||||
|
|
||||||
|
The best case saved only ~5ms in absolute terms.
|
||||||
|
|
||||||
|
### Cost-Benefit Analysis
|
||||||
|
|
||||||
|
**Costs of parallelization:**
|
||||||
|
- Added complexity with goroutines, channels, and synchronization
|
||||||
|
- Increased maintenance burden
|
||||||
|
- More difficult debugging and testing
|
||||||
|
- Potential race conditions
|
||||||
|
|
||||||
|
**Benefits:**
|
||||||
|
- 5-15% performance improvement (5ms in real terms)
|
||||||
|
- Imperceptible to users in interactive use
|
||||||
|
|
||||||
|
### User Experience Perspective
|
||||||
|
|
||||||
|
For a command-line tool:
|
||||||
|
- Current 15-20ms response time is excellent
|
||||||
|
- Users cannot perceive 5ms differences
|
||||||
|
- Sub-50ms is considered "instant" in HCI research
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
### Positive
|
||||||
|
- Simpler, more maintainable codebase
|
||||||
|
- Easier to debug and reason about
|
||||||
|
- No synchronization bugs or race conditions
|
||||||
|
- Focus remains on code clarity
|
||||||
|
|
||||||
|
### Negative
|
||||||
|
- Missed opportunity for ~5ms performance gain
|
||||||
|
- Search remains single-threaded
|
||||||
|
|
||||||
|
### Neutral
|
||||||
|
- Performance remains excellent for intended use case
|
||||||
|
- Follows Go philosophy of preferring simplicity
|
||||||
|
|
||||||
|
## Alternatives Considered
|
||||||
|
|
||||||
|
### 1. Keep Parallel Implementation
|
||||||
|
**Rejected**: Complexity outweighs negligible performance gains.
|
||||||
|
|
||||||
|
### 2. Optimize Process Startup
|
||||||
|
**Rejected**: Process creation overhead is inherent to CLI tools and cannot be avoided without fundamental architecture changes.
|
||||||
|
|
||||||
|
### 3. Future Optimizations
|
||||||
|
If performance becomes critical, consider:
|
||||||
|
- **Long-running daemon**: Eliminate process startup overhead entirely
|
||||||
|
- **Shell function**: Reduce fork/exec overhead
|
||||||
|
- **Compiled-in cheatsheets**: Eliminate file I/O
|
||||||
|
|
||||||
|
However, these would fundamentally change the tool's architecture and usage model.
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
This decision reinforces important principles:
|
||||||
|
1. Always profile before optimizing
|
||||||
|
2. Consider the full execution context
|
||||||
|
3. Measure what matters to users
|
||||||
|
4. Complexity has a real cost
|
||||||
|
|
||||||
|
The parallelization attempt was valuable as a learning exercise and definitively answered whether this optimization path was worthwhile.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- Benchmark implementation: test/integration/search_bench_test.go
|
||||||
|
- Reverted parallel implementation: see git history (commit 82eb918)
|
||||||
80
adr/004-recursive-cheat-directory-search.md
Normal file
80
adr/004-recursive-cheat-directory-search.md
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
# ADR-004: Recursive `.cheat` Directory Search
|
||||||
|
|
||||||
|
Date: 2026-02-15
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
Accepted
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
Previously, `cheat` only checked the current working directory for a `.cheat`
|
||||||
|
subdirectory to use as a directory-scoped cheatpath. If a user was in
|
||||||
|
`~/projects/myapp/src/handlers/` but the `.cheat` directory lived at
|
||||||
|
`~/projects/myapp/.cheat`, it would not be found. Users requested (#602) that
|
||||||
|
`cheat` walk up the directory hierarchy to find the nearest `.cheat`
|
||||||
|
directory, mirroring the discovery pattern used by `git` for `.git`
|
||||||
|
directories.
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
Walk upward from the current working directory to the filesystem root, and
|
||||||
|
stop at the first `.cheat` directory found. Only directories are matched (a
|
||||||
|
file named `.cheat` is ignored).
|
||||||
|
|
||||||
|
### Stop at first `.cheat` found
|
||||||
|
|
||||||
|
Rather than collecting multiple `.cheat` directories from ancestor directories:
|
||||||
|
|
||||||
|
- Matches `.git` discovery semantics, which users already understand
|
||||||
|
- Fits the existing single-cheatpath-named-`"cwd"` code without structural
|
||||||
|
changes
|
||||||
|
- Avoids precedence and naming complexity when multiple `.cheat` directories
|
||||||
|
exist in the ancestor chain
|
||||||
|
- `cheat` already supports multiple cheatpaths via `conf.yml` for users who
|
||||||
|
want that; directory-scoped `.cheat` serves the project-context use case
|
||||||
|
|
||||||
|
### Walk to filesystem root (not `$HOME`)
|
||||||
|
|
||||||
|
Rather than stopping the search at `$HOME`:
|
||||||
|
|
||||||
|
- Simpler implementation with no platform-specific home-directory detection
|
||||||
|
- Supports sysadmins working in `/etc`, `/srv`, `/var`, or other paths
|
||||||
|
outside `$HOME`
|
||||||
|
- The boundary only matters on the failure path (no `.cheat` found anywhere),
|
||||||
|
where the cost is a few extra `stat` calls
|
||||||
|
- Security is not a concern since cheatsheets are display-only text, not
|
||||||
|
executable code
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
### Positive
|
||||||
|
- Users can place `.cheat` at their project root and it works from any
|
||||||
|
subdirectory, matching their mental model
|
||||||
|
- No configuration changes needed; existing `.cheat` directories continue to
|
||||||
|
work identically
|
||||||
|
- Minimal code change (one small helper function)
|
||||||
|
|
||||||
|
### Negative
|
||||||
|
- A `.cheat` directory in an unexpected ancestor could be picked up
|
||||||
|
unintentionally, though this is unlikely in practice and matches how `.git`
|
||||||
|
works
|
||||||
|
|
||||||
|
### Neutral
|
||||||
|
- The cheatpath name remains `"cwd"` regardless of which ancestor the `.cheat`
|
||||||
|
was found in
|
||||||
|
|
||||||
|
## Alternatives Considered
|
||||||
|
|
||||||
|
### 1. Stop at `$HOME`
|
||||||
|
**Rejected**: Adds platform-specific complexity for minimal benefit. The only
|
||||||
|
downside of walking to root is a few extra `stat` calls on the failure path.
|
||||||
|
|
||||||
|
### 2. Collect multiple `.cheat` directories
|
||||||
|
**Rejected**: Introduces precedence and naming complexity. Users who want
|
||||||
|
multiple cheatpaths can configure them in `conf.yml`.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- GitHub issue: #602
|
||||||
|
- Implementation: `findLocalCheatpath()` in `internal/config/config.go`
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from . import sheet
|
|
||||||
from . import sheets
|
|
||||||
from . import utils
|
|
||||||
65
cheat/app.py
65
cheat/app.py
@@ -1,65 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
"""cheat
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
cheat <cheatsheet>
|
|
||||||
cheat -e <cheatsheet>
|
|
||||||
cheat -s <keyword>
|
|
||||||
cheat -l
|
|
||||||
cheat -d
|
|
||||||
cheat -v
|
|
||||||
|
|
||||||
cheat allows you to create and view interactive cheatsheets on the
|
|
||||||
command-line. It was designed to help remind *nix system
|
|
||||||
administrators of options for commands that they use frequently,
|
|
||||||
but not frequently enough to remember.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
To look up 'tar':
|
|
||||||
cheat tar
|
|
||||||
|
|
||||||
To create or edit the cheatsheet for 'foo':
|
|
||||||
cheat -e foo
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-d --directories List directories on CHEATPATH
|
|
||||||
-e --edit Edit cheatsheet
|
|
||||||
-l --list List cheatsheets
|
|
||||||
-s --search Search cheatsheets for <keyword>
|
|
||||||
-v --version Print the version number
|
|
||||||
"""
|
|
||||||
|
|
||||||
# require the dependencies
|
|
||||||
import sheet
|
|
||||||
import sheets
|
|
||||||
from utils import *
|
|
||||||
from docopt import docopt
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
# parse the command-line options
|
|
||||||
options = docopt(__doc__, version='cheat 2.1.17')
|
|
||||||
|
|
||||||
# list directories
|
|
||||||
if options['--directories']:
|
|
||||||
print("\n".join(sheets.paths()))
|
|
||||||
|
|
||||||
# list cheatsheets
|
|
||||||
elif options['--list']:
|
|
||||||
print(sheets.list())
|
|
||||||
|
|
||||||
# create/edit cheatsheet
|
|
||||||
elif options['--edit']:
|
|
||||||
sheet.create_or_edit(options['<cheatsheet>'])
|
|
||||||
|
|
||||||
# search among the cheatsheets
|
|
||||||
elif options['--search']:
|
|
||||||
print(colorize(sheets.search(options['<keyword>'])))
|
|
||||||
|
|
||||||
# print the cheatsheet
|
|
||||||
else:
|
|
||||||
print(colorize(sheet.read(options['<cheatsheet>'])))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
function _cheat_autocomplete {
|
|
||||||
sheets=$(cheat -l | cut -d' ' -f1)
|
|
||||||
COMPREPLY=()
|
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
|
||||||
COMPREPLY=(`compgen -W "$sheets" -- $2`)
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
complete -F _cheat_autocomplete cheat
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#completion for cheat
|
|
||||||
complete -c cheat -s h -l help -f -x --description "Display help and exit"
|
|
||||||
complete -c cheat -l edit -f -x --description "Edit <cheatsheet>"
|
|
||||||
complete -c cheat -s e -f -x --description "Edit <cheatsheet>"
|
|
||||||
complete -c cheat -s l -l list -f -x --description "List all available cheatsheets"
|
|
||||||
complete -c cheat -s d -l cheat-directories -f -x --description "List all current cheat dirs"
|
|
||||||
complete -c cheat --authoritative -f
|
|
||||||
for cheatsheet in (cheat -l | cut -d' ' -f1)
|
|
||||||
complete -c cheat -a "$cheatsheet"
|
|
||||||
complete -c cheat -o e -a "$cheatsheet"
|
|
||||||
complete -c cheat -o '-edit' -a "$cheatsheet"
|
|
||||||
end
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#compdef cheat
|
|
||||||
|
|
||||||
declare -a cheats
|
|
||||||
cheats=$(cheat -l | cut -d' ' -f1)
|
|
||||||
_arguments "1:cheats:(${cheats})" && return 0
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
7z
|
|
||||||
A file archiver with highest compression ratio
|
|
||||||
|
|
||||||
Args:
|
|
||||||
a add
|
|
||||||
d delete
|
|
||||||
e extract
|
|
||||||
l list
|
|
||||||
t test
|
|
||||||
u update
|
|
||||||
x extract with full paths
|
|
||||||
|
|
||||||
Example:
|
|
||||||
7z a -t7z -m0-lzma -mx=9 -mfb=64 -md=32m -ms=on archive.7z dir1
|
|
||||||
|
|
||||||
-t7z 7z archive
|
|
||||||
-m0=lzma lzma method
|
|
||||||
-mx=9 level of compression = 9 (ultra)
|
|
||||||
-mfb=64 number of fast bytes for lzma = 64
|
|
||||||
-md=32m dictionary size = 32 Mb
|
|
||||||
-ms=on solid archive = on
|
|
||||||
|
|
||||||
7z exit codes:
|
|
||||||
0 normal (no errors or warnings)
|
|
||||||
1 warning (non-fatal errors)
|
|
||||||
2 fatal error
|
|
||||||
7 bad cli arguments
|
|
||||||
8 not enough memory for operation
|
|
||||||
255 process was interrupted
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
def sheets_dir():
|
|
||||||
return os.path.split(__file__)
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# send 100 requests with a concurency of 50 requests to an URL
|
|
||||||
ab -n 100 -c 50 http://www.example.com/
|
|
||||||
|
|
||||||
# send requests during 30 seconds with a concurency of 50 requests to an URL
|
|
||||||
ab -t 30 -c 50 URL http://www.example.com/
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Install a package
|
|
||||||
apk add $package
|
|
||||||
|
|
||||||
# Remove a package
|
|
||||||
apk del $package
|
|
||||||
|
|
||||||
# Update repos
|
|
||||||
apk update
|
|
||||||
|
|
||||||
# Upgrade all packages
|
|
||||||
apk upgrade
|
|
||||||
|
|
||||||
# Find a package
|
|
||||||
apk search $package
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# Desc: Apparmor will protect the system by confining programs to a limited set of resources.
|
|
||||||
|
|
||||||
# To activate a profile:
|
|
||||||
sudo aa-enforce usr.bin.firefox
|
|
||||||
# OR
|
|
||||||
export _PROFILE_='usr.bin.firefox' sudo $(rm /etc/apparmor.d/disable/$_PROFILE_ ; cat /etc/apparmor.d/$_PROFILE_ | apparmor_parser -a )
|
|
||||||
|
|
||||||
# TO disable a profile:
|
|
||||||
sudo aa-disable usr.bin.firefox
|
|
||||||
# OR
|
|
||||||
export _PROFILE_='usr.bin.firefox' sudo $(ln -s /etc/apparmor.d/$_PROFILE_ /etc/apparmor.d/disable/ && apparmor_parser -R /etc/apparmor.d/$_PROFILE_)
|
|
||||||
|
|
||||||
# To list profiles loaded:
|
|
||||||
sudo aa-status
|
|
||||||
# OR
|
|
||||||
sudo apparmor_status
|
|
||||||
|
|
||||||
# List of profiles aviables: /etc/apparmor.d/
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
# To search for apt packages:
|
|
||||||
apt-cache search "whatever"
|
|
||||||
|
|
||||||
# To display package records for the named package(s):
|
|
||||||
apt-cache show pkg(s)
|
|
||||||
|
|
||||||
# To display reverse dependencies of a package
|
|
||||||
apt-cache rdepends package_name
|
|
||||||
|
|
||||||
# To display package versions, reverse dependencies and forward dependencies
|
|
||||||
# of a package
|
|
||||||
apt-cache showpkg package_name
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# Desc: Allows to update the operating system
|
|
||||||
|
|
||||||
# To fetch package list
|
|
||||||
apt-get update
|
|
||||||
|
|
||||||
# To download and install updates without installing new package.
|
|
||||||
apt-get upgrade
|
|
||||||
|
|
||||||
# To download and install the updates AND install new necessary packages
|
|
||||||
apt-get dist-upgrade
|
|
||||||
|
|
||||||
# Full command:
|
|
||||||
apt-get update && apt-get dist-upgrade
|
|
||||||
|
|
||||||
# To install a new package(s)
|
|
||||||
apt-get install package(s)
|
|
||||||
|
|
||||||
# Download a package without installing it. (The package will be downloaded in your current working dir)
|
|
||||||
apt-get download modsecurity-crs
|
|
||||||
|
|
||||||
# Change Cache dir and archive dir (where .deb are stored).
|
|
||||||
apt-get -o Dir::Cache="/path/to/destination/dir/" -o Dir::Cache::archives="./" install ...
|
|
||||||
|
|
||||||
# Show apt-get installed packages.
|
|
||||||
grep 'install ' /var/log/dpkg.log
|
|
||||||
|
|
||||||
# Silently keep old configuration during batch updates
|
|
||||||
apt-get update -o DPkg::Options::='--force-confold' ...
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# To search for packages:
|
|
||||||
aptitude search "whatever"
|
|
||||||
|
|
||||||
# To display package records for the named package(s):
|
|
||||||
aptitude show pkg(s)
|
|
||||||
|
|
||||||
# To install a package:
|
|
||||||
aptitude install package
|
|
||||||
|
|
||||||
# To remove a package:
|
|
||||||
aptitude remove package
|
|
||||||
|
|
||||||
# To remove unnecessary package:
|
|
||||||
aptitude autoclean
|
|
||||||
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# To show some text in ASCII Art:
|
|
||||||
|
|
||||||
figlet Cheat
|
|
||||||
# ____ _ _
|
|
||||||
# / ___| |__ ___ __ _| |_
|
|
||||||
#| | | '_ \ / _ \/ _` | __|
|
|
||||||
#| |___| | | | __/ (_| | |_
|
|
||||||
# \____|_| |_|\___|\__,_|\__|
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
# To have some text with color and other options:
|
|
||||||
# Show with a border
|
|
||||||
toilet -F border Cheat
|
|
||||||
# Basic show (filled)
|
|
||||||
toilet Cheat
|
|
||||||
# mmm # m
|
|
||||||
# m" " # mm mmm mmm mm#mm
|
|
||||||
# # #" # #" # " # #
|
|
||||||
# # # # #"""" m"""# #
|
|
||||||
# "mmm" # # "#mm" "mm"# "mm
|
|
||||||
#
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# To connect to a running Asterisk session:
|
|
||||||
asterisk -rvvv
|
|
||||||
|
|
||||||
# To issue a command to Asterisk from the shell:
|
|
||||||
asterisk -rx "<command>"
|
|
||||||
|
|
||||||
# To originate an echo call from a SIP trunk on an Asterisk server, to a specified number:
|
|
||||||
asterisk -rx "channel originate SIP/<trunk>/<number> application echo"
|
|
||||||
|
|
||||||
# To print out the details of SIP accounts:
|
|
||||||
asterisk -rx "sip show peers"
|
|
||||||
|
|
||||||
# To print out the passwords of SIP accounts:
|
|
||||||
asterisk -rx "sip show users"
|
|
||||||
|
|
||||||
# To print out the current active channels:
|
|
||||||
asterisk -rx "core show channels"
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# To schedule a one time task
|
|
||||||
at {time}
|
|
||||||
{command 0}
|
|
||||||
{command 1}
|
|
||||||
Ctrl-d
|
|
||||||
|
|
||||||
# {time} can be either
|
|
||||||
now | midnight | noon | teatime (4pm)
|
|
||||||
HH:MM
|
|
||||||
now + N {minutes | hours | days | weeks}
|
|
||||||
MM/DD/YY
|
|
||||||
|
|
||||||
# To list pending jobs
|
|
||||||
atq
|
|
||||||
|
|
||||||
# To remove a job (use id from atq)
|
|
||||||
atrm {id}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# sum integers from a file or stdin, one integer per line:
|
|
||||||
printf '1\n2\n3\n' | awk '{ sum += $1} END {print sum}'
|
|
||||||
|
|
||||||
# using specific character as separator to sum integers from a file or stdin
|
|
||||||
printf '1:2:3' | awk -F ":" '{print $1+$2+$3}'
|
|
||||||
|
|
||||||
# print a multiplication table
|
|
||||||
seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}'
|
|
||||||
|
|
||||||
# Specify output separator character
|
|
||||||
printf '1 2 3' | awk 'BEGIN {OFS=":"}; {print $1,$2,$3}'
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
# To implement a for loop:
|
|
||||||
for file in *;
|
|
||||||
do
|
|
||||||
echo $file found;
|
|
||||||
done
|
|
||||||
|
|
||||||
# To implement a case command:
|
|
||||||
case "$1"
|
|
||||||
in
|
|
||||||
0) echo "zero found";;
|
|
||||||
1) echo "one found";;
|
|
||||||
2) echo "two found";;
|
|
||||||
3*) echo "something beginning with 3 found";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Turn on debugging:
|
|
||||||
set -x
|
|
||||||
|
|
||||||
# Turn off debugging:
|
|
||||||
set +x
|
|
||||||
|
|
||||||
# Retrieve N-th piped command exit status
|
|
||||||
printf 'foo' | fgrep 'foo' | sed 's/foo/bar/'
|
|
||||||
echo ${PIPESTATUS[0]} # replace 0 with N
|
|
||||||
|
|
||||||
# Lock file:
|
|
||||||
( set -o noclobber; echo > my.lock ) || echo 'Failed to create lock file'
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# Install a package locally
|
|
||||||
bower install <package-name>
|
|
||||||
|
|
||||||
# Install a package locally directly from github
|
|
||||||
bower install <user>/<repo>
|
|
||||||
|
|
||||||
# Install a specific package locally
|
|
||||||
bower install <package-name>#<version>
|
|
||||||
|
|
||||||
# Install a package locally and save installed package into bower.json
|
|
||||||
bower install <package-name> --save
|
|
||||||
|
|
||||||
# Retrieve info of a particular package
|
|
||||||
bower info <package-name>
|
|
||||||
|
|
||||||
# List local packages
|
|
||||||
bower list
|
|
||||||
|
|
||||||
# Search for a package by name
|
|
||||||
bower search <package-name>
|
|
||||||
|
|
||||||
# Update a package to their newest version
|
|
||||||
bower update <package-name>
|
|
||||||
|
|
||||||
# Remove a local package
|
|
||||||
bower uninstall <package-name>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# Add execute for all (myscript.sh)
|
|
||||||
chmod a+x myscript.sh
|
|
||||||
|
|
||||||
# Set user to read/write/execute, group/global to read only (myscript.sh), symbolic mode
|
|
||||||
chmod u=rwx, go=r myscript.sh
|
|
||||||
|
|
||||||
# Remove write from user/group/global (myscript.sh), symbolic mode
|
|
||||||
chmod a-w myscript.sh
|
|
||||||
|
|
||||||
# Remove read/write/execute from user/group/global (myscript.sh), symbolic mode
|
|
||||||
chmod = myscript.sh
|
|
||||||
|
|
||||||
# Set user to read/write and group/global read (myscript.sh), octal notation
|
|
||||||
chmod 644 myscript.sh
|
|
||||||
|
|
||||||
# Set user to read/write/execute and group/global read/execute (myscript.sh), octal notation
|
|
||||||
chmod 755 myscript.sh
|
|
||||||
|
|
||||||
# Set user/group/global to read/write (myscript.sh), octal notation
|
|
||||||
chmod 666 myscript.sh
|
|
||||||
|
|
||||||
# Roles
|
|
||||||
u - user (owner of the file)
|
|
||||||
g - group (members of file's group)
|
|
||||||
o - global (all users who are not owner and not part of group)
|
|
||||||
a - all (all 3 roles above)
|
|
||||||
|
|
||||||
# Numeric representations
|
|
||||||
7 - full (rwx)
|
|
||||||
6 - read and write (rw-)
|
|
||||||
5 - read and execute (r-x)
|
|
||||||
4 - read only (r--)
|
|
||||||
3 - write and execute (-wx)
|
|
||||||
2 - write only (-w-)
|
|
||||||
1 - execute only (--x)
|
|
||||||
0 - none (---)
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# Change file owner
|
|
||||||
chown user file
|
|
||||||
|
|
||||||
# Change file owner and group
|
|
||||||
chown user:group file
|
|
||||||
|
|
||||||
# Change owner recursively
|
|
||||||
chown -R user directory
|
|
||||||
|
|
||||||
# Change ownership to match another file
|
|
||||||
chown --reference=/path/to/ref_file file
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# To resize an image to a fixed width and proportional height:
|
|
||||||
convert original-image.jpg -resize 100x converted-image.jpg
|
|
||||||
|
|
||||||
# To resize an image to a fixed height and proportional width:
|
|
||||||
convert original-image.jpg -resize x100 converted-image.jpg
|
|
||||||
|
|
||||||
# To resize an image to a fixed width and height:
|
|
||||||
convert original-image.jpg -resize 100x100 converted-image.jpg
|
|
||||||
|
|
||||||
# To resize an image and simultaneously change its file type:
|
|
||||||
convert original-image.jpg -resize 100x converted-image.png
|
|
||||||
|
|
||||||
# To resize all of the images within a directory:
|
|
||||||
# To implement a for loop:
|
|
||||||
for file in `ls original/image/path/`;
|
|
||||||
do new_path=${file%.*};
|
|
||||||
new_file=`basename $new_path`;
|
|
||||||
convert $file -resize 150 conerted/image/path/$new_file.png;
|
|
||||||
done
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# set a shell
|
|
||||||
SHELL=/bin/bash
|
|
||||||
|
|
||||||
# crontab format
|
|
||||||
* * * * * command_to_execute
|
|
||||||
- - - - -
|
|
||||||
| | | | |
|
|
||||||
| | | | +- day of week (0 - 7) (where sunday is 0 and 7)
|
|
||||||
| | | +--- month (1 - 12)
|
|
||||||
| | +----- day (1 - 31)
|
|
||||||
| +------- hour (0 - 23)
|
|
||||||
+--------- minute (0 - 59)
|
|
||||||
|
|
||||||
# example entries
|
|
||||||
# every 15 min
|
|
||||||
*/15 * * * * /home/user/command.sh
|
|
||||||
# every midnight
|
|
||||||
0 * * * * /home/user/command.sh
|
|
||||||
# every Saturday at 8:05 AM
|
|
||||||
5 8 * * 6 /home/user/command.sh
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Split a file based on pattern
|
|
||||||
csplit input.file '/PATTERN/'
|
|
||||||
|
|
||||||
# Use prefix/suffix to improve resulting file names
|
|
||||||
csplit -f 'prefix-' -b '%d.extension' input.file '/PATTERN/' '{*}'
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# Manage printers through CUPS:
|
|
||||||
http://localhost:631 (in web browser)
|
|
||||||
|
|
||||||
# Print file from command line
|
|
||||||
lp myfile.txt
|
|
||||||
|
|
||||||
# Display print queue
|
|
||||||
lpq
|
|
||||||
|
|
||||||
# Remove print job from queue
|
|
||||||
lprm 545
|
|
||||||
or
|
|
||||||
lprm -
|
|
||||||
|
|
||||||
# Print log location
|
|
||||||
/var/log/cups
|
|
||||||
|
|
||||||
# Reject new jobs
|
|
||||||
cupsreject printername
|
|
||||||
|
|
||||||
# Accept new jobs
|
|
||||||
cupsaccept printername
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
# Download a single file
|
|
||||||
curl http://path.to.the/file
|
|
||||||
|
|
||||||
# Download a file and specify a new filename
|
|
||||||
curl http://example.com/file.zip -o new_file.zip
|
|
||||||
|
|
||||||
# Download multiple files
|
|
||||||
curl -O URLOfFirstFile -O URLOfSecondFile
|
|
||||||
|
|
||||||
# Download all sequentially numbered files (1-24)
|
|
||||||
curl http://example.com/pic[1-24].jpg
|
|
||||||
|
|
||||||
# Download a file and pass HTTP Authentication
|
|
||||||
curl -u username:password URL
|
|
||||||
|
|
||||||
# Download a file with a Proxy
|
|
||||||
curl -x proxysever.server.com:PORT http://addressiwantto.access
|
|
||||||
|
|
||||||
# Download a file from FTP
|
|
||||||
curl -u username:password -O ftp://example.com/pub/file.zip
|
|
||||||
|
|
||||||
# Get an FTP directory listing
|
|
||||||
curl ftp://username:password@example.com
|
|
||||||
|
|
||||||
# Resume a previously failed download
|
|
||||||
curl -C - -o partial_file.zip http://example.com/file.zip
|
|
||||||
|
|
||||||
# Fetch only the HTTP headers from a response
|
|
||||||
curl -I http://example.com
|
|
||||||
|
|
||||||
# Fetch your external IP and network info as JSON
|
|
||||||
curl http://ifconfig.me/all/json
|
|
||||||
|
|
||||||
# Limit the rate of a download
|
|
||||||
curl --limit-rate 1000B -O http://path.to.the/file
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# To cut out the third field of text or stdoutput that is delimited by a #:
|
|
||||||
cut -d# -f3
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Print date in format suitable for affixing to file names
|
|
||||||
date +"%Y%m%d_%H%M%S"
|
|
||||||
|
|
||||||
# Convert Unix timestamp to Date
|
|
||||||
date -d @1440359821
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# Read from {/dev/urandom} 2*512 Bytes and put it into {/tmp/test.txt}
|
|
||||||
# Note: At the first iteration, we read 512 Bytes.
|
|
||||||
# Note: At the second iteration, we read 512 Bytes.
|
|
||||||
dd if=/dev/urandom of=/tmp/test.txt count=512 bs=2
|
|
||||||
|
|
||||||
# Watch the progress of 'dd'
|
|
||||||
dd if=/dev/zero of=/dev/null bs=4KB &; export dd_pid=`pgrep '^dd'`; while [[ -d /proc/$dd_pid ]]; do kill -USR1 $dd_pid && sleep 1 && clear; done
|
|
||||||
|
|
||||||
# Watch the progress of 'dd' with `pv` and `dialog` (apt-get install pv dialog)
|
|
||||||
(pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0
|
|
||||||
|
|
||||||
# Watch the progress of 'dd' with `pv` and `zenity` (apt-get install pv zenity)
|
|
||||||
(pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | zenity --title 'Running dd command (cloning), please wait...' --progress
|
|
||||||
|
|
||||||
# DD with "graphical" return
|
|
||||||
dcfldd if=/dev/zero of=/dev/null bs=500K
|
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# Printout disk free space in a human readable format
|
|
||||||
df -h
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# To release the current IP address:
|
|
||||||
sudo dhclient -r
|
|
||||||
|
|
||||||
# To obtain a new IP address:
|
|
||||||
sudo dhclient
|
|
||||||
|
|
||||||
# Running the above in sequence is a common way of refreshing an IP.
|
|
||||||
|
|
||||||
# To obtain a new IP address for a specific interface:
|
|
||||||
sudo dhclient eth0
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# To view the differences between two files:
|
|
||||||
diff -u version1 version2
|
|
||||||
|
|
||||||
# To view the differences between two directories:
|
|
||||||
diff -ur folder1/ folder2/
|
|
||||||
|
|
||||||
# To ignore the white spaces:
|
|
||||||
diff -ub version1 version2
|
|
||||||
|
|
||||||
# To ignore the blank lines:
|
|
||||||
diff -uB version1 version2
|
|
||||||
|
|
||||||
# To ignore the differences between uppercase and lowercase:
|
|
||||||
diff -ui version1 version2
|
|
||||||
|
|
||||||
# To report whether the files differ:
|
|
||||||
diff -q version1 version2
|
|
||||||
|
|
||||||
# To report whether the files are identical:
|
|
||||||
diff -s version1 version2
|
|
||||||
|
|
||||||
# To diff the output of two commands or scripts:
|
|
||||||
diff <(command1) <(command2)
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# INSTALL
|
|
||||||
# ==============================================================================
|
|
||||||
# Edit /etc/default/distcc and set theses vars
|
|
||||||
# STARTDISTCC="true"
|
|
||||||
# ALLOWEDNETS="127.0.0.1 192.168.1.0/24"# Your computer and local computers
|
|
||||||
# #LISTENER="127.0.0.1"# Comment it
|
|
||||||
# ZEROCONF="true"# Auto configuration
|
|
||||||
|
|
||||||
# REMEMBER 1:
|
|
||||||
# Start/Restart your distccd servers before using one of these commands.
|
|
||||||
# service distccd start
|
|
||||||
|
|
||||||
# REMEMBER 2:
|
|
||||||
# Do not forget to install on each machine DISTCC.
|
|
||||||
# No need to install libs ! Only main host need libs !
|
|
||||||
|
|
||||||
# USAGE
|
|
||||||
# ==============================================================================
|
|
||||||
|
|
||||||
# Run make with 4 thread (a cross network) in auto configuration.
|
|
||||||
# Note: for gcc, Replace CXX by CC and g++ by gcc
|
|
||||||
ZEROCONF='+zeroconf' make -j4 CXX='distcc g++'
|
|
||||||
|
|
||||||
# Run make with 4 thread (a cross network) in static configuration (2 ip)
|
|
||||||
# Note: for gcc, Replace CXX by CC and g++ by gcc
|
|
||||||
DISTCC_HOSTS='127.0.0.1 192.168.1.69' make -j4 CXX='distcc g++'
|
|
||||||
|
|
||||||
# Show hosts aviables
|
|
||||||
ZEROCONF='+zeroconf' distcc --show-hosts
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# To install the latest version of a package:
|
|
||||||
dnf install <package name>
|
|
||||||
|
|
||||||
# To search package details for the given string
|
|
||||||
dnf search <string>
|
|
||||||
|
|
||||||
# To find which package provides a binary
|
|
||||||
dnf provides <path to binary>
|
|
||||||
|
|
||||||
# The following are available after installing "dnf-plugins-core"
|
|
||||||
|
|
||||||
# Download a package
|
|
||||||
dnf download <package name>
|
|
||||||
|
|
||||||
# install the build dependencies for a SRPM or from a .spec file
|
|
||||||
dnf builddep <srpm/.spec file>
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# Start docker daemon
|
|
||||||
docker -d
|
|
||||||
|
|
||||||
# start a container with an interactive shell
|
|
||||||
docker run -ti <image_name> /bin/bash
|
|
||||||
|
|
||||||
# "shell" into a running container (docker-1.3+)
|
|
||||||
docker exec -ti <container_name> bash
|
|
||||||
|
|
||||||
# inspect a running container
|
|
||||||
docker inspect <container_name> (or <container_id>)
|
|
||||||
|
|
||||||
# Get the process ID for a container
|
|
||||||
# Source: https://github.com/jpetazzo/nsenter
|
|
||||||
docker inspect --format {{.State.Pid}} <container_name_or_ID>
|
|
||||||
|
|
||||||
# List the current mounted volumes for a container (and pretty print)
|
|
||||||
# Source:
|
|
||||||
# http://nathanleclaire.com/blog/2014/07/12/10-docker-tips-and-tricks-that-will-make-you-sing-a-whale-song-of-joy/
|
|
||||||
docker inspect --format='{{json .Volumes}}' <container_id> | python -mjson.tool
|
|
||||||
|
|
||||||
# list currently running containers
|
|
||||||
docker ps
|
|
||||||
|
|
||||||
# list all containers
|
|
||||||
docker ps -a
|
|
||||||
|
|
||||||
# list all images
|
|
||||||
docker images
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# Install the package or upgrade it
|
|
||||||
dpkg -i test.deb
|
|
||||||
|
|
||||||
# Remove a package including configuration files
|
|
||||||
dpkg -P test.deb
|
|
||||||
|
|
||||||
# List all installed packages with versions and details
|
|
||||||
dpkg -I
|
|
||||||
|
|
||||||
# Find out if a Debian package is installed or not
|
|
||||||
dpkg -s test.deb | grep Status
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# To sort directories/files by size
|
|
||||||
du -sk *| sort -rn
|
|
||||||
|
|
||||||
# To show cumulative humanreadable size
|
|
||||||
du -sh
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
# Basic usage
|
|
||||||
|
|
||||||
Indent Select text then press TAB
|
|
||||||
Cut CTRL-w
|
|
||||||
Copy ALT-w
|
|
||||||
Paste CTRL-y
|
|
||||||
Search/Find CTRL-s
|
|
||||||
Replace ALT-% (ALT-SHIFT-5)
|
|
||||||
Save CTRL-x CTRL-s
|
|
||||||
Load/Open CTRL-x CTRL-f
|
|
||||||
Undo CTRL-x u
|
|
||||||
Highlight all text CTRL-x h
|
|
||||||
Directory listing CTRL-x d
|
|
||||||
Cancel a command ESC ESC ESC
|
|
||||||
Font size bigger CTRL-x CTRL-+
|
|
||||||
Font size smaller CTRL-x CTRL--
|
|
||||||
|
|
||||||
# Buffers
|
|
||||||
|
|
||||||
Split screen vertically CTRL-x 2
|
|
||||||
Split screen vertically with 5 row height CTRL-u 5 CTRL-x 2
|
|
||||||
Split screen horizontally CTRL-x 3
|
|
||||||
Split screen horizontally with 24 column width CTRL-u 24 CTRL-x 3
|
|
||||||
Revert to single screen CTRL-x 1
|
|
||||||
Hide the current screen CTRL-x 0
|
|
||||||
Kill the current screen CTRL-x k
|
|
||||||
Move to the next buffer CTRL-x O
|
|
||||||
Select a buffer CTRL-x b
|
|
||||||
Run command in the scratch buffer CTRL-x CTRL-e
|
|
||||||
|
|
||||||
# Other stuff
|
|
||||||
|
|
||||||
Open a shell ALT-x eshell
|
|
||||||
Goto a line number ALT-x goto-line
|
|
||||||
Word wrap ALT-x toggle-word-wrap
|
|
||||||
Spell checking ALT-x flyspell-mode
|
|
||||||
Line numbers ALT-x linum-mode
|
|
||||||
Toggle line wrap ALT-x visual-line-mode
|
|
||||||
Compile some code ALT-x compile
|
|
||||||
List packages ALT-x package-list-packages
|
|
||||||
|
|
||||||
# Sudoing within eshell
|
|
||||||
|
|
||||||
By default when using the sudo command within eshell you'll just
|
|
||||||
get "permission denied" messages. To overcome that type:
|
|
||||||
|
|
||||||
alias sudo '*sudo $*'
|
|
||||||
|
|
||||||
# Line numbers
|
|
||||||
|
|
||||||
To add line numbers and enable moving to a line with CTRL-l:
|
|
||||||
|
|
||||||
(global-set-key "\C-l" 'goto-line)
|
|
||||||
(add-hook 'find-file-hook (lambda () (linum-mode 1)))
|
|
||||||
|
|
||||||
# Org-mode
|
|
||||||
|
|
||||||
To begin org-mode ALT-x org-mode
|
|
||||||
Table column separator Vertical/pipe character
|
|
||||||
Reorganize table TAB
|
|
||||||
Section heading *
|
|
||||||
Open/collapse section TAB
|
|
||||||
Open/collapse All CTRL-TAB
|
|
||||||
Export in other file formats (eg HTML,PDF) CTRL-c CTRL-e
|
|
||||||
|
|
||||||
To make org-mode automatically wrap lines:
|
|
||||||
|
|
||||||
(add-hook 'org-mode-hook
|
|
||||||
'(lambda ()
|
|
||||||
(visual-line-mode 1)))
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
# Print file metadata etc.
|
|
||||||
ffmpeg -i path/to/file.ext
|
|
||||||
|
|
||||||
# Convert all m4a files to mp3
|
|
||||||
for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -ab 320k "${f%.m4a}.mp3"; done
|
|
||||||
|
|
||||||
# Listen to 10 seconds of audio from a video file
|
|
||||||
#
|
|
||||||
# -ss : start time
|
|
||||||
# -t : seconds to cut
|
|
||||||
# -autoexit : closes ffplay as soon as the audio finishes
|
|
||||||
ffmpeg -ss 00:34:24.85 -t 10 -i path/to/file.mp4 -f mp3 pipe:play | ffplay -i pipe:play -autoexit
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# To find files by case-insensitive extension (ex: .jpg, .JPG, .jpG):
|
|
||||||
find . -iname "*.jpg"
|
|
||||||
|
|
||||||
# To find directories:
|
|
||||||
find . -type d
|
|
||||||
|
|
||||||
# To find files:
|
|
||||||
find . -type f
|
|
||||||
|
|
||||||
# To find files by octal permission:
|
|
||||||
find . -type f -perm 777
|
|
||||||
|
|
||||||
# To find files with setuid bit set:
|
|
||||||
find . -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l
|
|
||||||
|
|
||||||
# To find files with extension '.txt' and remove them:
|
|
||||||
find ./path/ -name '*.txt' -exec rm '{}' \;
|
|
||||||
|
|
||||||
# To find files with extension '.txt' and look for a string into them:
|
|
||||||
find ./path/ -name '*.txt' | xargs grep 'string'
|
|
||||||
|
|
||||||
# To find files with size bigger than 5 Mb and sort them by size:
|
|
||||||
find . -size +5M -type f -print0 | xargs -0 ls -Ssh | sort -z
|
|
||||||
|
|
||||||
# To find files bigger thank 2 MB and list them:
|
|
||||||
find . -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
|
|
||||||
|
|
||||||
# To find files modified more than 7 days ago and list file information
|
|
||||||
find . -type f -mtime +7d -ls
|
|
||||||
|
|
||||||
# To find symlinks owned by a user and list file information
|
|
||||||
find . -type l --user=username -ls
|
|
||||||
|
|
||||||
# To search for and delete empty directories
|
|
||||||
find . -type d -empty -exec rmdir {} \;
|
|
||||||
|
|
||||||
# To search for directories named build at a max depth of 2 directories
|
|
||||||
find . -maxdepth 2 -name build -type d
|
|
||||||
|
|
||||||
# To search all files who are not in .git directory
|
|
||||||
find . ! -iwholename '*.git*' -type f
|
|
||||||
|
|
||||||
# Find all files that have the same node (hard link) as MY_FILE_HERE
|
|
||||||
find . -type f -samefile MY_FILE_HERE 2>/dev/null
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
# Compile a file
|
|
||||||
gcc file.c
|
|
||||||
|
|
||||||
# Compile a file with a custom output
|
|
||||||
gcc -o file file.c
|
|
||||||
|
|
||||||
# Debug symbols
|
|
||||||
gcc -g
|
|
||||||
|
|
||||||
# Debug with all symbols.
|
|
||||||
gcc -ggdb3
|
|
||||||
|
|
||||||
# Build for 64 bytes
|
|
||||||
gcc -m64
|
|
||||||
|
|
||||||
# Include the directory {/usr/include/myPersonnal/lib/} to the list of path for #include <....>
|
|
||||||
# With this option, no warning / error will be reported for the files in {/usr/include/myPersonnal/lib/}
|
|
||||||
gcc -isystem /usr/include/myPersonnal/lib/
|
|
||||||
|
|
||||||
# Build a GUI for windows (Mingw) (Will disable the term/console)
|
|
||||||
gcc -mwindows
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# start the debugger
|
|
||||||
gdb your-executable
|
|
||||||
|
|
||||||
# set a breakpoint
|
|
||||||
b some-method, break some-method
|
|
||||||
|
|
||||||
# run the program
|
|
||||||
r, run
|
|
||||||
|
|
||||||
# when a breakpoint was reached:
|
|
||||||
|
|
||||||
# run the current line, stepping over any invocations
|
|
||||||
n, next
|
|
||||||
# run the current line, stepping into any invocations
|
|
||||||
s, step
|
|
||||||
# print a stacktrace
|
|
||||||
bt, backtrace
|
|
||||||
# evaluate an expression and print the result
|
|
||||||
p length=strlen(string)
|
|
||||||
# list surrounding source code
|
|
||||||
l, list
|
|
||||||
# continue execution
|
|
||||||
c, continue
|
|
||||||
|
|
||||||
# exit gdb (after program terminated)
|
|
||||||
q, quit
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
# To set your identity:
|
|
||||||
git config --global user.name "John Doe"
|
|
||||||
git config --global user.email johndoe@example.com
|
|
||||||
|
|
||||||
# To set your editor:
|
|
||||||
git config --global core.editor emacs
|
|
||||||
|
|
||||||
# To enable color:
|
|
||||||
git config --global color.ui true
|
|
||||||
|
|
||||||
# To stage all changes for commit:
|
|
||||||
git add --all
|
|
||||||
|
|
||||||
# To commit staged changes
|
|
||||||
git commit -m "Your commit message"
|
|
||||||
|
|
||||||
# To edit previous commit message
|
|
||||||
git commit --amend
|
|
||||||
|
|
||||||
# Git commit in the past
|
|
||||||
git commit --date="`date --date='2 day ago'`"
|
|
||||||
git commit --date="Jun 13 18:30:25 IST 2015"
|
|
||||||
# more recent versions of Git also support --date="2 days ago" directly
|
|
||||||
|
|
||||||
# To change the date of an existing commit
|
|
||||||
git filter-branch --env-filter \
|
|
||||||
'if [ $GIT_COMMIT = 119f9ecf58069b265ab22f1f97d2b648faf932e0 ]
|
|
||||||
then
|
|
||||||
export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800"
|
|
||||||
export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700"
|
|
||||||
fi'
|
|
||||||
|
|
||||||
# To removed staged and working directory changes
|
|
||||||
git reset --hard
|
|
||||||
|
|
||||||
# To go 2 commits back
|
|
||||||
git reset --hard HEAD~2
|
|
||||||
|
|
||||||
# To remove untracked files
|
|
||||||
git clean -f -d
|
|
||||||
|
|
||||||
# To remove untracked and ignored files
|
|
||||||
git clean -f -d -x
|
|
||||||
|
|
||||||
# To push to the tracked master branch:
|
|
||||||
git push origin master
|
|
||||||
|
|
||||||
# To push to a specified repository:
|
|
||||||
git push git@github.com:username/project.git
|
|
||||||
|
|
||||||
# To delete the branch "branch_name"
|
|
||||||
git branch -D branch_name
|
|
||||||
|
|
||||||
# To make an exisiting branch track a remote branch
|
|
||||||
git branch -u upstream/foo
|
|
||||||
|
|
||||||
# To see who commited which line in a file
|
|
||||||
git blame filename
|
|
||||||
|
|
||||||
# To sync a fork with the master repo:
|
|
||||||
git remote add upstream git@github.com:name/repo.git # Set a new repo
|
|
||||||
git remote -v # Confirm new remote repo
|
|
||||||
git fetch upstream # Get branches
|
|
||||||
git branch -va # List local - remote branches
|
|
||||||
git checkout master # Checkout local master branch
|
|
||||||
git checkout -b new_branch # Create and checkout a new branch
|
|
||||||
git merge upstream/master # Merge remote into local repo
|
|
||||||
git show 83fb499 # Show what a commit did.
|
|
||||||
git show 83fb499:path/fo/file.ext # Shows the file as it appeared at 83fb499.
|
|
||||||
git diff branch_1 branch_2 # Check difference between branches
|
|
||||||
git log # Show all the commits
|
|
||||||
git status # Show the changes from last commit
|
|
||||||
|
|
||||||
# Commit history of a set of files
|
|
||||||
git log --pretty=email --patch-with-stat --reverse --full-index -- Admin\*.py > Sripts.patch
|
|
||||||
|
|
||||||
# Import commits from another repo
|
|
||||||
git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout <commit SHA> | git am -3 -k
|
|
||||||
|
|
||||||
# View commits that will be pushed
|
|
||||||
git log @{u}..
|
|
||||||
|
|
||||||
# View changes that are new on a feature branch
|
|
||||||
git log -p feature --not master
|
|
||||||
git diff master...feature
|
|
||||||
|
|
||||||
# Interactive rebase for the last 7 commits
|
|
||||||
git rebase -i @~7
|
|
||||||
|
|
||||||
# Diff files WITHOUT considering them a part of git
|
|
||||||
# This can be used to diff files that are not in a git repo!
|
|
||||||
git diff --no-index path/to/file/A path/to/file/B
|
|
||||||
|
|
||||||
# To pull changes while overwriting any local commits
|
|
||||||
git fetch --all
|
|
||||||
git reset --hard origin/master
|
|
||||||
|
|
||||||
# Update all your submodules
|
|
||||||
git submodule update --init --recursive
|
|
||||||
|
|
||||||
# Perform a shallow clone to only get latest commits
|
|
||||||
# (helps save data when cloning large repos)
|
|
||||||
git clone --depth 1 <remote-url>
|
|
||||||
|
|
||||||
# To unshallow a clone
|
|
||||||
git pull --unshallow
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
# Create a key
|
|
||||||
|
|
||||||
gpg --gen-key
|
|
||||||
|
|
||||||
|
|
||||||
# Show keys
|
|
||||||
|
|
||||||
To list a summary of all keys
|
|
||||||
|
|
||||||
gpg --list-keys
|
|
||||||
|
|
||||||
To show your public key
|
|
||||||
|
|
||||||
gpg --armor --export
|
|
||||||
|
|
||||||
To show the fingerprint for a key
|
|
||||||
|
|
||||||
gpg --fingerprint KEY_ID
|
|
||||||
|
|
||||||
# Search for keys
|
|
||||||
|
|
||||||
gpg --search-keys 'user@emailaddress.com'
|
|
||||||
|
|
||||||
|
|
||||||
# To Encrypt a File
|
|
||||||
|
|
||||||
gpg --encrypt --recipient 'user@emailaddress.com' example.txt
|
|
||||||
|
|
||||||
|
|
||||||
# To Decrypt a File
|
|
||||||
|
|
||||||
gpg --output example.txt --decrypt example.txt.gpg
|
|
||||||
|
|
||||||
|
|
||||||
# Export keys
|
|
||||||
|
|
||||||
gpg --output ~/public_key.txt --armor --export KEY_ID
|
|
||||||
gpg --output ~/private_key.txt --armor --export-secret-key KEY_ID
|
|
||||||
|
|
||||||
Where KEY_ID is the 8 character GPG key ID.
|
|
||||||
|
|
||||||
Store these files to a safe location, such as a USB drive, then
|
|
||||||
remove the private key file.
|
|
||||||
|
|
||||||
shred -zu ~/private_key.txt
|
|
||||||
|
|
||||||
# Import keys
|
|
||||||
|
|
||||||
Retrieve the key files which you previously exported.
|
|
||||||
|
|
||||||
gpg --import ~/public_key.txt
|
|
||||||
gpg --allow-secret-key-import --import ~/private_key.txt
|
|
||||||
|
|
||||||
Then delete the private key file.
|
|
||||||
|
|
||||||
shred -zu ~/private_key.txt
|
|
||||||
|
|
||||||
# Revoke a key
|
|
||||||
|
|
||||||
Create a revocation certificate.
|
|
||||||
|
|
||||||
gpg --output ~/revoke.asc --gen-revoke KEY_ID
|
|
||||||
|
|
||||||
Where KEY_ID is the 8 character GPG key ID.
|
|
||||||
|
|
||||||
After creating the certificate import it.
|
|
||||||
|
|
||||||
gpg --import ~/revoke.asc
|
|
||||||
|
|
||||||
Then ensure that key servers know about the revokation.
|
|
||||||
|
|
||||||
gpg --send-keys KEY_ID
|
|
||||||
|
|
||||||
# Signing and Verifying files
|
|
||||||
|
|
||||||
If you're uploading files to launchpad you may also want to include
|
|
||||||
a GPG signature file.
|
|
||||||
|
|
||||||
gpg -ba filename
|
|
||||||
|
|
||||||
or if you need to specify a particular key:
|
|
||||||
|
|
||||||
gpg --default-key <key ID> -ba filename
|
|
||||||
|
|
||||||
This then produces a file with a .asc extension which can be uploaded.
|
|
||||||
If you need to set the default key more permanently then edit the
|
|
||||||
file ~/.gnupg/gpg.conf and set the default-key parameter.
|
|
||||||
|
|
||||||
To verify a downloaded file using its signature file.
|
|
||||||
|
|
||||||
gpg --verify filename.asc
|
|
||||||
|
|
||||||
# Signing Public Keys
|
|
||||||
|
|
||||||
Import the public key or retrieve it from a server.
|
|
||||||
|
|
||||||
gpg --keyserver <keyserver> --recv-keys <Key_ID>
|
|
||||||
|
|
||||||
Check its fingerprint against any previously stated value.
|
|
||||||
|
|
||||||
gpg --fingerprint <Key_ID>
|
|
||||||
|
|
||||||
Sign the key.
|
|
||||||
|
|
||||||
gpg --sign-key <Key_ID>
|
|
||||||
|
|
||||||
Upload the signed key to a server.
|
|
||||||
|
|
||||||
gpg --keyserver <keyserver> --send-key <Key_ID>
|
|
||||||
|
|
||||||
# Change the email address associated with a GPG key
|
|
||||||
|
|
||||||
gpg --edit-key <key ID>
|
|
||||||
adduid
|
|
||||||
|
|
||||||
Enter the new name and email address. You can then list the addresses with:
|
|
||||||
|
|
||||||
list
|
|
||||||
|
|
||||||
If you want to delete a previous email address first select it:
|
|
||||||
|
|
||||||
uid <list number>
|
|
||||||
|
|
||||||
Then delete it with:
|
|
||||||
|
|
||||||
deluid
|
|
||||||
|
|
||||||
To finish type:
|
|
||||||
|
|
||||||
save
|
|
||||||
|
|
||||||
Publish the key to a server:
|
|
||||||
|
|
||||||
gpg --send-keys <key ID>
|
|
||||||
|
|
||||||
# Creating Subkeys
|
|
||||||
|
|
||||||
Subkeys can be useful if you don't wish to have your main GPG key
|
|
||||||
installed on multiple machines. In this way you can keep your
|
|
||||||
master key safe and have subkeys with expiry periods or which may be
|
|
||||||
separately revoked installed on various machines. This avoids
|
|
||||||
generating entirely separate keys and so breaking any web of trust
|
|
||||||
which has been established.
|
|
||||||
|
|
||||||
gpg --edit-key <key ID>
|
|
||||||
|
|
||||||
At the prompt type:
|
|
||||||
|
|
||||||
addkey
|
|
||||||
|
|
||||||
Choose RSA (sign only), 4096 bits and select an expiry period.
|
|
||||||
Entropy will be gathered.
|
|
||||||
|
|
||||||
At the prompt type:
|
|
||||||
|
|
||||||
save
|
|
||||||
|
|
||||||
You can also repeat the procedure, but selecting RSA (encrypt only).
|
|
||||||
To remove the master key, leaving only the subkey/s in place:
|
|
||||||
|
|
||||||
gpg --export-secret-subkeys <subkey ID> > subkeys
|
|
||||||
gpg --export <key ID> > pubkeys
|
|
||||||
gpg --delete-secret-key <key ID>
|
|
||||||
|
|
||||||
Import the keys back.
|
|
||||||
|
|
||||||
gpg --import pubkeys subkeys
|
|
||||||
|
|
||||||
Verify the import.
|
|
||||||
|
|
||||||
gpg -K
|
|
||||||
|
|
||||||
Should show sec# instead of just sec.
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# Search a file for a pattern
|
|
||||||
grep pattern file
|
|
||||||
|
|
||||||
# Case insensitive search (with line numbers)
|
|
||||||
grep -in pattern file
|
|
||||||
|
|
||||||
# Recursively grep for string <pattern> in folder:
|
|
||||||
grep -R pattern folder
|
|
||||||
|
|
||||||
# Read search patterns from a file (one per line)
|
|
||||||
grep -f pattern_file file
|
|
||||||
|
|
||||||
# Find lines NOT containing pattern
|
|
||||||
grep -v pattern file
|
|
||||||
|
|
||||||
# You can grep with regular expressions
|
|
||||||
grep "^00" file #Match lines starting with 00
|
|
||||||
grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" file #Find IP add
|
|
||||||
|
|
||||||
# Find all files which match {pattern} in {directory}
|
|
||||||
# This will show: "file:line my research"
|
|
||||||
grep -rnw 'directory' -e "pattern"
|
|
||||||
|
|
||||||
# Exclude grep from your grepped output of ps.
|
|
||||||
# Add [] to the first letter. Ex: sshd -> [s]shd
|
|
||||||
ps aux | grep '[h]ttpd'
|
|
||||||
|
|
||||||
# Colour in red {bash} and keep all other lines
|
|
||||||
ps aux | grep -E --color 'bash|$'
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# To reduce the size of a pdf file:
|
|
||||||
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf
|
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# To create a *.gz compressed file
|
|
||||||
gzip test.txt
|
|
||||||
|
|
||||||
# To create a *.gz compressed file to a specific location using -c option (standard out)
|
|
||||||
gzip -c test.txt > test_custom.txt.gz
|
|
||||||
|
|
||||||
# To uncompress a *.gz file
|
|
||||||
gzip -d test.txt.gz
|
|
||||||
|
|
||||||
# Display compression ratio of the compressed file using gzip -l
|
|
||||||
gzip -l *.gz
|
|
||||||
|
|
||||||
# Recursively compress all the files under a specified directory
|
|
||||||
gzip -r documents_directory
|
|
||||||
|
|
||||||
# To create a *.gz compressed file and keep the original
|
|
||||||
gzip < test.txt > test.txt.gz
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# Display all hardware details
|
|
||||||
sudo lshw
|
|
||||||
|
|
||||||
# List currently loaded kernel modules
|
|
||||||
lsmod
|
|
||||||
|
|
||||||
# List all modules available to the system
|
|
||||||
find /lib/modules/$(uname -r) -type f -iname "*.ko"
|
|
||||||
|
|
||||||
# Load a module into kernel
|
|
||||||
modprobe modulename
|
|
||||||
|
|
||||||
# Remove a module from kernel
|
|
||||||
modprobe -r modulename
|
|
||||||
|
|
||||||
# List devices connected via pci bus
|
|
||||||
lspci
|
|
||||||
|
|
||||||
# Debug output for pci devices (hex)
|
|
||||||
lspci -vvxxx
|
|
||||||
|
|
||||||
# Display cpu hardware stats
|
|
||||||
cat /proc/cpuinfo
|
|
||||||
|
|
||||||
# Display memory hardware stats
|
|
||||||
cat /proc/meminfo
|
|
||||||
|
|
||||||
# Output the kernel ring buffer
|
|
||||||
dmesg
|
|
||||||
|
|
||||||
# Ouput kernel messages
|
|
||||||
dmesg --kernel
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# To show the first 10 lines of file
|
|
||||||
head file
|
|
||||||
|
|
||||||
# To show the first N lines of file
|
|
||||||
head -n N file
|
|
||||||
|
|
||||||
# To show the first N bytes of file
|
|
||||||
head -c N file
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# To see most used top 10 commands:
|
|
||||||
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
|
|
||||||
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
As a contributor to open-source
|
|
||||||
-------------------------------
|
|
||||||
|
|
||||||
# clone your own project
|
|
||||||
$ git clone dotfiles
|
|
||||||
→ git clone git://github.com/YOUR_USER/dotfiles.git
|
|
||||||
|
|
||||||
# clone another project
|
|
||||||
$ git clone github/hub
|
|
||||||
→ git clone git://github.com/github/hub.git
|
|
||||||
|
|
||||||
# see the current project's issues
|
|
||||||
$ git browse -- issues
|
|
||||||
→ open https://github.com/github/hub/issues
|
|
||||||
|
|
||||||
# open another project's wiki
|
|
||||||
$ git browse mojombo/jekyll wiki
|
|
||||||
→ open https://github.com/mojombo/jekyll/wiki
|
|
||||||
|
|
||||||
## Example workflow for contributing to a project:
|
|
||||||
$ git clone github/hub
|
|
||||||
$ cd hub
|
|
||||||
# create a topic branch
|
|
||||||
$ git checkout -b feature
|
|
||||||
→ ( making changes ... )
|
|
||||||
$ git commit -m "done with feature"
|
|
||||||
# It's time to fork the repo!
|
|
||||||
$ git fork
|
|
||||||
→ (forking repo on GitHub...)
|
|
||||||
→ git remote add YOUR_USER git://github.com/YOUR_USER/hub.git
|
|
||||||
# push the changes to your new remote
|
|
||||||
$ git push YOUR_USER feature
|
|
||||||
# open a pull request for the topic branch you've just pushed
|
|
||||||
$ git pull-request
|
|
||||||
→ (opens a text editor for your pull request message)
|
|
||||||
|
|
||||||
|
|
||||||
As an open-source maintainer
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
# fetch from multiple trusted forks, even if they don't yet exist as remotes
|
|
||||||
$ git fetch mislav,cehoffman
|
|
||||||
→ git remote add mislav git://github.com/mislav/hub.git
|
|
||||||
→ git remote add cehoffman git://github.com/cehoffman/hub.git
|
|
||||||
→ git fetch --multiple mislav cehoffman
|
|
||||||
|
|
||||||
# check out a pull request for review
|
|
||||||
$ git checkout https://github.com/github/hub/pull/134
|
|
||||||
→ (creates a new branch with the contents of the pull request)
|
|
||||||
|
|
||||||
# directly apply all commits from a pull request to the current branch
|
|
||||||
$ git am -3 https://github.com/github/hub/pull/134
|
|
||||||
|
|
||||||
# cherry-pick a GitHub URL
|
|
||||||
$ git cherry-pick https://github.com/xoebus/hub/commit/177eeb8
|
|
||||||
→ git remote add xoebus git://github.com/xoebus/hub.git
|
|
||||||
→ git fetch xoebus
|
|
||||||
→ git cherry-pick 177eeb8
|
|
||||||
|
|
||||||
# `am` can be better than cherry-pick since it doesn't create a remote
|
|
||||||
$ git am https://github.com/xoebus/hub/commit/177eeb8
|
|
||||||
|
|
||||||
# open the GitHub compare view between two releases
|
|
||||||
$ git compare v0.9..v1.0
|
|
||||||
|
|
||||||
# put compare URL for a topic branch to clipboard
|
|
||||||
$ git compare -u feature | pbcopy
|
|
||||||
|
|
||||||
# create a repo for a new project
|
|
||||||
$ git init
|
|
||||||
$ git add . && git commit -m "It begins."
|
|
||||||
$ git create -d "My new thing"
|
|
||||||
→ (creates a new project on GitHub with the name of current directory)
|
|
||||||
$ git push origin master
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Display network settings of the first ethernet adapter
|
|
||||||
ifconfig wlan0
|
|
||||||
|
|
||||||
# Display all interfaces, even if down
|
|
||||||
ifconfig -a
|
|
||||||
|
|
||||||
# Take down / up the wireless adapter
|
|
||||||
ifconfig wlan0 {up|down}
|
|
||||||
|
|
||||||
# Set a static IP and netmask
|
|
||||||
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
|
|
||||||
|
|
||||||
# You may also need to add a gateway IP
|
|
||||||
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# format C/C++ source according to the style of Kernighan and Ritchie (K&R), no tabs, 3 spaces per indent, wrap lines at 120 characters.
|
|
||||||
indent -i3 -kr -nut -l120
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# Display all interfaces with addresses
|
|
||||||
ip addr
|
|
||||||
|
|
||||||
# Take down / up the wireless adapter
|
|
||||||
ip link set dev wlan0 {up|down}
|
|
||||||
|
|
||||||
# Set a static IP and netmask
|
|
||||||
ip addr add 192.168.1.100/32 dev eth0
|
|
||||||
|
|
||||||
# Remove a IP from an interface
|
|
||||||
ip addr del 192.168.1.100/32 dev eth0
|
|
||||||
|
|
||||||
# Remove all IPs from an interface
|
|
||||||
ip address flush dev eth0
|
|
||||||
|
|
||||||
# Display all routes
|
|
||||||
ip route
|
|
||||||
|
|
||||||
# Display all routes for IPv6
|
|
||||||
ip -6 route
|
|
||||||
|
|
||||||
# Add default route via gateway IP
|
|
||||||
ip route add default via 192.168.1.1
|
|
||||||
|
|
||||||
# Add route via interface
|
|
||||||
ip route add 192.168.0.0/24 dev eth0
|
|
||||||
|
|
||||||
# Change your mac address
|
|
||||||
ip link set dev eth0 address aa:bb:cc:dd:ee:ff
|
|
||||||
|
|
||||||
# View neighbors (using ARP and NDP)
|
|
||||||
ip neighbor show
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
# Show hit for rules with auto refresh
|
|
||||||
watch --interval 0 'iptables -nvL | grep -v "0 0"'
|
|
||||||
|
|
||||||
# Show hit for rule with auto refresh and highlight any changes since the last refresh
|
|
||||||
watch -d -n 2 iptables -nvL
|
|
||||||
|
|
||||||
# Block the port 902 and we hide this port from nmap.
|
|
||||||
iptables -A INPUT -i eth0 -p tcp --dport 902 -j REJECT --reject-with icmp-port-unreachable
|
|
||||||
|
|
||||||
# Note, --reject-with accept:
|
|
||||||
# icmp-net-unreachable
|
|
||||||
# icmp-host-unreachable
|
|
||||||
# icmp-port-unreachable <- Hide a port to nmap
|
|
||||||
# icmp-proto-unreachable
|
|
||||||
# icmp-net-prohibited
|
|
||||||
# icmp-host-prohibited or
|
|
||||||
# icmp-admin-prohibited
|
|
||||||
# tcp-reset
|
|
||||||
|
|
||||||
# Add a comment to a rule:
|
|
||||||
iptables ... -m comment --comment "This rule is here for this reason"
|
|
||||||
|
|
||||||
|
|
||||||
# To remove or insert a rule:
|
|
||||||
# 1) Show all rules
|
|
||||||
iptables -L INPUT --line-numbers
|
|
||||||
# OR iptables -nL --line-numbers
|
|
||||||
|
|
||||||
# Chain INPUT (policy ACCEPT)
|
|
||||||
# num target prot opt source destination
|
|
||||||
# 1 ACCEPT udp -- anywhere anywhere udp dpt:domain
|
|
||||||
# 2 ACCEPT tcp -- anywhere anywhere tcp dpt:domain
|
|
||||||
# 3 ACCEPT udp -- anywhere anywhere udp dpt:bootps
|
|
||||||
# 4 ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
|
|
||||||
|
|
||||||
# 2.a) REMOVE (-D) a rule. (here an INPUT rule)
|
|
||||||
iptables -D INPUT 2
|
|
||||||
|
|
||||||
# 2.b) OR INSERT a rule.
|
|
||||||
iptables -I INPUT {LINE_NUMBER} -i eth1 -p tcp --dport 21 -s 123.123.123.123 -j ACCEPT -m comment --comment "This rule is here for this reason"
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# To connect to an IRC server
|
|
||||||
/connect <server domain name>
|
|
||||||
|
|
||||||
# To join a channel
|
|
||||||
/join #<channel name>
|
|
||||||
|
|
||||||
# To set a nickname
|
|
||||||
/nick <my nickname>
|
|
||||||
|
|
||||||
# To send a private message to a user
|
|
||||||
/msg <nickname>
|
|
||||||
|
|
||||||
# To close the current channel window
|
|
||||||
/wc
|
|
||||||
|
|
||||||
# To switch between channel windows
|
|
||||||
ALT+<number>, eg. ALT+1, ALT+2
|
|
||||||
|
|
||||||
# To list the nicknames within a channel
|
|
||||||
/names
|
|
||||||
|
|
||||||
# To change the topic
|
|
||||||
/topic <description>
|
|
||||||
|
|
||||||
# To quit irssi
|
|
||||||
/exit
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# Display wireless settings of the first wireless adapter
|
|
||||||
iwconfig wlan0
|
|
||||||
|
|
||||||
# Take down / up the wireless adapter
|
|
||||||
iwconfig wlan0 txpower {on|auto|off}
|
|
||||||
|
|
||||||
# Change the mode of the wireless adapter
|
|
||||||
iwconfig wlan0 mode {managed|ad-hoc|monitor}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# Actively follow log (like tail -f)
|
|
||||||
journalctl -f
|
|
||||||
|
|
||||||
# Display all errors since last boot
|
|
||||||
journalctl -b -p err
|
|
||||||
|
|
||||||
# Filter by time period
|
|
||||||
journalctl --since=2012-10-15 --until="2011-10-16 23:59:59"
|
|
||||||
|
|
||||||
# Show list of systemd units logged in journal
|
|
||||||
journalctl -F _SYSTEMD_UNIT
|
|
||||||
|
|
||||||
# Filter by specific unit
|
|
||||||
journalctl -u dbus
|
|
||||||
|
|
||||||
# Filter by executable name
|
|
||||||
journalctl /usr/bin/dbus-daemon
|
|
||||||
|
|
||||||
# Filter by PID
|
|
||||||
journalctl _PID=123
|
|
||||||
|
|
||||||
# Filter by Command, e.g., sshd
|
|
||||||
journalctl _COMM=sshd
|
|
||||||
|
|
||||||
# Filter by Command and time period
|
|
||||||
journalctl _COMM=crond --since '10:00' --until '11:00'
|
|
||||||
|
|
||||||
# List all available boots
|
|
||||||
journalctl --list-boots
|
|
||||||
|
|
||||||
# Filter by specific User ID e.g., user id 1000
|
|
||||||
journalctl _UID=1000
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# Pretty print the json
|
|
||||||
jq "." < filename.json
|
|
||||||
|
|
||||||
# Access the value at key "foo"
|
|
||||||
jq '.foo'
|
|
||||||
|
|
||||||
# Access first list item
|
|
||||||
jq '.[0]'
|
|
||||||
|
|
||||||
# Slice & Dice
|
|
||||||
jq '.[2:4]'
|
|
||||||
jq '.[:3]'
|
|
||||||
jq '.[-2:]'
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
# Add entry to default jrnl (from your configured text editor)
|
|
||||||
jrnl
|
|
||||||
|
|
||||||
# Add entry to default jrnl
|
|
||||||
jrnl Write entry here.
|
|
||||||
|
|
||||||
# List of tags
|
|
||||||
jrnl --tags
|
|
||||||
|
|
||||||
# Entries per tag
|
|
||||||
jrnl @tag
|
|
||||||
|
|
||||||
# Export jrnl as json
|
|
||||||
jrnl --export json
|
|
||||||
|
|
||||||
# Entries in a timeframe
|
|
||||||
jrnl -from 2009 -until may
|
|
||||||
|
|
||||||
# Add Sublime text to .jrnl_config
|
|
||||||
|
|
||||||
# Windows
|
|
||||||
"editor": "F:\\Powerpack\\Sublime\\sublime_text.exe -w"
|
|
||||||
|
|
||||||
# Linux
|
|
||||||
"editor": "/usr/bin/sublime -w"
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# To disable the terminal refresh when exiting
|
|
||||||
less -X
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# Display available libraries
|
|
||||||
ldconfig -p
|
|
||||||
|
|
||||||
# Update library resources
|
|
||||||
ldconfig
|
|
||||||
|
|
||||||
# Display libraries and file location
|
|
||||||
ldd
|
|
||||||
|
|
||||||
# Libraries available to apps in real-time
|
|
||||||
"Dynamic Libraries" (.so.)
|
|
||||||
|
|
||||||
# Libraries only available to apps when installed (imported)
|
|
||||||
"Static Libraries" (.a.)
|
|
||||||
|
|
||||||
# Standard (usual) library file location
|
|
||||||
/lib
|
|
||||||
|
|
||||||
# Sofware-accessible source for library info
|
|
||||||
/etc/ld.so.cache # (binary)
|
|
||||||
|
|
||||||
# Human-readable source for library info
|
|
||||||
/etc/ld.so.conf # (points to /etc/ld.so.conf.d)
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# To create a symlink:
|
|
||||||
ln -s path/to/the/target/directory name-of-symlink
|
|
||||||
|
|
||||||
# Symlink, while overwriting existing destination files
|
|
||||||
ln -sf /some/dir/exec /usr/bin/exec
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# Displays everything in the target directory
|
|
||||||
ls path/to/the/target/directory
|
|
||||||
|
|
||||||
# Displays everything including hidden files
|
|
||||||
ls -a
|
|
||||||
|
|
||||||
# Displays all files, along with the size (with unit suffixes) and timestamp
|
|
||||||
ls -lh
|
|
||||||
|
|
||||||
# Display files, sorted by size
|
|
||||||
ls -S
|
|
||||||
|
|
||||||
# Display directories only
|
|
||||||
ls -d */
|
|
||||||
|
|
||||||
# Display directories only, include hidden
|
|
||||||
ls -d .*/ */
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# List all IPv4 network files
|
|
||||||
sudo lsof -i4
|
|
||||||
|
|
||||||
# List all IPv6 network files
|
|
||||||
sudo lsof -i6
|
|
||||||
|
|
||||||
# To find listening ports:
|
|
||||||
lsof -Pnl +M -i4
|
|
||||||
|
|
||||||
# To find which program is using the port 80:
|
|
||||||
lsof -i TCP:80
|
|
||||||
|
|
||||||
# List all processes accessing a particular file/directory
|
|
||||||
lsof </path/to/file>
|
|
||||||
|
|
||||||
# List all files open for a particular user
|
|
||||||
lsof -u <username>
|
|
||||||
|
|
||||||
# List all files/network connections a given process is using
|
|
||||||
lsof -c <command-name>
|
|
||||||
|
|
||||||
# See this primer: http://www.danielmiessler.com/study/lsof/
|
|
||||||
# for a number of other useful lsof tips
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#Exclusive Activation of a Volume Group in a Cluster
|
|
||||||
#Link --> https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/High_Availability_Add-On_Administration/s1-exclusiveactive-HAAA.html
|
|
||||||
1> vgs --noheadings -o vg_name
|
|
||||||
2> volume_list = [ "rhel_root", "rhel_home" ]
|
|
||||||
3> dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r)
|
|
||||||
4> Reboot the node
|
|
||||||
5> uname -r to verify the correct initrd image
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Convert a man page to pdf
|
|
||||||
man -t bash | ps2pdf - bash.pdf
|
|
||||||
|
|
||||||
# View the ascii chart
|
|
||||||
man 7 ascii
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# headers
|
|
||||||
h1 header
|
|
||||||
=========
|
|
||||||
h2 header
|
|
||||||
---------
|
|
||||||
|
|
||||||
# blockquotes
|
|
||||||
> first level and paragraph
|
|
||||||
>> second level and first paragraph
|
|
||||||
>
|
|
||||||
> first level and second paragraph
|
|
||||||
|
|
||||||
# lists
|
|
||||||
## unordered - use *, +, or -
|
|
||||||
* Red
|
|
||||||
* Green
|
|
||||||
* Blue
|
|
||||||
|
|
||||||
## ordered
|
|
||||||
1. First
|
|
||||||
2. Second
|
|
||||||
3. Third
|
|
||||||
|
|
||||||
# code - use 4 spaces/1 tab
|
|
||||||
regular text
|
|
||||||
code code code
|
|
||||||
or:
|
|
||||||
Use the `printf()` function
|
|
||||||
|
|
||||||
# hr's - three or more of the following
|
|
||||||
***
|
|
||||||
---
|
|
||||||
___
|
|
||||||
|
|
||||||
# links
|
|
||||||
This is [an example](http://example.com "Title") inline link.
|
|
||||||
|
|
||||||
# image
|
|
||||||

|
|
||||||
|
|
||||||
# emphasis
|
|
||||||
*em* _em_
|
|
||||||
|
|
||||||
**strong** __strong__
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# Create a directory and all its parents
|
|
||||||
mkdir -p foo/bar/baz
|
|
||||||
|
|
||||||
# Create foo/bar and foo/baz directories
|
|
||||||
mkdir -p foo/{bar,baz}
|
|
||||||
|
|
||||||
# Create the foo/bar, foo/baz, foo/baz/zip and foo/baz/zap directories
|
|
||||||
mkdir -p foo/{bar,baz/{zip,zap}}
|
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# To show the file start at line number 5
|
|
||||||
more +5 file
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# To mount / partition as read-write in repair mode:
|
|
||||||
mount -o remount,rw /
|
|
||||||
|
|
||||||
# Bind mount path to a second location
|
|
||||||
mount --bind /origin/path /destination/path
|
|
||||||
|
|
||||||
# To mount Usb disk as user writable:
|
|
||||||
mount -o uid=username,gid=usergroup /dev/sdx /mnt/xxx
|
|
||||||
|
|
||||||
# To mount a remote NFS directory
|
|
||||||
mount -t nfs example.com:/remote/example/dir /local/example/dir
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# To connect to a database
|
|
||||||
mysql -h localhost -u root -p
|
|
||||||
|
|
||||||
# To backup all databases
|
|
||||||
mysqldump --all-databases --all-routines -u root -p > ~/fulldump.sql
|
|
||||||
|
|
||||||
# To restore all databases
|
|
||||||
mysql -u root -p < ~/fulldump.sql
|
|
||||||
|
|
||||||
# To create a database in utf8 charset
|
|
||||||
CREATE DATABASE owa CHARACTER SET utf8 COLLATE utf8_general_ci;
|
|
||||||
|
|
||||||
# To add a user and give rights on the given database
|
|
||||||
GRANT ALL PRIVILEGES ON database.* TO 'user'@'localhost'IDENTIFIED BY 'password' WITH GRANT OPTION;
|
|
||||||
|
|
||||||
# To list the privileges granted to the account that you are using to connect to the server. Any of the 3 statements will work.
|
|
||||||
SHOW GRANTS FOR CURRENT_USER();
|
|
||||||
SHOW GRANTS;
|
|
||||||
SHOW GRANTS FOR CURRENT_USER;
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# To dump a database to a file (Note that your password will appear in your command history!):
|
|
||||||
mysqldump -uusername -ppassword the-database > db.sql
|
|
||||||
|
|
||||||
# To dump a database to a file:
|
|
||||||
mysqldump -uusername -p the-database > db.sql
|
|
||||||
|
|
||||||
# To dump a database to a .tgz file (Note that your password will appear in your command history!):
|
|
||||||
mysqldump -uusername -ppassword the-database | gzip -9 > db.sql
|
|
||||||
|
|
||||||
# To dump a database to a .tgz file:
|
|
||||||
mysqldump -uusername -p the-database | gzip -9 > db.sql
|
|
||||||
|
|
||||||
# To dump all databases to a file (Note that your password will appear in your command history!):
|
|
||||||
mysqldump -uusername -ppassword --all-databases > all-databases.sql
|
|
||||||
|
|
||||||
# To dump all databases to a file:
|
|
||||||
mysqldump -uusername -p --all-databases > all-databases.sql
|
|
||||||
|
|
||||||
# To export the database structure only:
|
|
||||||
mysqldump --no-data -uusername -p the-database > dump_file
|
|
||||||
|
|
||||||
# To export the database data only:
|
|
||||||
mysqldump --no-create-info -uusername -p the-database > dump_file
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# To open a TCP connection to port 42 of host.example.com, using port 31337 as the source port, with a timeout of 5 seconds:
|
|
||||||
nc -p 31337 -w 5 host.example.com 42
|
|
||||||
|
|
||||||
# To open a UDP connection to port 53 of host.example.com:
|
|
||||||
nc -u host.example.com 53
|
|
||||||
|
|
||||||
# To open a TCP connection to port 42 of host.example.com using 10.1.2.3 as the IP for the local end of the connection:
|
|
||||||
nc -s 10.1.2.3 host.example.com 42
|
|
||||||
|
|
||||||
# To create and listen on a UNIX-domain stream socket:
|
|
||||||
nc -lU /var/tmp/dsocket
|
|
||||||
|
|
||||||
# To connect to port 42 of host.example.com via an HTTP proxy at 10.2.3.4, port 8080. This example could also be used by ssh(1); see the ProxyCommand directive in ssh_config(5) for more information.
|
|
||||||
nc -x10.2.3.4:8080 -Xconnect host.example.com 42
|
|
||||||
|
|
||||||
# The same example again, this time enabling proxy authentication with username "ruser" if the proxy requires it:
|
|
||||||
nc -x10.2.3.4:8080 -Xconnect -Pruser host.example.com 42
|
|
||||||
|
|
||||||
# To choose the source IP for the testing using the -s option
|
|
||||||
nc -zv -s source_IP target_IP Port
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
# Connect mode (ncat is client) | default port is 31337
|
|
||||||
ncat <host> [<port>]
|
|
||||||
|
|
||||||
# Listen mode (ncat is server) | default port is 31337
|
|
||||||
ncat -l [<host>] [<port>]
|
|
||||||
|
|
||||||
# Transfer file (closes after one transfer)
|
|
||||||
ncat -l [<host>] [<port>] < file
|
|
||||||
|
|
||||||
# Transfer file (stays open for multiple transfers)
|
|
||||||
ncat -l --keep-open [<host>] [<port>] < file
|
|
||||||
|
|
||||||
# Receive file
|
|
||||||
ncat [<host>] [<port>] > file
|
|
||||||
|
|
||||||
# Brokering | allows for multiple clients to connect
|
|
||||||
ncat -l --broker [<host>] [<port>]
|
|
||||||
|
|
||||||
# Listen with SSL | many options, use ncat --help for full list
|
|
||||||
ncat -l --ssl [<host>] [<port>]
|
|
||||||
|
|
||||||
# Access control
|
|
||||||
ncat -l --allow <ip>
|
|
||||||
ncat -l --deny <ip>
|
|
||||||
|
|
||||||
# Proxying
|
|
||||||
ncat --proxy <proxyhost>[:<proxyport>] --proxy-type {http | socks4} <host>[<port>]
|
|
||||||
|
|
||||||
# Chat server | can use brokering for multi-user chat
|
|
||||||
ncat -l --chat [<host>] [<port>]
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# WARNING ! netstat is deprecated. Look below.
|
|
||||||
|
|
||||||
# To view which users/processes are listening to which ports:
|
|
||||||
sudo netstat -lnptu
|
|
||||||
|
|
||||||
# To view routing table (use -n flag to disable DNS lookups):
|
|
||||||
netstat -r
|
|
||||||
|
|
||||||
# Which process is listening to port <port>
|
|
||||||
netstat -pln | grep <port> | awk '{print $NF}'
|
|
||||||
|
|
||||||
Example output: 1507/python
|
|
||||||
|
|
||||||
# Fast display of ipv4 tcp listening programs
|
|
||||||
sudo netstat -vtlnp --listening -4
|
|
||||||
|
|
||||||
# WARNING ! netstat is deprecated.
|
|
||||||
# Replace it by:
|
|
||||||
ss
|
|
||||||
|
|
||||||
# For netstat-r
|
|
||||||
ip route
|
|
||||||
|
|
||||||
# For netstat -i
|
|
||||||
ip -s link
|
|
||||||
|
|
||||||
# For netstat-g
|
|
||||||
ip maddr
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
# Single target scan:
|
|
||||||
nmap [target]
|
|
||||||
|
|
||||||
# Scan from a list of targets:
|
|
||||||
nmap -iL [list.txt]
|
|
||||||
|
|
||||||
# iPv6:
|
|
||||||
nmap -6 [target]
|
|
||||||
|
|
||||||
# OS detection:
|
|
||||||
nmap -O --osscan_guess [target]
|
|
||||||
|
|
||||||
# Save output to text file:
|
|
||||||
nmap -oN [output.txt] [target]
|
|
||||||
|
|
||||||
# Save output to xml file:
|
|
||||||
nmap -oX [output.xml] [target]
|
|
||||||
|
|
||||||
# Scan a specific port:
|
|
||||||
nmap -source-port [port] [target]
|
|
||||||
|
|
||||||
# Do an aggressive scan:
|
|
||||||
nmap -A [target]
|
|
||||||
|
|
||||||
# Speedup your scan:
|
|
||||||
# -n => disable ReverseDNS
|
|
||||||
# --min-rate=X => min X packets / sec
|
|
||||||
nmap -T5 --min-parallelism=50 -n --min-rate=300 [target]
|
|
||||||
|
|
||||||
# Traceroute:
|
|
||||||
nmap -traceroute [target]
|
|
||||||
|
|
||||||
# Ping scan only: -sP
|
|
||||||
# Don't ping: -PN <- Use full if a host don't reply to a ping.
|
|
||||||
# TCP SYN ping: -PS
|
|
||||||
# TCP ACK ping: -PA
|
|
||||||
# UDP ping: -PU
|
|
||||||
# ARP ping: -PR
|
|
||||||
|
|
||||||
# Example: Ping scan all machines on a class C network
|
|
||||||
nmap -sP 192.168.0.0/24
|
|
||||||
|
|
||||||
# Force TCP scan: -sT
|
|
||||||
# Force UDP scan: -sU
|
|
||||||
|
|
||||||
# Use some script:
|
|
||||||
nmap --script default,safe
|
|
||||||
|
|
||||||
# Loads the script in the default category, the banner script, and all .nse files in the directory /home/user/customscripts.
|
|
||||||
nmap --script default,banner,/home/user/customscripts
|
|
||||||
|
|
||||||
# Loads all scripts whose name starts with http-, such as http-auth and http-open-proxy.
|
|
||||||
nmap --script 'http-*'
|
|
||||||
|
|
||||||
# Loads every script except for those in the intrusive category.
|
|
||||||
nmap --script "not intrusive"
|
|
||||||
|
|
||||||
# Loads those scripts that are in both the default and safe categories.
|
|
||||||
nmap --script "default and safe"
|
|
||||||
|
|
||||||
# Loads scripts in the default, safe, or intrusive categories, except for those whose names start with http-.
|
|
||||||
nmap --script "(default or safe or intrusive) and not http-*"
|
|
||||||
|
|
||||||
# Scan for the heartbleed
|
|
||||||
# -pT:443 => Scan only port 443 with TCP (T:)
|
|
||||||
nmap -T5 --min-parallelism=50 -n --script "ssl-heartbleed" -pT:443 127.0.0.1
|
|
||||||
|
|
||||||
# Show all informations (debug mode)
|
|
||||||
nmap -d ...
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# To send a desktop notification via dbus:
|
|
||||||
notify-send -i 'icon-file/name' -a 'application_name' 'summary' 'body of message'
|
|
||||||
|
|
||||||
# The -i and -a flags can be omitted if unneeded.
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user