-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
492 lines (348 loc) · 40.6 KB
/
index.html
File metadata and controls
492 lines (348 loc) · 40.6 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>notes</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:type" content="website">
<meta property="og:title" content="notes">
<meta property="og:url" content="http://caseycoding.github.io/index.html">
<meta property="og:site_name" content="notes">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="notes">
<link rel="icon" href="/favicon.png">
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<div id="container">
<div id="wrap">
<header id="header">
<div id="banner"></div>
<div id="header-outer" class="outer">
<div id="header-title" class="inner">
<h1 id="logo-wrap">
<a href="/" id="logo">notes</a>
</h1>
</div>
<div id="header-inner" class="inner">
<nav id="main-nav">
<a id="main-nav-toggle" class="nav-icon"></a>
</nav>
<nav id="sub-nav">
<a id="nav-search-btn" class="nav-icon" title="Search"></a>
</nav>
<div id="search-form-wrap">
<form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit"></button><input type="hidden" name="sitesearch" value="http://caseycoding.github.io"></form>
</div>
</div>
</div>
</header>
<div class="outer">
<section id="main">
<article id="post-notes-2" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2018/01/02/notes-2/" class="article-date">
<time datetime="2018-01-02T17:26:07.000Z" itemprop="datePublished">2018-01-02</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/01/02/notes-2/">notes</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="bash-work-notes-by-month"><a href="#bash-work-notes-by-month" class="headerlink" title="bash work notes by month"></a>bash work notes by month</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">notes() {</div><div class="line"> subl ~/work/notes/$(date +%B)</div><div class="line">}</div></pre></td></tr></table></figure>
<h2 id="documentation-tools"><a href="#documentation-tools" class="headerlink" title="documentation tools"></a>documentation tools</h2><p><a href="http://stable.ascii-flow.appspot.com/" target="_blank" rel="external">ascii flow charting</a><br>obviously <a href="draw.io">draw.io</a><br><a href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy</a> ios</p>
<h2 id="vi"><a href="#vi" class="headerlink" title="vi"></a>vi</h2><p>w - jump by start of words (punctuation considered words)<br>W - jump by words (spaces separate words)<br>e - jump to end of words (punctuation considered words)<br>E - jump to end of words (no punctuation)</p>
<p>global find and replace<br><code>:%s/foo/bar/g</code></p>
<h2 id="Linux"><a href="#Linux" class="headerlink" title="Linux"></a>Linux</h2><h3 id="Grep"><a href="#Grep" class="headerlink" title="Grep"></a>Grep</h3><p>File pattern searcher<br>grep -E === egrep<br>grep -F === fgrep</p>
<p>basic usage<br><code>grep [options] [pattern] [file]</code></p>
<p>common options<br>-B lines before context<br>-A lines after after context<br>-C lines around context (-A num and -B num)<br>-e regex pattern</p>
<p>egrep is regex-ish grep<br>fgrep interprets pattern a a set of fixed strings separated by new lines<br>e.g. <code>grep -F -f user_list.txt /etc/group</code></p>
<p><a href="https://unix.stackexchange.com/questions/17949/what-is-the-difference-between-grep-egrep-and-fgrep" target="_blank" rel="external">src</a></p>
<h3 id="Find"><a href="#Find" class="headerlink" title="Find"></a>Find</h3><p><code>find [directory] -name Filename -type f</code><br><code>find [directory] -name ".txt"</code><br><code>find . -name Notes -type d</code><br><code>find ./Documents ./Downloads -name 30.csv</code></p>
<h3 id="Hard-vs-soft-or-symbolic-links"><a href="#Hard-vs-soft-or-symbolic-links" class="headerlink" title="Hard vs soft or symbolic links"></a>Hard vs soft or symbolic links</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"> +---------+ +-----+ +----+</div><div class="line"> |notes.txt|+----->|inode|+---->|data|</div><div class="line"> +---------+ +-----+ +----+</div><div class="line"> ^</div><div class="line"> |</div><div class="line"> +</div><div class="line">+-----------+</div><div class="line">|symlink.txt|</div><div class="line">+-----------+</div></pre></td></tr></table></figure>
<p>Hardlink points to inode<br>Symlink points to hardlink</p>
<h3 id="Sockets-and-ports"><a href="#Sockets-and-ports" class="headerlink" title="Sockets and ports"></a>Sockets and ports</h3><p>Ports are like the…port<br>Socket is like the dock number<br>One socket is used to listen for incoming connections. When something comes through, a new socket is created to handle the new request, mapped to the same port. The original socket waits for more requests.</p>
<h3 id="host-name"><a href="#host-name" class="headerlink" title="host name"></a>host name</h3><p><code>/etc/hostname</code><br><code>/etc/hosts</code></p>
<h3 id="mv-multi"><a href="#mv-multi" class="headerlink" title="mv multi"></a>mv multi</h3><p><code>mv -t DESTINATION file1 file2</code></p>
<h3 id="messaging"><a href="#messaging" class="headerlink" title="messaging"></a>messaging</h3><p><code>w</code> or <code>who</code> to display logged in users</p>
<h3 id="broadcast-to-everyone"><a href="#broadcast-to-everyone" class="headerlink" title="broadcast to everyone"></a>broadcast to everyone</h3><p><code>wall [message]</code> to broadcast the message<br>might use <code>-n</code> to omit senders info</p>
<h3 id="broadcast-to-terminal"><a href="#broadcast-to-terminal" class="headerlink" title="broadcast to terminal"></a>broadcast to terminal</h3><p>echo “Lunch” > /dev/pts/1</p>
<h3 id="open-running-chat"><a href="#open-running-chat" class="headerlink" title="open running chat"></a>open running chat</h3><p><code>write [username] [TTY]</code> e.g. <code>write dev pts/0</code></p>
<p><a href="https://unix.stackexchange.com/questions/99460/sending-messages-to-another-user" target="_blank" rel="external">src</a> <a href="https://stackoverflow.com/questions/20091681/sending-message-via-terminal-to-another-logged-on-user-bash-programming" target="_blank" rel="external">src</a></p>
<h2 id="sed"><a href="#sed" class="headerlink" title="sed"></a>sed</h2><p><code>pm2 logs 0 | sed -n '/key/p'</code><br><a href="https://stackoverflow.com/questions/5385234/using-sed-awk-to-print-lines-with-matching-pattern-or-another-matching-pattern" target="_blank" rel="external">src</a></p>
<p>multi-key<br><code>sed -EN '/key1|key2/p'</code></p>
<p><code>sed -n -e '/pattern1/p'</code> for linux?</p>
<h2 id="reload-term"><a href="#reload-term" class="headerlink" title="reload term"></a>reload term</h2><p><code>source .bashrc</code><br>(run)</p>
<h2 id="bash"><a href="#bash" class="headerlink" title="bash"></a>bash</h2><p><code>sleep 5</code><br><code>!!</code> - entire previous command<br><code>!$</code> - last<br><code>!^</code> - first<br><code>!:3</code> third<br><code>!*</code> all</p>
<p><code>date +"%B"</code> to get date</p>
<h2 id="psql-size"><a href="#psql-size" class="headerlink" title="psql size"></a>psql size</h2><p>SELECT pg_size_pretty(pg_database_size(‘torque-converter’)) As fulldbsize;</p>
</div>
<footer class="article-footer">
<a data-url="http://caseycoding.github.io/2018/01/02/notes-2/" data-id="cjd3zseim0006uk9kkbug80oh" class="article-share-link">Share</a>
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/linux/">linux</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/taking-better-notes/">taking better notes</a></li></ul>
</footer>
</div>
</article>
<article id="post-general-tools" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2017/11/26/general-tools/" class="article-date">
<time datetime="2017-11-26T09:31:00.000Z" itemprop="datePublished">2017-11-26</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/11/26/general-tools/">general tools</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="tldr"><a href="#tldr" class="headerlink" title="tldr"></a>tldr</h2><p>‘Simplified and community-driven man pages’<br><code>npm install -g tldr</code></p>
<h2 id="exa"><a href="#exa" class="headerlink" title="exa"></a>exa</h2><p>‘exa is a modern replacement for ls.’<br><code>brew install exa</code></p>
<h2 id="spectacle"><a href="#spectacle" class="headerlink" title="spectacle"></a>spectacle</h2><p>window management<br><a href="https://www.spectacleapp.com" target="_blank" rel="external">https://www.spectacleapp.com</a></p>
<h2 id="pullit"><a href="#pullit" class="headerlink" title="pullit"></a>pullit</h2><p>‘Display and pull branches from GitHub pull requests.’<br><code>npm install -g pullit</code></p>
<p>init github api in index.js with an api token to use with private repos<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">this</span>.github.authenticate({</div><div class="line"> <span class="attr">type</span>: <span class="string">'token'</span>,</div><div class="line"> <span class="attr">token</span>: <span class="string">'TOKENTOKENTOKENTOKENTOKENTOKENTOKENTOKEN'</span></div><div class="line">})</div></pre></td></tr></table></figure></p>
<h2 id="markdown-here"><a href="#markdown-here" class="headerlink" title="markdown here"></a>markdown here</h2><p><a href="https://markdown-here.com/" target="_blank" rel="external">https://markdown-here.com/</a></p>
<h2 id="octotree"><a href="#octotree" class="headerlink" title="octotree"></a>octotree</h2><p><a href="https://github.com/buunguyen/octotree" target="_blank" rel="external">https://github.com/buunguyen/octotree</a></p>
<h2 id="nimbus-products"><a href="#nimbus-products" class="headerlink" title="nimbus products"></a>nimbus products</h2><p><a href="https://nimbusweb.me/" target="_blank" rel="external">https://nimbusweb.me/</a></p>
<h2 id="art-pip"><a href="#art-pip" class="headerlink" title="art pip"></a>art pip</h2><p>art-pip</p>
</div>
<footer class="article-footer">
<a data-url="http://caseycoding.github.io/2017/11/26/general-tools/" data-id="cjd3zseim0005uk9kymmb4xwn" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-notes-1" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2017/08/16/notes-1/" class="article-date">
<time datetime="2017-08-16T20:31:36.000Z" itemprop="datePublished">2017-08-16</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/08/16/notes-1/">notes</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="kill-mongo-stuffs"><a href="#kill-mongo-stuffs" class="headerlink" title="kill mongo stuffs"></a>kill mongo stuffs</h2><p><code>db.currentOp()</code><br><code>db.currentOp( { "$ownOps": true } )</code> - only your own ops?<br><code>db.killOp([the_opid])</code></p>
<h2 id="curl-time"><a href="#curl-time" class="headerlink" title="curl time"></a>curl time</h2><p><code>-w %{time_connect}:%{time_starttransfer}:%{time_total}</code><br><code>-w '\ntime_connect: %{time_connect} time_starttransfer: %{time_starttransfer} time_total: %{time_total} size_download: %{size_download}\n'</code></p>
<h2 id="curl-follow-302"><a href="#curl-follow-302" class="headerlink" title="curl follow 302"></a>curl follow 302</h2><p><code>curl -b cookies.txt</code> with <code>-L</code> or <code>--location-trusted</code><br>This will retain the cookies from the redirect and send them back on the GET</p>
<h2 id="nodemon-exec-for-compiling-and-or-linting"><a href="#nodemon-exec-for-compiling-and-or-linting" class="headerlink" title="nodemon --exec for compiling and/or linting"></a><code>nodemon --exec</code> for compiling and/or linting</h2><p><code>nodemon --exec 'javac SomeClass.java && java SomeClass' ./SomeClass</code></p>
<h2 id="jq"><a href="#jq" class="headerlink" title="jq"></a>jq</h2><p><code>jq '.data.key.term.otherKey'</code><br><a href="https://github.com/stedolan/jq/" target="_blank" rel="external">https://github.com/stedolan/jq/</a></p>
<h2 id="create-mongo-time-stamp-from-1hr-ago-in-bash"><a href="#create-mongo-time-stamp-from-1hr-ago-in-bash" class="headerlink" title="create mongo time stamp from 1hr ago in bash"></a>create mongo time stamp from 1hr ago in bash</h2><p><code>printf 'ObjectId("%x0000000000000000")\n' $(date -v-60M -u +%s)</code></p>
<h2 id="bash-time-stamp"><a href="#bash-time-stamp" class="headerlink" title="bash time stamp"></a>bash time stamp</h2><p><code>SECONDS=0</code><br>do some work<br><code>duration=$SECONDS</code><br><code>echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."</code></p>
<h2 id="node-memory-testing"><a href="#node-memory-testing" class="headerlink" title="node memory testing"></a>node memory testing</h2><p>kill -s SIGUSR1 node_pid</p>
<p><a href="https://codefresh.io/blog/debug_node_in_docker/" target="_blank" rel="external">https://codefresh.io/blog/debug_node_in_docker/</a></p>
<h2 id="git"><a href="#git" class="headerlink" title="git"></a>git</h2><h3 id="looking-at-tags"><a href="#looking-at-tags" class="headerlink" title="looking at tags"></a>looking at tags</h3><p><code>git describe --tags</code></p>
<h3 id="set-the-author"><a href="#set-the-author" class="headerlink" title="set the author"></a>set the author</h3><p><code>git commit --author="John Doe <john@doe.com>" -m "<the usual commit message>"</code><br><a href="https://stackoverflow.com/questions/18750808/difference-between-author-and-committer-in-git" target="_blank" rel="external">src</a></p>
<h3 id="cleaning-up-branches"><a href="#cleaning-up-branches" class="headerlink" title="cleaning up branches"></a>cleaning up branches</h3><p><code>git branch -d [name]</code> - to delete<br><code>git branch --merged</code> - to see whats been merged<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">git fetch -p && <span class="keyword">for</span> branch <span class="keyword">in</span> `git branch -vv | grep <span class="string">': gone]'</span> | awk <span class="string">'{print $1}'</span>`; <span class="keyword">do</span> <span class="built_in">echo</span> <span class="variable">$branch</span>; <span class="keyword">done</span> <span class="comment"># to see what will be deleted</span></div><div class="line">git fetch -p && <span class="keyword">for</span> branch <span class="keyword">in</span> `git branch -vv | grep <span class="string">': gone]'</span> | awk <span class="string">'{print $1}'</span>`; <span class="keyword">do</span> git branch -d <span class="variable">$branch</span>; <span class="keyword">done</span> <span class="comment"># to delete</span></div></pre></td></tr></table></figure></p>
<h3 id="git-diff"><a href="#git-diff" class="headerlink" title="git diff"></a>git diff</h3><p>filter new files:<br><code>git diff origin/base origin/head --diff-filter=M</code></p>
<h2 id="find-and-replace"><a href="#find-and-replace" class="headerlink" title="find and replace"></a>find and replace</h2><p>osx:<br><code>find . -type f -name '*.csv' -exec sed -i '' "s/find/replace/g" {} \;</code><br>linux:<br><code>find . -type f -name '*.csv' -exec sed -i "s/{find}/{replace}/g" {} \;</code></p>
<h2 id="push-pop-dirs"><a href="#push-pop-dirs" class="headerlink" title="push pop dirs"></a>push pop dirs</h2><p><code>pushd</code><br><code>popd</code><br><code>dirs -l #list</code></p>
<h2 id="look-at-docker-logs-command"><a href="#look-at-docker-logs-command" class="headerlink" title="look at docker logs command"></a>look at docker logs command</h2><p><code>docker logs</code></p>
</div>
<footer class="article-footer">
<a data-url="http://caseycoding.github.io/2017/08/16/notes-1/" data-id="cjd3zsein0007uk9kehbj55qs" class="article-share-link">Share</a>
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/git/">git</a></li></ul>
</footer>
</div>
</article>
<article id="post-weekly-notes-1" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2017/06/09/weekly-notes-1/" class="article-date">
<time datetime="2017-06-09T15:19:53.000Z" itemprop="datePublished">2017-06-09</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/06/09/weekly-notes-1/">notes</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>more notes from the past few months:</p>
<h2 id="shell-notes"><a href="#shell-notes" class="headerlink" title="shell notes"></a>shell notes</h2><p>use cmd+i to set the ‘badge’ to something useful</p>
<h2 id="exit-all-ssh-sessions"><a href="#exit-all-ssh-sessions" class="headerlink" title="exit all ssh sessions"></a>exit all ssh sessions</h2><p><code>~.</code></p>
<p><a href="https://unix.stackexchange.com/questions/41682/exit-out-of-all-ssh-connections-in-one-command-and-close-putty" target="_blank" rel="external">src</a></p>
<h2 id="vi"><a href="#vi" class="headerlink" title="vi"></a>vi</h2><h3 id="vi-find"><a href="#vi-find" class="headerlink" title="vi find"></a>vi find</h3><p>/string Search forward for string<br>?string Search back for string<br>n Search for next instance of string<br>N Search for previous instance of string</p>
<h3 id="vi-delete-all-lines"><a href="#vi-delete-all-lines" class="headerlink" title="vi delete all lines"></a>vi delete all lines</h3><p><code>:1,$d</code><br><a href="https://unix.stackexchange.com/questions/161821/how-can-i-delete-all-lines-in-a-file-using-vi" target="_blank" rel="external">src</a></p>
<h3 id="vi-line-moving"><a href="#vi-line-moving" class="headerlink" title="vi line moving"></a>vi line moving</h3><blockquote>
<p>Therefore, dd p / dd k P are common commands to move a line one down / up.</p>
</blockquote>
<p><a href="https://vi.stackexchange.com/questions/2674/how-can-i-easily-move-a-line" target="_blank" rel="external">src</a></p>
<p><code>yy</code> to yank<br><code>p</code> to paste after<br><code>P</code> to paste before<br><code>u</code> to undo</p>
<h3 id="comment-out-in-vim"><a href="#comment-out-in-vim" class="headerlink" title="comment out in vim"></a>comment out in vim</h3><p>ctrl+v to enter visual block<br>x to delete selection<br>shift+I to enter edit mode on multiple lines</p>
<p><a href="https://stackoverflow.com/questions/1676632/whats-a-quick-way-to-comment-uncomment-lines-in-vim" target="_blank" rel="external">src</a></p>
<h3 id="misc"><a href="#misc" class="headerlink" title="misc"></a>misc</h3><p>:w [filename]</p>
<h2 id="curl-proxy"><a href="#curl-proxy" class="headerlink" title="curl proxy"></a>curl proxy</h2><p>-x, –proxy <a href="mailto:[protocol://][user:password@]proxyhost[:port]">[protocol://][user:password@]proxyhost[:port]</a></p>
<h2 id="find-and-kill-that-process"><a href="#find-and-kill-that-process" class="headerlink" title="find (and kill) that process"></a>find (and kill) that process</h2><p><code>ps -A | less</code><br><code>ps -A | grep firefox</code><br><code>ps -feww | grep firefox</code></p>
<p><code>kill 31098</code><br><code>kill -15 (SIGTERM) 31098</code></p>
<h2 id="webstorm"><a href="#webstorm" class="headerlink" title="webstorm"></a>webstorm</h2><p><em>minimap</em><br>CodeGlance plug in</p>
<p><em>scratch page</em><br>shift + command + n</p>
<p><em>search everywhere</em><br>shift + shift + shift</p>
<p><em>aut0-format</em><br><code>⌥+⌘+L</code><br>option + command + L</p>
<h2 id="cd-back"><a href="#cd-back" class="headerlink" title="cd back"></a>cd back</h2><p><code>cd -</code></p>
<h2 id="protobuf"><a href="#protobuf" class="headerlink" title="protobuf"></a>protobuf</h2><p>If you are running into an error with node-gyp regarding protobuf when running npm install:<br><code>brew install protobuf</code><br><code>brew install pkg-config</code></p>
<h2 id="send-output-to-file-and-console"><a href="#send-output-to-file-and-console" class="headerlink" title="send output to file and console"></a>send output to file and console</h2><p><code>tee</code> it up!</p>
<h2 id="color-output"><a href="#color-output" class="headerlink" title="color output"></a>color output</h2><p><code>console.log('\x1b[36m%s\x1b[0m', 'I am cyan');</code><br><a href="https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color" target="_blank" rel="external">https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color</a></p>
<h2 id="mongo"><a href="#mongo" class="headerlink" title="mongo"></a>mongo</h2><p><code>db.collection.find().limit(1).sort({$natural:-1})</code><br><code>.pretty()</code> on json payloads to make them…pretty.<br><code>.explain('executionStats')</code><br><code>{$regex : ".*/route$"}</code></p>
<h3 id="case-insensitive"><a href="#case-insensitive" class="headerlink" title="case insensitive"></a>case insensitive</h3><p><code>db.stuff.find( { foo: /^bar$/i } )</code><br><a href="https://stackoverflow.com/questions/1863399/mongodb-is-it-possible-to-make-a-case-insensitive-query" target="_blank" rel="external">https://stackoverflow.com/questions/1863399/mongodb-is-it-possible-to-make-a-case-insensitive-query</a></p>
<h3 id="kill-mongo-stuffs"><a href="#kill-mongo-stuffs" class="headerlink" title="kill mongo stuffs"></a>kill mongo stuffs</h3><p><code>db.currentOp()</code><br><code>db.currentOp( { "$ownOps": true } )</code> - only your own ops?<br><code>db.killOp([the_opid])</code><br><code>db.currentOp().inprog.length</code></p>
<h3 id="and-or"><a href="#and-or" class="headerlink" title="and or"></a>and or</h3><p>$and: [{expression 1}, {expression 2}]<br>$or: [{expression 1}, {expression 2}]</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line">db.collection.find({</div><div class="line"> <span class="string">"_id"</span>: {</div><div class="line"> <span class="attr">$gt</span>: ObjectId(<span class="string">"5a3ad38c0000000000000000"</span>)</div><div class="line"> },</div><div class="line"> <span class="string">"name"</span>: <span class="string">"Joe"</span>,</div><div class="line"> <span class="attr">$and</span>: [</div><div class="line"> {<span class="string">"items"</span>: {</div><div class="line"> <span class="string">"$elemMatch"</span>: {</div><div class="line"> <span class="string">"fName"</span>: <span class="regexp">/Case/i</span></div><div class="line"> }</div><div class="line"> }},</div><div class="line"> {<span class="string">"items"</span>: {</div><div class="line"> <span class="string">"$elemMatch"</span>: {</div><div class="line"> <span class="string">"lname"</span>: <span class="regexp">/Jojo/i</span></div><div class="line"> }</div><div class="line"> }}</div><div class="line"> ]</div><div class="line">}).sort({<span class="attr">$natural</span>:<span class="number">-1</span>})</div></pre></td></tr></table></figure>
<p>Max query time:<br><code>.maxTimeMS()</code></p>
<h2 id="remove-env-vars"><a href="#remove-env-vars" class="headerlink" title="remove env vars"></a>remove env vars</h2><p><code>unset <var></code></p>
<h2 id="grep"><a href="#grep" class="headerlink" title="grep"></a>grep</h2><p>multiples<br><code>grep -e foo -e bar *.txt</code></p>
<p>extra spaces<br>-A after<br>-B before<br>-C both</p>
<p><a href=":">src</a><a href="https://unix.stackexchange.com/questions/37313/how-do-i-grep-for-multiple-patterns" target="_blank" rel="external">https://unix.stackexchange.com/questions/37313/how-do-i-grep-for-multiple-patterns</a>)</p>
<h2 id="pm2"><a href="#pm2" class="headerlink" title="pm2"></a>pm2</h2><h4 id="watch"><a href="#watch" class="headerlink" title="watch"></a>watch</h4><p>–watch [paths]<br>–ignore-watch <folders|files><br>note: need to figure out how to correctly pass in ignored files</folders|files></p>
<p>using config file is easier</p>
<h4 id="node-args"><a href="#node-args" class="headerlink" title="node args"></a>node args</h4><p>“node_args”: “–prof”</p>
<h2 id="iterm"><a href="#iterm" class="headerlink" title="iterm"></a>iterm</h2><h3 id="jump-words"><a href="#jump-words" class="headerlink" title="jump words"></a>jump words</h3><p><a href="https://coderwall.com/p/h6yfda/use-and-to-jump-forwards-backwards-words-in-iterm-2-on-os-x" target="_blank" rel="external">https://coderwall.com/p/h6yfda/use-and-to-jump-forwards-backwards-words-in-iterm-2-on-os-x</a></p>
<h3 id="config-open-location"><a href="#config-open-location" class="headerlink" title="config open location"></a>config open location</h3><p><a href="https://apple.stackexchange.com/questions/148508/how-to-open-a-new-tab-in-iterm-in-the-same-folder-as-the-one-that-is-open" target="_blank" rel="external">https://apple.stackexchange.com/questions/148508/how-to-open-a-new-tab-in-iterm-in-the-same-folder-as-the-one-that-is-open</a></p>
<h3 id="command-overlord"><a href="#command-overlord" class="headerlink" title="command overlord"></a>command overlord</h3><p>command + shift + i = send command to all terminal windows</p>
<h2 id="finding-where-something-is-aliased"><a href="#finding-where-something-is-aliased" class="headerlink" title="finding where something is aliased"></a>finding where something is aliased</h2><p><code>which ls</code><br>ls: aliased to ls -G</p>
<p><code>grep -r 'ls -G' ~</code><br><a href="https://stackoverflow.com/questions/2614403/how-to-find-out-where-alias-in-the-bash-sense-is-defined-when-running-terminal" target="_blank" rel="external">src</a> (2nd answer down)</p>
<p>to override<br><code>command ls</code></p>
<h2 id="ping-to-get-ip-of-url"><a href="#ping-to-get-ip-of-url" class="headerlink" title="ping to get ip of url"></a>ping to get ip of url</h2><h2 id="windows-ssh"><a href="#windows-ssh" class="headerlink" title="windows ssh"></a>windows ssh</h2><p>eval <code>ssh-agent -s</code><br>ssh-add -l<br>ssh-add .ssh/your_id #not the pub one</p>
</div>
<footer class="article-footer">
<a data-url="http://caseycoding.github.io/2017/06/09/weekly-notes-1/" data-id="cjd3zseiq000auk9k75vlbpyr" class="article-share-link">Share</a>
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/clutch/">clutch</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/mongo/">mongo</a></li></ul>
</footer>
</div>
</article>
<article id="post-weekly-notes" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2017/05/20/weekly-notes/" class="article-date">
<time datetime="2017-05-20T16:48:59.000Z" itemprop="datePublished">2017-05-20</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/05/20/weekly-notes/">notes</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>notes from the past few months:</p>
<h2 id="Terminal-Copy"><a href="#Terminal-Copy" class="headerlink" title="Terminal Copy"></a>Terminal Copy</h2><p>copy and paste pwd form command line:<br><code>pwd | pbcopy</code> –> to copy current directory to clipboard<br>then <code>cd $(pbpaste)</code> –> to cd in different terminal</p>
<h2 id="Copying-when-sshed-in"><a href="#Copying-when-sshed-in" class="headerlink" title="Copying when sshed in"></a>Copying when sshed in</h2><p>commandThatMakesOutput | ssh (host name) pbcopy<br>need local ssh server though…</p>
<p><a href="http://stackoverflow.com/questions/1152362/getting-items-on-the-local-clipboard-from-a-remote-ssh-session" target="_blank" rel="external">src</a></p>
<h2 id="scroll-up-in-terminal"><a href="#scroll-up-in-terminal" class="headerlink" title="scroll up in terminal:"></a>scroll up in terminal:</h2><p>shit + fn up-key (page up)</p>
<h2 id="webstorm"><a href="#webstorm" class="headerlink" title="webstorm"></a>webstorm</h2><p>command 1 = project view<br>command 2 = favorites<br>command 3 = search thingy<br>esc = return to editor</p>
<h2 id="Mongo-‘the-mongo-shell-speaks-js’"><a href="#Mongo-‘the-mongo-shell-speaks-js’" class="headerlink" title="Mongo - ‘the mongo shell speaks js’"></a>Mongo - ‘the mongo shell speaks js’</h2><p>decodeURIComponent(query that returns stringified stuff)</p>
<h2 id="npm-test"><a href="#npm-test" class="headerlink" title="npm test"></a><code>npm test</code></h2><p>exit status 0 is added to the end of npm test calls</p>
<p>Use <code>; exit 0</code> to replicate this for other npm scripts.</p>
<p><a href="http://stackoverflow.com/questions/23286017/npm-error-elifecycle-while-running-the-test" target="_blank" rel="external">source of info and link to code source</a></p>
<h2 id="grep-files-with-regex"><a href="#grep-files-with-regex" class="headerlink" title="grep files with regex"></a><code>grep</code> files with regex</h2><p><code>grep -c -F /\**</code><br><code>grep ^\ *function</code></p>
<p>grep options<br>-c count<br>-F fixed string</p>
<p>control-R to search command history!!</p>
<h2 id="Broken-Git-Fetch"><a href="#Broken-Git-Fetch" class="headerlink" title="Broken Git Fetch?"></a>Broken Git Fetch?</h2><p><code>git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"</code></p>
<h2 id="Running-in-background"><a href="#Running-in-background" class="headerlink" title="Running in background"></a>Running in background</h2><p>node server.js > std.txt 2> err.txt &</p>
<p><a href="https://kb.iu.edu/d/afnz" target="_blank" rel="external">src</a></p>
<h2 id="Time-stamp-in-name"><a href="#Time-stamp-in-name" class="headerlink" title="Time stamp in name"></a>Time stamp in name</h2><p>$(date +%s)</p>
<h2 id="What-does-etc-stand-for"><a href="#What-does-etc-stand-for" class="headerlink" title="What does /etc stand for?"></a>What does /etc stand for?</h2><p><a href="http://www.aboutlinux.info/2007/03/what-does-etc-stands-for-in-linuxunix.html" target="_blank" rel="external">http://www.aboutlinux.info/2007/03/what-does-etc-stands-for-in-linuxunix.html</a></p>
<h2 id="JSON-Funzies"><a href="#JSON-Funzies" class="headerlink" title="JSON Funzies"></a>JSON Funzies</h2><p><code>json_pp</code><br><code>jq</code> - <code>jq 'if ._links.html then ._links.html.href else .errors[0].message end'</code></p>
<h2 id="Shhh-curl-shhh"><a href="#Shhh-curl-shhh" class="headerlink" title="Shhh curl, shhh"></a>Shhh curl, shhh</h2><p><code>-s</code> flag prevents process display</p>
<p><a href="http://stackoverflow.com/questions/7373752/how-do-i-get-curl-to-not-show-the-progress-bar" target="_blank" rel="external">src</a></p>
<h2 id="PM2"><a href="#PM2" class="headerlink" title="PM2"></a>PM2</h2><p>delete - start with a set environment variables<br><code>pm2 delete 0</code><br><code>pm2 start app.json --only num2</code></p>
<p>clean logs<br><code>pm2 logs [--raw] 0</code></p>
<h2 id="SSH"><a href="#SSH" class="headerlink" title="SSH"></a>SSH</h2><p><code>ssh-copy-id [username]@[addresss]</code></p>
<p><a href="https://help.ubuntu.com/community/SSH/OpenSSH/Keys" target="_blank" rel="external">src</a></p>
<h2 id="NPM"><a href="#NPM" class="headerlink" title="NPM"></a>NPM</h2><p><code>npm i -S</code> -> save as dep - this is now the default behavior in npm@5<br><code>npm i -D</code> -> save as dev dep<br><code>npm repo</code> -> go to repo<br><code>npm run</code> -> what can i run?</p>
<p><code>npm version [<newversion> | major | minor | patch ]</code></p>
<p><code>npm ls -g --depth=0</code> <code>npm uninstall -g</code><br>list and uninstall globals</p>
<p><code>npm update -g</code><br>update globals - not sure if this is recommended</p>
<p><code>npm rb</code><br>rebuild after changing node version</p>
<p><a href="https://medium.com/@adiramsalem/8-npm-tricks-you-can-use-to-impress-your-colleagues-dbdae1ef5f9e" target="_blank" rel="external">src</a></p>
<h2 id="git-reset"><a href="#git-reset" class="headerlink" title="git reset"></a>git reset</h2><p><code>git reset HEAD~</code></p>
<p><a href="http://stackoverflow.com/questions/927358/how-to-undo-last-commits-in-git" target="_blank" rel="external">src</a></p>
<p>good ref for other things:<br><a href="http://ohshitgit.com" target="_blank" rel="external">http://ohshitgit.com</a></p>
<h2 id="vi"><a href="#vi" class="headerlink" title="vi"></a>vi</h2><p><code>set number</code><br><code>:44</code><br><code>syntax off</code><br>x - to delete char under cursor</p>
<p>pasting<br><code>:set paste</code> then <code>i</code> then <code>:set nopaste</code><br><a href="https://stackoverflow.com/questions/3217007/how-do-you-paste-with-vim-without-code-being-commented" target="_blank" rel="external">src</a></p>
<h2 id="docker-port-publishing"><a href="#docker-port-publishing" class="headerlink" title="docker port publishing"></a>docker port publishing</h2><p><code>docker run -d -p 127.0.0.1:80:8080 ubuntu bash</code></p>
<p>This binds port 8080 of the container to port 80 on 127.0.0.1 of the host machine.<br>A.k.a <code>-p [host]:[container]</code>. host:container, host:container got it.</p>
</div>
<footer class="article-footer">
<a data-url="http://caseycoding.github.io/2017/05/20/weekly-notes/" data-id="cjd3zseit000euk9kc7icpx9l" class="article-share-link">Share</a>
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/clutch/">clutch</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/docker/">docker</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/git/">git</a></li></ul>
</footer>
</div>
</article>
<article id="post-notes" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2015/11/30/notes/" class="article-date">
<time datetime="2015-11-30T06:27:10.000Z" itemprop="datePublished">2015-11-30</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2015/11/30/notes/">notes</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="starting-and-stopping-mongo"><a href="#starting-and-stopping-mongo" class="headerlink" title="starting and stopping mongo"></a>starting and stopping mongo</h2><p>If you have mongodb installed via homebrew, homebrew actually has a handy brew services command. To show current running services:<br><code>brew services list</code><br>To start mongodb:<br><code>brew services start mongodb</code><br>To stop mongodb if it’s already running:<br><code>brew services stop mongodb</code></p>
<p><a href="http://stackoverflow.com/questions/8495293/whats-a-clean-way-to-stop-mongod-on-mac-os-x" target="_blank" rel="external">src</a></p>
<h2 id="yaml"><a href="#yaml" class="headerlink" title="yaml"></a>yaml</h2><p>Basically JSON</p>
<p><a href="http://www.yaml.org/start.html" target="_blank" rel="external">http://www.yaml.org/start.html</a></p>
<h2 id="ESP8266"><a href="#ESP8266" class="headerlink" title="ESP8266"></a>ESP8266</h2><p>“It is sold as a wifi to serial module.”</p>
<h2 id="nano"><a href="#nano" class="headerlink" title="nano"></a>nano</h2><p>delete line:<br>control+c+k<br><code>control-</code> will give you a line prompt<br><code>nano +[line #] filename</code> to open at line</p>
<h2 id="pi-check-disk-space"><a href="#pi-check-disk-space" class="headerlink" title="pi check disk space"></a>pi check disk space</h2><p>df -Bg</p>
<h2 id="hexo"><a href="#hexo" class="headerlink" title="hexo"></a>hexo</h2><p>hexo new [title]</p>
<p>hexo generate</p>
<p>hexo server</p>
<p>hexo deploy #sends <code>/public</code> to github</p>
<h2 id="removing-dups-in-history"><a href="#removing-dups-in-history" class="headerlink" title="removing dups in history"></a>removing dups in history</h2><p>add<br><code>HISTCONTROL=erasedups</code><br>in bash_profile/zshrc/etc</p>
</div>
<footer class="article-footer">
<a data-url="http://caseycoding.github.io/2015/11/30/notes/" data-id="cjd3zseir000buk9kdcc2xygv" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-hello-blog" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2015/11/28/hello-blog/" class="article-date">
<time datetime="2015-11-28T17:44:31.000Z" itemprop="datePublished">2015-11-28</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2015/11/28/hello-blog/">hello-blog</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>Well hello there. Nice to see you. Welcome to my alternative to bookmarks. This blog is also supported by the idea that if you have a question, so do ten of your classmates.</p>
<p>Inspired by <a href="http://kbeckmann.github.io/" target="_blank" rel="external">http://kbeckmann.github.io/</a> who added the ws2801 module to nodemcu.</p>
</div>
<footer class="article-footer">
<a data-url="http://caseycoding.github.io/2015/11/28/hello-blog/" data-id="cjd3zseip0009uk9kuebaboah" class="article-share-link">Share</a>
</footer>
</div>
</article>
</section>
</div>
<footer id="footer">
<div class="outer">
<div id="footer-info" class="inner">
© 2018 Casey Loren Billman<br>
Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
</div>
</div>
</footer>
</div>
<nav id="mobile-nav">
</nav>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script src="/js/script.js"></script>
</div>
</body>
</html>