snipt

Ctrl+h for KB shortcuts
#64056

Bash

SVN: get patch of changes between revisions

svn diff -r 70560:70561
https://snipt.net/embed/7b97016d9fda96c2361bba257a0bf448/
https://snipt.net/raw/7b97016d9fda96c2361bba257a0bf448/
7b97016d9fda96c2361bba257a0bf448
bash
Bash
1
2014-04-21T02:12:01
True
False
Jun 13, 2013 at 03:39 AM
/api/public/snipt/64056/
svn-get-patch-of-changes-between-revisions
<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 id="L-1"><a name="L-1"></a>svn diff -r 70560:70561 </span></pre></div> </td></tr></table>
svn
#64054

Bash

SVN: get overview of changed files between revisions

svn diff -r 70560:70561 --summarize [url_to_repo]
https://snipt.net/embed/563a198c91f2fb92168548b041602fc8/
https://snipt.net/raw/563a198c91f2fb92168548b041602fc8/
563a198c91f2fb92168548b041602fc8
bash
Bash
1
2014-04-10T04:01:01
True
False
Jun 13, 2013 at 03:38 AM
/api/public/snipt/64054/
svn-get-overview-of-changed-files-between-revisions
<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 id="L-1"><a name="L-1"></a>svn diff -r 70560:70561 --summarize <span class="o">[</span>url_to_repo<span class="o">]</span> </span></pre></div> </td></tr></table>
svn
#57672

Bash Session

Kill all apache instance of www-data

ps -ef | grep apache | grep www-data | sed 's/^www-data //g;' | sed 's/ .*$//g;' | xargs -L 1 sudo kill -9
https://snipt.net/embed/a41a51c287d07be3c6f3e5056f470fc9/
https://snipt.net/raw/a41a51c287d07be3c6f3e5056f470fc9/
a41a51c287d07be3c6f3e5056f470fc9
console
Bash Session
1
2014-04-16T04:15:09
True
False
Mar 15, 2013 at 09:44 AM
/api/public/snipt/57672/
kill-all-apache-instance-of-www-data
<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 id="L-1"><a name="L-1"></a><span class="go">ps -ef | grep apache | grep www-data | sed &#39;s/^www-data //g;&#39; | sed &#39;s/ .*$//g;&#39; | xargs -L 1 sudo kill -9</span> </span></pre></div> </td></tr></table>
#39369

Bash

Bash: Backup file, without overwrite

1
2
3
4
5
6
7
# Backup file, without overwrite
function bf {
  SAN_TIMESTAMP=$(date +%y%m%d)'_'$(date +%H%M%S)
  cp $1 $1'.backup.'$SAN_TIMESTAMP
  # Prevent actually overwriting the file by making it read only.
  chmod 444 $1'.backup.'$SAN_TIMESTAMP
}
https://snipt.net/embed/87f4403b982dedb92d5a35b020f76019/
https://snipt.net/raw/87f4403b982dedb92d5a35b020f76019/
87f4403b982dedb92d5a35b020f76019
bash
Bash
7
2014-04-15T22:57:26
True
False
/api/public/snipt/39369/
bash-backup-file-without-overwrite
<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 id="L-1"><a name="L-1"></a><span class="c"># Backup file, without overwrite</span> </span><span id="L-2"><a name="L-2"></a><span class="k">function </span>bf <span class="o">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">SAN_TIMESTAMP</span><span class="o">=</span><span class="k">$(</span>date +%y%m%d<span class="k">)</span><span class="s1">&#39;_&#39;</span><span class="k">$(</span>date +%H%M%S<span class="k">)</span> </span><span id="L-4"><a name="L-4"></a> cp <span class="nv">$1</span> <span class="nv">$1</span><span class="s1">&#39;.backup.&#39;</span><span class="nv">$SAN_TIMESTAMP</span> </span><span id="L-5"><a name="L-5"></a> <span class="c"># Prevent actually overwriting the file by making it read only.</span> </span><span id="L-6"><a name="L-6"></a> chmod 444 <span class="nv">$1</span><span class="s1">&#39;.backup.&#39;</span><span class="nv">$SAN_TIMESTAMP</span> </span><span id="L-7"><a name="L-7"></a><span class="o">}</span> </span></pre></div> </td></tr></table>
backup, bash
#38059

Bash

Copy a file from one machine to another using scp

1
2
3
Example of copying config.php to the /tmp directory on 10.10.132.67 with user 'sander' on port 2145

scp -P 2145 config.php sander@10.10.132.67:/tmp/
https://snipt.net/embed/f157419363fde992f66e5bec39944e66/
https://snipt.net/raw/f157419363fde992f66e5bec39944e66/
f157419363fde992f66e5bec39944e66
bash
Bash
3
2014-04-11T02:49:36
True
False
/api/public/snipt/38059/
copy-a-file-from-one-machine-to-another-using-scp
<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 id="L-1"><a name="L-1"></a>Example of copying config.php to the /tmp directory on 10.10.132.67 with user <span class="s1">&#39;sander&#39;</span> on port 2145 </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>scp -P 2145 config.php sander@10.10.132.67:/tmp/ </span></pre></div> </td></tr></table>
scp, ubuntu
#37147

Text only

Regular expression to find emailaddresses in a string

[\w\-][\w\-\.]+@[\w\-][\w\-\.]+[a-zA-Z]{1,4}
https://snipt.net/embed/e856dc44f76107e055a2c46c08398c42/
https://snipt.net/raw/e856dc44f76107e055a2c46c08398c42/
e856dc44f76107e055a2c46c08398c42
text
Text only
1
2014-04-05T07:40:18
True
False
/api/public/snipt/37147/
regular-expression-to-find-emailaddresses-in-a-string
<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 id="L-1"><a name="L-1"></a>[\w\-][\w\-\.]+@[\w\-][\w\-\.]+[a-zA-Z]{1,4} </span></pre></div> </td></tr></table>
regex
#35972

CSS

Excluding only a few IE browsers

1
2
3
4
5
This snippet will only show content to browsers IE9 and higher. Of course this will also show all included content to any other non-IE browser.

<!--[if IE]><![if gt IE 8]><![endif]-->
More HTML...
<!--[if IE]><![endif]><![endif]-->
https://snipt.net/embed/0088e43494e39ec0c07f2bd6ba0f6b5f/
https://snipt.net/raw/0088e43494e39ec0c07f2bd6ba0f6b5f/
0088e43494e39ec0c07f2bd6ba0f6b5f
css
CSS
5
2014-04-06T17:18:37
True
False
Jul 18, 2012 at 04:39 AM
/api/public/snipt/35972/
exluding-only-a-few-ie-browsers
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nt">This</span> <span class="nt">snippet</span> <span class="nt">will</span> <span class="nt">only</span> <span class="nt">show</span> <span class="nt">content</span> <span class="nt">to</span> <span class="nt">browsers</span> <span class="nt">IE9</span> <span class="nt">and</span> <span class="nt">higher</span><span class="o">.</span> <span class="nt">Of</span> <span class="nt">course</span> <span class="nt">this</span> <span class="nt">will</span> <span class="nt">also</span> <span class="nt">show</span> <span class="nt">all</span> <span class="nt">included</span> <span class="nt">content</span> <span class="nt">to</span> <span class="nt">any</span> <span class="nt">other</span> <span class="nt">non-IE</span> <span class="nt">browser</span><span class="o">.</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="o">&lt;!</span><span class="nt">--</span><span class="o">[</span><span class="nt">if</span> <span class="nt">IE</span><span class="o">]&gt;&lt;![</span><span class="nt">if</span> <span class="nt">gt</span> <span class="nt">IE</span> <span class="nt">8</span><span class="o">]&gt;&lt;![</span><span class="nt">endif</span><span class="o">]</span><span class="nt">--</span><span class="o">&gt;</span> </span><span id="L-4"><a name="L-4"></a><span class="nt">More</span> <span class="nt">HTML</span><span class="o">...</span> </span><span id="L-5"><a name="L-5"></a><span class="o">&lt;!</span><span class="nt">--</span><span class="o">[</span><span class="nt">if</span> <span class="nt">IE</span><span class="o">]&gt;&lt;![</span><span class="nt">endif</span><span class="o">]&gt;&lt;![</span><span class="nt">endif</span><span class="o">]</span><span class="nt">--</span><span class="o">&gt;</span> </span></pre></div> </td></tr></table>
"conditional comments", css, ie
#35937

Bash

Review each SVN version controlled file with meld which has been modified

1
2
3
4
5
svn st | grep '^M' | sed 's/^M       //g;' | xargs -L 1 meld
sed: simpele search and replace
xargs (3): view every file in meld, one at a time (-L 1)

Note: the match may differ: s/^M      //g;
https://snipt.net/embed/ffc7bb31907cdc9c3b1d93dee453fdf3/
https://snipt.net/raw/ffc7bb31907cdc9c3b1d93dee453fdf3/
ffc7bb31907cdc9c3b1d93dee453fdf3
bash
Bash
5
2014-04-15T07:37:58
True
False
/api/public/snipt/35937/
review-each-svn-version-controlled-file-which-has-been-modified-with-meld
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>svn st <span class="p">|</span> grep <span class="s1">&#39;^M&#39;</span> <span class="p">|</span> sed <span class="s1">&#39;s/^M //g;&#39;</span> <span class="p">|</span> xargs -L 1 meld </span><span id="L-2"><a name="L-2"></a>sed: simpele search and replace </span><span id="L-3"><a name="L-3"></a>xargs <span class="o">(</span>3<span class="o">)</span>: view every file in meld, one at a <span class="nb">time</span> <span class="o">(</span>-L 1<span class="o">)</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>Note: the match may differ: s/^M //g<span class="p">;</span> </span></pre></div> </td></tr></table>
diff, meld, svn