-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.html
More file actions
527 lines (496 loc) · 17.7 KB
/
index.html
File metadata and controls
527 lines (496 loc) · 17.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Web Dev Cheat-sheets</title>
<link href="index.css" type="text/css" rel="stylesheet">
</head>
<body>
<header>
<h1>Web Dev Cheat-sheets</h1>
<nav>
<ul>
<li><a href="#HTML">HTML</a></li>
<li><a href="#CSS">CSS</a></li>
<li><a href="#DOM">DOM</a></li>
<li><a href="#JS">JS</a></li>
<li><a href="#git">Git</a></li>
</ul>
</nav>
</header>
<main>
<section id="HTML">
<h2>HTML Cheat-sheet</h2>
<article id="form">
<h3>Forms</h3>
<pre><form>
<fieldset>
<legend>Describes fieldset</legend>
<p>
<input type="radio" name="vertical" id="option1" value="top">
<label for="option1">Top</label>
</p>
<p>
<label for="option2">
<input type="radio" name="vertical" id="option2" value="bottom"> Bottom
</label>
</p>
<p>
<label for="horizontal">
Horizontal:
</label>
<select id="horizontal" name="horizontal">
<option value="left">Left</option>
<option value="middle">Middle</option>
<option value="right">Right</option>
</select>
</p>
</fieldset>
</form></pre>
</article>
<article id="semantic">
<h3>Semantic Markup</h3>
<pre><html lang="en">
<head>
<title>Title<title>
</head>
<body>
<header>
Logo, title, navigation
<nav>
Primary and secondary menus but ever nest navs
</nav>
</header>
<section>
Related grouping of semantic meaning
<article>
Self-contained content
</article>
<article>
Would still make sense if all other content removed
<aside>
<blockquote>
Related to main but outside the main flow
</blockquote>
</aside>
</article>
</section>
<footer>
Copyright, contact, links
</footer>
</body>
</html></pre>
</article>
<article id="table">
<h3>Tables</h3>
<pre><table>
<caption>Table Caption</caption>
<colgroup>
<col>
<col span="2" class="left-two">
<col span="2" class="right-two">
</colgroup>
<thead>
<tr>
<th></th>
<th colspan="2">Left Two</th>
<th colspan="2">Right Two</th>
</tr>
</thead>
<tbody>
<tr>
<th rowspan="2">Top Two</th>
<td>Body 1,1</td>
<td>Body 1,2</td>
<td>Body 1,3</td>
<td>Body 1,4</td>
</tr>
<tr>
<td>Body 2,1</td>
<td>Body 2,2</td>
<td>Body 2,3</td>
<td>Body 2,4</td>
</tr>
<tr>
<th rowspan="2">Bottom Two</th>
<td>Body 3,1</td>
<td>Body 3,2</td>
<td>Body 3,3</td>
<td>Body 3,4</td>
</tr>
<tr>
<td>Body 4,1</td>
<td>Body 4,2</td>
<td>Body 4,3</td>
<td>Body 4,4</td>
</tr>
</tbody>
<tfoot>
<tr>
<th></th>
<td>Footer 1</td>
<td>Footer 2</td>
<td>Footer 3</td>
<td>Footer 4</td>
</tr>
</tfoot>
</table></pre>
</article>
</section>
<section id="CSS">
<h2>CSS Cheat-sheet</h2>
<article id="color">
<h3>Coloring</h3>
</article>
<article id="position">
<h3>Positioning</h3>
<div>
<pre>position: <b>static</b> | relative | absolute | sticky</pre>
<p>sets element's positioning, along with top, left, bottom, right properties</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/position">MDN</a>
</div>
<div>
<pre>margin 0 auto</pre>
<p>centers block in containing block</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/margin">MDN</a>
</div>
<div>
<pre>overflow: <b>visible</b> | hidden | scroll | auto | clip | hidden visible</pre>
<p>how to render content outside content-box</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/overflow">MDN</a>
</div>
</article>
<article id="size">
<h3>Sizing</h3>
<div>
<pre>box-sizing: <b>content-box</b> | border-box</pre>
<p>content-box is default</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing">MDN</a>
</div>
</article>
<div>
<pre>height: <px | em | % | keyword></pre>
<p>Sets height for non-inline elements</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/height">MDN</a>
</div>
<div>
<pre>width: <px | em | % | keyword></pre>
<p>Sets width for non-inline elements</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/width">MDN</a>
</div>
</section>
<section id="DOM">
<h2>DOM Cheat-sheet</h2>
<article id="query">
<h3>Querying/Selecting Elements</h3>
<div>
<pre>document.getElementById(id)</pre>
<p>returns element object by id</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById">MDN</a>
</div>
<div>
<pre>document.getElementsByClassName(className)</pre>
<p>returns live HTMLCollection of elements by class</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName">MDN</a>
</div>
<div>
<pre>document.getElementsByTagName(tagName)</pre>
<p>returns live HTMLCollection of elements by tag</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/document/getElementsByTagName">MDN</a>
</div>
<div>
<pre>document.querySelector(cssSelector)</pre>
<p>returns the first element matching selector(s)</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector">MDN</a>
</div>
<div>
<pre>document.querySelectorAll(cssSelector)</pre>
<p>returns static NodeList representing elements matching selector(s)</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll">MDN</a>
</div>
</article>
<article id="select">
<h3>Traversing Elements</h3>
<div>
<pre>firstElementChild, lastElementChild</pre>
<p>returns first/last child element or null if none</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/ParentNode">MDN</a>
</div>
<div>
<pre>nextElementChild, previousElementChild
nextElementSibling, previousElementSibling
parentNode, childNodes, childElementCount</pre>
<p>self-explanatory</p>
<a href="https://javascript.info/dom-navigation#siblings-and-the-parent">JAVASCRIPT.INFO</a>
</div>
</article>
</section>
<section id="JS">
<h2>JavaScript Cheat-sheet</h2>
<article id="arrays">
<h3>Arrays</h3>
<div>
<pre>Array.from(arrayLike[, mapFn[, thisArg]])</pre>
<p>creates mapped array from array-like iterable object</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from">MDN</a>
</div>
<div>
<pre>Array.prototype.includes(valueToFind[, fromIndex])</pre>
<p>returns true if value found</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes">MDN</a>
</div>
</article>
<article id="objects">
<h3>Objects</h3>
<div>
<pre>Object.prototype.hasOwnProperty('property')</pre>
<p>returns true of object has property (not inherited) specified in string</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty">MDN</a>
</div>
<div>
<pre>for (let [key, value] of Object.entries(object1))</pre>
<p>returns array of object's keys and values: <strong>[key, value]</strong></p>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries">MDN</a>
</div>
<div>
<pre>console.log(Object.keys(object1))</pre>
<p>returns array of object's own property names</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys">MDN</a>
</div>
</article>
<article id="strings">
<h3>Strings</h3>
<div>
<pre>stringVar.includes(searchString[, position])</pre>
<p>returns true if searchString found in stringVar, beginning at position</p>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes">MDN</a>
</div>
</article>
<article id="misc">
<h3>Miscellaneous</h3>
<div>
<pre>parseInt(process.version.slice(1))</pre>
<p>returns node's major version number</p>
<a href="https://nodejs.org/en/knowledge/getting-started/the-process-module/">nodejs article</a>
<a href="https://nodejs.org/dist/latest-v13.x/docs/api/process.html#process_process_version">nodejs docs</a>
</div>
<div>
<pre>typeof variable === "undefined"</pre>
<p>checks if variable is defined<em>--do not forget the quotes since:</em><strong> typeof typeof whatever === "string"</strong></p>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof">MDN</a>
</div>
</article>
</section>
<section id="git">
<h2>Git Cheat-sheet</h2>
<article id="view">
<h3>Viewing</h3>
<div>
<pre>git log --oneline</pre>
<p>shows most concise history format</p>
<a href="https://git-scm.com/docs/git-log">git reference</a>
</div>
<div>
<pre>git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=human</pre>
<p>shows a practical format</p>
</div>
</article>
<article id="create">
<h3>Creating and Committing</h3>
<div>
<pre>git init</pre>
<p>creates local repository<em>--don't forget .gitignore</em></p>
</div>
<div>
<pre>git clone <http | https | ssh | git URL></pre>
<p>(http and git don't require credentials)</p>
</div>
<div>
<pre>git add -A [-v]</pre>
<p>adds, modifies, and removes entries to match working tree</p>
<a href="https://git-scm.com/docs/git-add">git reference</a>
</div>
<div>
<pre>git add -u [-v]</pre>
<p>removes and modifies entries to match working tree; adds nothing</p>
</div>
<div>
<pre>git rm <i><file></i></pre>
<p>removes file from working tree and index</p>
</div>
<div>
<pre>git commit -m <i>"Message"</i></pre>
<p>commits working tree to branch</p>
<a href="https://git-scm.com/docs/git-commit">git reference</a>
<a href="https://chris.beams.io/posts/git-commit/#seven-rules">rules</a>
</div>
<div>
<pre>git commit --amend -m <i>"New message"</i></pre>
<p>add changes and/or changes message to last commit</p>
</div>
</article>
<article id="branch">
<h3>Branching and Merging</h3>
<div>
<pre>git branch -vva</pre>
<p>lists all local and remote branches</p>
</div>
<div>
<pre>git branch <i><branch-name></i></pre>
<p>creates new branch</p>
</div>
<div>
<pre>git branch -d <i><branch-name></i></pre>
<p>deletes local branch</p>
</div>
<div>
<pre>git checkout <i><branch-name></i></pre>
<p>checks out local branch</p>
</div>
<div>
<pre>git checkout -b <i><branch-name></i></pre>
<p>shortcut for git branch + git checkout <branch-name></p>
</div>
<div>
<pre>git merge <i><branch-name></i></pre>
<p>merges branch-name into current checked-out branch</p>
</div>
<div>
<pre>git merge --abort</pre>
<p>aborts merge during conflict resolution</p>
</div>
</article>
<article id="stash">
<h3>Stashing</h3>
<div>
<pre>git stash</pre>
<p>stashes local changes and cleans working directory</p>
</div>
<div>
<pre>git stash list</pre>
<p>lists stashes, newest on top</p>
</div>
<div>
<pre>git stash pop</pre>
<p>applies changes to working directory and removes stash</p>
</div>
<div>
<pre>git stash apply [<i>stash-name</i>]</pre>
<p>applies changes but keeps stash</p>
</div>
<div>
<pre>git stash drop [<i>stash-name</i>]</pre>
<p>deletes stash</p>
</div>
</article>
<article id="undo">
<h3>Undoing</h3>
<div>
<pre>git checkout <i>file/to/restore.ext</i></pre>
<p>restores a file to the last committed version</p>
</div>
<div>
<pre>git reset HEAD <i>file/to/unstage.ext</i></pre>
<p>clears staging area of staged changes without changing working copy</p>
<a href="https://git-scm.com/docs/git-reset">git reference</a>
</div>
<div>
<pre>git reset --hard <HEAD | 7-hash-digits></pre>
<p>replaces working copy files with last or specified commit, moves HEAD</p>
</div>
<div>
<pre>git revert <HEAD | 7-hash-digits></pre>
<p>produces new commit with changes to revert to last or specified commit</p>
</div>
</article>
<article id="remote">
<h3>Remote</h3>
<div>
<pre>git remote add <i>upstream</i> <http | https | ssh | git URL></pre>
<p>adds remote repository</p>
</div>
<div>
<pre>git remote -v</pre>
<p>lists remote repositories with URLs</p>
</div>
<div>
<pre>git fetch <i>origin</i></pre>
<p>updates local information about the remote</p>
</div>
<div>
<pre>git pull [<i>upstream master</i>]</pre>
<p>fetches and merges remote commits</p>
</div>
<div>
<pre>git checkout --track <i>origin/branch-name</i></pre>
<p>creates and checks out local branch with same name as remote</p>
</div>
<div>
<pre>git push [-u <i>origin branch-name</i>]</pre>
<p>uploads local commits to remote, [optional] required if not tracked</p>
</div>
<div>
<pre>git push origin --delete <i>branch-name</i></pre>
<p>deletes remote branch</p>
</div>
</article>
<article id="config">
<h3>Configuring</h3>
<div>
<pre>git config --list [--local|--global][ | sort]</pre>
<p>shows current configuration</p>
<a href="https://git-scm.com/docs/git-config">git reference</a>
</div>
<div>
<pre>git config [--global] core.editor <i>/path/to/editor</i></pre>
<p>selects editor for blank commit comment</p>
</div>
</article>
<article id="workflow">
<h3>Workflow</h3>
<div>
<p>From:</p> <a href="https://learn-2.galvanize.com/cohorts/1792/blocks/111/content_files/Git_and_the_Command_Line/git-workflow-overview.md">HR Git Workflow</a>
<ol>
<li>Fork project from <a href="https://github.com/orgs/hackreactor/dashboard">hackreactor</a> GitHub</li>
<li>Clone GitHub forked project to local machine
<pre>git clone https://github.com/<i>USER_NAME/REPOSITORY_NAME</i>.git</pre>
</li>
<li>Add remote to point to original (upstream) repo
<pre>git remote add upstream https://github.com/<i>USER_NAME/REPOSITORY_NAME</i>.git</pre>
</li>
<li>Check for correct branch and clean staging area
<pre>git status</pre>
</li>
<li>Make smallest possible change to add or improve something; review
<pre>git status, git diff</pre>
</li>
<li>Add files to commit
<pre>git add, git status</pre>
</li>
<li>Commit changes
<pre>git commit, git status</pre>
</li>
<li>Push changes to GitHub fork
<pre>git push origin master</pre>
</li>
</ol>
</div>
</article>
</section>
<footer>
<h6>
2020 J.West <a href="https://www.gnu.org/licenses/gpl-3.0.html">GPLv3</a>
</h6>
</footer>
</main>
<!-- <script src="index.js"></script>-->
</body>
</html>
<!--
TODO:
** CSS **
position
z-index
** DOM **
Objects: document, window, global
-->