snipt

Ctrl+h for KB shortcuts

Bash

Delete svn:ignore property

svn propdel svn:ignore .
https://snipt.net/embed/e8e941604140a7c6367e9ca4377f9fc0/
/raw/e8e941604140a7c6367e9ca4377f9fc0/
e8e941604140a7c6367e9ca4377f9fc0
bash
Bash
1
2019-08-21T15:28:43
True
False
False
/api/public/snipt/49131/
delete-svnignore-property
<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>svn propdel svn:ignore . </span></pre></div> </td></tr></table>

SQL

Delete Database That Has Active Connections

1
2
3
SELECT * FROM pg_stat_activity WHERE datname = '<database_name>';
SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '<database_name>';
DROP DATABASE '<database_name>'
https://snipt.net/embed/26717b31e0878d6cd8dbedee6492e2e4/
/raw/26717b31e0878d6cd8dbedee6492e2e4/
26717b31e0878d6cd8dbedee6492e2e4
sql
SQL
3
2019-08-21T15:29:04
True
False
False
Mar 10, 2014 at 10:02 PM
/api/public/snipt/120719/
delete-database-that-has-active-connections
<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><span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="n">pg_stat_activity</span> <span class="k">WHERE</span> <span class="n">datname</span> <span class="o">=</span> <span class="s1">&#39;&lt;database_name&gt;&#39;</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a><span class="k">SELECT</span> <span class="n">pg_terminate_backend</span> <span class="p">(</span><span class="n">pg_stat_activity</span><span class="p">.</span><span class="n">pid</span><span class="p">)</span> <span class="k">FROM</span> <span class="n">pg_stat_activity</span> <span class="k">WHERE</span> <span class="n">pg_stat_activity</span><span class="p">.</span><span class="n">datname</span> <span class="o">=</span> <span class="s1">&#39;&lt;database_name&gt;&#39;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">DROP</span> <span class="k">DATABASE</span> <span class="s1">&#39;&lt;database_name&gt;&#39;</span> </span></pre></div> </td></tr></table>
postgresql

Bash

Roll back to a previous revision in Subversion

1
2
3
svn update
svn merge -r <current_revision>:<previous_revision> .
svn commit -m "Rolled back to <previous_revision>"
https://snipt.net/embed/c57cef74727cd13166ea5c64176c10ff/
/raw/c57cef74727cd13166ea5c64176c10ff/
c57cef74727cd13166ea5c64176c10ff
bash
Bash
3
2019-08-21T05:19:38
True
False
False
/api/public/snipt/105516/
roll-back-to-a-previous-revision-in-subversion
<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>svn update </span><span id="L-2"><a name="L-2"></a>svn merge -r &lt;current_revision&gt;:&lt;previous_revision&gt; . </span><span id="L-3"><a name="L-3"></a>svn commit -m <span class="s2">&quot;Rolled back to &lt;previous_revision&gt;&quot;</span> </span></pre></div> </td></tr></table>
subversion

Bash

Remove untracked files from a working copy

git clean -f -d
https://snipt.net/embed/2475339aabf270d85c75a522139069b0/
/raw/2475339aabf270d85c75a522139069b0/
2475339aabf270d85c75a522139069b0
bash
Bash
1
2019-08-21T15:29:30
True
False
False
Jan 07, 2014 at 09:45 PM
/api/public/snipt/104324/
remove-untracked-files-from-a-working-copy
<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 clean -f -d </span></pre></div> </td></tr></table>
git

Bash

Run a PostgreSQL SQL script

psql -v ON_ERROR_STOP=1 -U <username> -d <database_name> -1 -f <sql_file>
https://snipt.net/embed/3180df5e2cee20c0e448a08bb4e8db23/
/raw/3180df5e2cee20c0e448a08bb4e8db23/
3180df5e2cee20c0e448a08bb4e8db23
bash
Bash
1
2019-08-21T15:29:55
True
False
False
Feb 18, 2014 at 05:08 AM
/api/public/snipt/99549/
run-an-postgresql-sql-script
<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>psql -v <span class="nv">ON_ERROR_STOP</span><span class="o">=</span><span class="m">1</span> -U &lt;username&gt; -d &lt;database_name&gt; -1 -f &lt;sql_file&gt; </span></pre></div> </td></tr></table>
postgresql

Bash

Add/Remove Apache 2 from Startup

1
2
3
$ sudo update-rc.d apache2 defaults

$ sudo update-rc.d -f apache2 remove
https://snipt.net/embed/476a2fabde8dd72eae892a0975de0611/
/raw/476a2fabde8dd72eae892a0975de0611/
476a2fabde8dd72eae892a0975de0611
bash
Bash
3
2019-08-21T15:30:28
True
False
False
Jul 30, 2013 at 11:02 PM
/api/public/snipt/70703/
addremove-apache-2-from-startup
<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>$ sudo update-rc.d apache2 defaults </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>$ sudo update-rc.d -f apache2 remove </span></pre></div> </td></tr></table>
apache2, bash, ubuntu

Bash

Merge with --ours and --theirs

1
2
3
4
" Keep the current branch version
git checkout --ours <file_path>
" Keep the pulled version
git checkout --theirs <file_path>
https://snipt.net/embed/f0bc8d8c5eacfd5b08b4fbfcef1b3353/
/raw/f0bc8d8c5eacfd5b08b4fbfcef1b3353/
f0bc8d8c5eacfd5b08b4fbfcef1b3353
bash
Bash
4
2019-08-21T15:30:57
True
False
False
Jul 23, 2013 at 10:05 PM
/api/public/snipt/69258/
merge-with-ours-and-theirs
<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="s2">&quot; Keep the current branch version</span> </span><span id="L-2"><a name="L-2"></a><span class="s2">git checkout --ours &lt;file_path&gt;</span> </span><span id="L-3"><a name="L-3"></a><span class="s2">&quot;</span> Keep the pulled version </span><span id="L-4"><a name="L-4"></a>git checkout --theirs &lt;file_path&gt; </span></pre></div> </td></tr></table>
git

Bash

Revert to the Previous Commit

$ git reset --hard HEAD^
https://snipt.net/embed/5800d1ecc4aed091ec2751c8be86b5ea/
/raw/5800d1ecc4aed091ec2751c8be86b5ea/
5800d1ecc4aed091ec2751c8be86b5ea
bash
Bash
1
2019-08-21T15:31:19
True
False
False
Jul 23, 2013 at 09:53 PM
/api/public/snipt/69257/
revert-to-the-previous-commit
<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 reset --hard HEAD^ </span></pre></div> </td></tr></table>
git

Text only

Select a Block of Text in Visual Mode

1
2
3
4
5
6
7
# To select a block of text from line xx to line yy
# On line xx
ma

# On line yy
Shift + v
`a
https://snipt.net/embed/692622a64b09582415ea5853cab66a51/
/raw/692622a64b09582415ea5853cab66a51/
692622a64b09582415ea5853cab66a51
text
Text only
7
2019-08-21T00:31:19
True
False
False
May 07, 2013 at 10:48 PM
/api/public/snipt/60891/
select-a-block-of-text-in-visual-mode
<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># To select a block of text from line xx to line yy </span><span id="L-2"><a name="L-2"></a># On line xx </span><span id="L-3"><a name="L-3"></a>ma </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a># On line yy </span><span id="L-6"><a name="L-6"></a>Shift + v </span><span id="L-7"><a name="L-7"></a>`a </span></pre></div> </td></tr></table>
vim

Bash

Install True Type Fonts on Ubuntu

1
2
3
4
# Copy new fonts to /usr/share/fonts/truetype

# Rebuild font cache
sudo fc-cache -f
https://snipt.net/embed/3d91f3f1b8ea9e6f3d646ce5a6beb3b8/
/raw/3d91f3f1b8ea9e6f3d646ce5a6beb3b8/
3d91f3f1b8ea9e6f3d646ce5a6beb3b8
bash
Bash
4
2019-08-19T18:36:43
True
False
False
Apr 29, 2013 at 10:38 PM
/api/public/snipt/60297/
install-true-type-fonts-on-ubuntu
<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="c1"># Copy new fonts to /usr/share/fonts/truetype</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c1"># Rebuild font cache</span> </span><span id="L-4"><a name="L-4"></a>sudo fc-cache -f </span></pre></div> </td></tr></table>
font, ubuntu