snipt

Ctrl+h for KB shortcuts

Text only

Diff two trees

1
2
3
diff -qr pathA pathB

diff --brief -r pathA pathB    list files missing, added, modified
https://snipt.net/embed/97627a32450c7f8f1c20f66d8d415ebb/
/raw/97627a32450c7f8f1c20f66d8d415ebb/
97627a32450c7f8f1c20f66d8d415ebb
text
Text only
3
2019-08-22T00:30:34
True
False
False
Nov 09, 2012 at 12:04 PM
/api/public/snipt/48008/
diff-two-trees
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>diff -qr pathA pathB </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>diff --brief -r pathA pathB list files missing, added, modified </span></pre></div> </td></tr></table>

reStructuredText

sed replace newline

1
2
3
4
5
6
7
sed ':a;N;$!ba;s/\n/ /g'

from Zsolt Botykai on Stack overflow
1. create a register via :a
2. append the current and next line to the register via N
3. if we are before the last line, branch to the created register $!ba (`$! means not to do it on the last line (as there should be one final newline)).
4. finally the substitution replaces every newline with a space on the pattern space (which is the contents of the a register = the whole file.
https://snipt.net/embed/6bd52988f141491bd5ccf11da28520fb/
/raw/6bd52988f141491bd5ccf11da28520fb/
6bd52988f141491bd5ccf11da28520fb
rst
reStructuredText
7
2019-08-24T18:37:05
True
False
False
/api/public/snipt/20880/
sed-replace-newline
<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> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>sed &#39;:a;N;$!ba;s/\n/ /g&#39; </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>from Zsolt Botykai on Stack overflow </span><span id="L-4"><a name="L-4"></a><span class="m">1.</span> create a register via :a </span><span id="L-5"><a name="L-5"></a><span class="m">2.</span> append the current and next line to the register via N </span><span id="L-6"><a name="L-6"></a><span class="m">3.</span> if we are before the last line, branch to the created register $!ba (`$! means not to do it on the last line (as there should be one final newline)). </span><span id="L-7"><a name="L-7"></a><span class="m">4.</span> finally the substitution replaces every newline with a space on the pattern space (which is the contents of the a register = the whole file. </span></pre></div> </td></tr></table>
newline, replace, sed

XML

ant simple logging

1
2
3
4
5
6
7
    <target name="-log-init" unless="log.initialized">
        <!-- you can set build.log.dir prior and count on immutability to preserve value -->        
        <property name="log.initialized" value="yes"/>
        <property name="build.log.dir" location="${basedir}"/>
        <record name="${build.log.dir}/build.log" action="start"/>
        <record name="${build.log.dir}/build.dbg" action="start" loglevel="debug"/>
    </target>
https://snipt.net/embed/aaaf2c44a8c421fc546dd3d2b8412526/
/raw/aaaf2c44a8c421fc546dd3d2b8412526/
aaaf2c44a8c421fc546dd3d2b8412526
xml
XML
8
2019-08-23T05:25:10
True
False
False
/api/public/snipt/19389/
ant-simple-logging
<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> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a> <span class="nt">&lt;target</span> <span class="na">name=</span><span class="s">&quot;-log-init&quot;</span> <span class="na">unless=</span><span class="s">&quot;log.initialized&quot;</span><span class="nt">&gt;</span> </span><span id="L-2"><a name="L-2"></a> <span class="c">&lt;!-- you can set build.log.dir prior and count on immutability to preserve value --&gt;</span> </span><span id="L-3"><a name="L-3"></a> <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;log.initialized&quot;</span> <span class="na">value=</span><span class="s">&quot;yes&quot;</span><span class="nt">/&gt;</span> </span><span id="L-4"><a name="L-4"></a> <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;build.log.dir&quot;</span> <span class="na">location=</span><span class="s">&quot;${basedir}&quot;</span><span class="nt">/&gt;</span> </span><span id="L-5"><a name="L-5"></a> <span class="nt">&lt;record</span> <span class="na">name=</span><span class="s">&quot;${build.log.dir}/build.log&quot;</span> <span class="na">action=</span><span class="s">&quot;start&quot;</span><span class="nt">/&gt;</span> </span><span id="L-6"><a name="L-6"></a> <span class="nt">&lt;record</span> <span class="na">name=</span><span class="s">&quot;${build.log.dir}/build.dbg&quot;</span> <span class="na">action=</span><span class="s">&quot;start&quot;</span> <span class="na">loglevel=</span><span class="s">&quot;debug&quot;</span><span class="nt">/&gt;</span> </span><span id="L-7"><a name="L-7"></a> <span class="nt">&lt;/target&gt;</span> </span></pre></div> </td></tr></table>
ant, logging