snipt

Ctrl+h for KB shortcuts

Bash

get remote server cert in PEM format

1
2
3
4
server="www.example.com"
port=443
outFile="/some/file"
openssl s_client -showcerts -connect "$server:$port" < /dev/null | openssl x509 -outform PEM > "$outFile"
https://snipt.net/embed/eeaaedbea37b185b18e01b400ff00db6/
/raw/eeaaedbea37b185b18e01b400ff00db6/
eeaaedbea37b185b18e01b400ff00db6
bash
Bash
4
2017-01-01T11:25:26
True
False
True
Sep 30, 2015 at 07:12 AM
/api/public/snipt/141318/
get-remote-server-cert-in-pem-format
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nv">server</span><span class="o">=</span><span class="s2">&quot;www.example.com&quot;</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">port</span><span class="o">=</span>443 </span><span id="L-3"><a name="L-3"></a><span class="nv">outFile</span><span class="o">=</span><span class="s2">&quot;/some/file&quot;</span> </span><span id="L-4"><a name="L-4"></a>openssl s_client -showcerts -connect <span class="s2">&quot;</span><span class="nv">$server</span><span class="s2">:</span><span class="nv">$port</span><span class="s2">&quot;</span> &lt; /dev/null <span class="p">|</span> openssl x509 -outform PEM &gt; <span class="s2">&quot;</span><span class="nv">$outFile</span><span class="s2">&quot;</span> </span></pre></div> </td></tr></table>
bash, linux, openssl

Bash

linux > check if username exists

$ id -u name
https://snipt.net/embed/067c62975fc052fa0821b7b3ae80a4c5/
/raw/067c62975fc052fa0821b7b3ae80a4c5/
067c62975fc052fa0821b7b3ae80a4c5
bash
Bash
1
2019-06-16T05:58:32
True
False
False
Feb 03, 2015 at 07:45 PM
/api/public/snipt/138039/
linux-check-if-username-exists-bc795ca7
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ id -u name </span></pre></div> </td></tr></table>
bash, linux, ubuntu

Bash

find and delete files older than 15 minutes

$ find /path/to/files/*.json -type f -mmin +15 -delete
https://snipt.net/embed/526b8c150780e8fd47ad7b0adaac0e65/
/raw/526b8c150780e8fd47ad7b0adaac0e65/
526b8c150780e8fd47ad7b0adaac0e65
bash
Bash
1
2019-06-24T03:13:02
True
False
False
/api/public/snipt/137461/
find-and-delete-files-older-than-15-minutes-e01e1c63
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ find /path/to/files/*.json -type f -mmin +15 -delete </span></pre></div> </td></tr></table>
bash, delete, find, linux

Bash

Useful bash command snippets

1
2
3
4
5
6
# Clean all dirs that have mvn builds in them to 
# recover space taken up by /target dirs that are not used
for foo in *; do cd $foo; mvn clean; cd ..; done

# clean all SNAPSHOT items from the local maven repo
cd .m2/repository && find . -name '*-SNAPSHOT' -print0 | xargs -0 rm -rf
https://snipt.net/embed/b52b012c361bfbb20511292c266400c9/
/raw/b52b012c361bfbb20511292c266400c9/
b52b012c361bfbb20511292c266400c9
bash
Bash
6
2019-06-25T03:03:45
True
False
False
/api/public/snipt/136637/
useful-bash-command-snippets-3c6e6349
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># Clean all dirs that have mvn builds in them to </span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># recover space taken up by /target dirs that are not used</span> </span><span id="L-3"><a name="L-3"></a><span class="k">for</span> foo in *<span class="p">;</span> <span class="k">do</span> <span class="nb">cd</span> <span class="nv">$foo</span><span class="p">;</span> mvn clean<span class="p">;</span> <span class="nb">cd</span> ..<span class="p">;</span> <span class="k">done</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="c1"># clean all SNAPSHOT items from the local maven repo</span> </span><span id="L-6"><a name="L-6"></a><span class="nb">cd</span> .m2/repository <span class="o">&amp;&amp;</span> find . -name <span class="s1">&#39;*-SNAPSHOT&#39;</span> -print0 <span class="p">|</span> xargs -0 rm -rf </span></pre></div> </td></tr></table>
bash, cleanup, maven, shell

Bash

ImageMagick list supported formats

$ identify -list format|grep -i webp
https://snipt.net/embed/4435a262d53e289d0f8ba79119675c06/
/raw/4435a262d53e289d0f8ba79119675c06/
4435a262d53e289d0f8ba79119675c06
bash
Bash
1
2019-06-24T18:29:41
True
False
False
/api/public/snipt/135538/
imagemagick-list-supported-formats-8e405b30
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ identify -list format<span class="p">|</span>grep -i webp </span></pre></div> </td></tr></table>
bash, conversion, imagemagick

Bash

OSX install imagemagick with WEBP and TIFF support

$ brew install imagemagick --with-webp --with-libtiff
https://snipt.net/embed/7776a00a6468dbe85bb3eb07f987c85a/
/raw/7776a00a6468dbe85bb3eb07f987c85a/
7776a00a6468dbe85bb3eb07f987c85a
bash
Bash
1
2019-06-26T11:50:57
True
False
False
/api/public/snipt/135508/
osx-install-imagemagick-with-webp-and-tiff-support-27ac9e32
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ brew install imagemagick --with-webp --with-libtiff </span></pre></div> </td></tr></table>
bash, imagemagick

Bash

Better Git log

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
https://snipt.net/embed/1feea14ac5545403b2027bbe7046b8a0/
/raw/1feea14ac5545403b2027bbe7046b8a0/
1feea14ac5545403b2027bbe7046b8a0
bash
Bash
2
2019-06-24T00:11:56
True
False
False
Feb 24, 2014 at 11:00 AM
/api/public/snipt/116374/
better-git-log
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>git config --global alias.lg <span class="s2">&quot;log --color --graph --pretty=format:&#39;%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)&lt;%an&gt;%Creset&#39; --abbrev-commit&quot;</span> </span></pre></div> </td></tr></table>
bash, git