snipt

Ctrl+h for KB shortcuts

Bash

convert audio files (e.g. m4a) to ogg vorbis

1
2
3
4
5
#!/bin/bash

for i in "[email protected]"; do
  ffmpeg -i "$i" -acodec vorbis -ac 2 ${i%.*}.ogg
done
https://snipt.net/embed/d135a9ad1d04f6d13747598d3b272ebb/
/raw/d135a9ad1d04f6d13747598d3b272ebb/
d135a9ad1d04f6d13747598d3b272ebb
bash
Bash
6
2019-07-17T00:10:57
True
False
False
/api/public/snipt/10087/
convert-audio-files-eg-m4a-to-ogg-vorbis
<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></span><span id="L-1"><a name="L-1"></a><span class="ch">#!/bin/bash</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="k">for</span> i in <span class="s2">&quot;</span><span class="nv">[email protected]</span><span class="s2">&quot;</span><span class="p">;</span> <span class="k">do</span> </span><span id="L-4"><a name="L-4"></a> ffmpeg -i <span class="s2">&quot;</span><span class="nv">$i</span><span class="s2">&quot;</span> -acodec vorbis -ac <span class="m">2</span> <span class="si">${</span><span class="nv">i</span><span class="p">%.*</span><span class="si">}</span>.ogg </span><span id="L-5"><a name="L-5"></a><span class="k">done</span> </span></pre></div> </td></tr></table>
convert, ffmpeg, m4a, ogg

Text only

set apt-cacher proxy and temporarily disable it

1
2
3
4
5
6
7
In this example an apt-cacher proxy is running on the server at 192.168.0.2.

---- /etc/apt/apt.conf.d/01proxy:
Acquire::http::Proxy "http://192.168.0.2:3142/apt-cacher/";

Bypassing the proxy temporarily:
# apt-get install -o Acquire::http::Proxy=none ack-grep
https://snipt.net/embed/89385dbb43fd8fd9161e08100f3885f0/
/raw/89385dbb43fd8fd9161e08100f3885f0/
89385dbb43fd8fd9161e08100f3885f0
text
Text only
7
2019-07-17T08:57:01
True
False
False
/api/public/snipt/6260/
set-apt-cacher-proxy-and-temporarily-disable-it
<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>In this example an apt-cacher proxy is running on the server at 192.168.0.2. </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>---- /etc/apt/apt.conf.d/01proxy: </span><span id="L-4"><a name="L-4"></a>Acquire::http::Proxy &quot;http://192.168.0.2:3142/apt-cacher/&quot;; </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a>Bypassing the proxy temporarily: </span><span id="L-7"><a name="L-7"></a># apt-get install -o Acquire::http::Proxy=none ack-grep </span></pre></div> </td></tr></table>
apt, debian, ubuntu

Bash

compact Firefox (and other Mozilla product) databases

1
2
3
4
# make sure sqlite is installed
sudo apt-get install sqlite3
# vacuum'em-all
find ~/.mozilla -name "*.sqlite" -exec sqlite3 {} "VACUUM;" \;
https://snipt.net/embed/31bfb236664390862401f1f43f3970ba/
/raw/31bfb236664390862401f1f43f3970ba/
31bfb236664390862401f1f43f3970ba
bash
Bash
4
2019-07-18T02:46:39
True
False
False
/api/public/snipt/5721/
compact-firefox-and-other-mozilla-product-databases
<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"># make sure sqlite is installed</span> </span><span id="L-2"><a name="L-2"></a>sudo apt-get install sqlite3 </span><span id="L-3"><a name="L-3"></a><span class="c1"># vacuum&#39;em-all</span> </span><span id="L-4"><a name="L-4"></a>find ~/.mozilla -name <span class="s2">&quot;*.sqlite&quot;</span> -exec sqlite3 <span class="o">{}</span> <span class="s2">&quot;VACUUM;&quot;</span> <span class="se">\;</span> </span></pre></div> </td></tr></table>
compact, database, firefox, mozilla, sqlite, thunderbird, vacuum

Bash

save/restore debian package selections

1
2
3
$ sudo dpkg --get-selections >packages.txt
$ sudo dpkg --set-selections <packages.txt
$ sudo apt-get dselect-upgrade
https://snipt.net/embed/8eff9d1fde7c40dd7062916beca63dd0/
/raw/8eff9d1fde7c40dd7062916beca63dd0/
8eff9d1fde7c40dd7062916beca63dd0
bash
Bash
3
2019-07-16T23:51:25
True
False
False
/api/public/snipt/5529/
saverestore-debian-package-selections
<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 dpkg --get-selections &gt;packages.txt </span><span id="L-2"><a name="L-2"></a>$ sudo dpkg --set-selections &lt;packages.txt </span><span id="L-3"><a name="L-3"></a>$ sudo apt-get dselect-upgrade </span></pre></div> </td></tr></table>
apt, debian, dpkg, ubuntu

Bash

list repositories for a deb package

1
2
3
4
5
6
7
8
$ sudo apt-get install apt-show-versions
$ apt-show-versions -a git-core
git-core 1:1.6.0.4-1ubuntu2 install ok installed
git-core 1:1.5.6.3-1.1ubuntu2   intrepid          fi.archive.ubuntu.com
git-core 1:1.5.6.3-1.1ubuntu2.1 intrepid-security security.ubuntu.com
git-core 1:1.6.0.4-1ubuntu2     jaunty            fi.archive.ubuntu.com
No unstable version
git-core/jaunty uptodate 1:1.6.0.4-1ubuntu2
https://snipt.net/embed/d8d74718b12f9a51c299d2a619db73c8/
/raw/d8d74718b12f9a51c299d2a619db73c8/
d8d74718b12f9a51c299d2a619db73c8
bash
Bash
8
2019-07-08T04:54:16
True
False
False
/api/public/snipt/5465/
list-repositories-for-a-deb-package
<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> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ sudo apt-get install apt-show-versions </span><span id="L-2"><a name="L-2"></a>$ apt-show-versions -a git-core </span><span id="L-3"><a name="L-3"></a>git-core 1:1.6.0.4-1ubuntu2 install ok installed </span><span id="L-4"><a name="L-4"></a>git-core 1:1.5.6.3-1.1ubuntu2 intrepid <span class="k">fi</span>.archive.ubuntu.com </span><span id="L-5"><a name="L-5"></a>git-core 1:1.5.6.3-1.1ubuntu2.1 intrepid-security security.ubuntu.com </span><span id="L-6"><a name="L-6"></a>git-core 1:1.6.0.4-1ubuntu2 jaunty <span class="k">fi</span>.archive.ubuntu.com </span><span id="L-7"><a name="L-7"></a>No unstable version </span><span id="L-8"><a name="L-8"></a>git-core/jaunty uptodate 1:1.6.0.4-1ubuntu2 </span></pre></div> </td></tr></table>
apt, debian, dpkg, query, repository, ubuntu

Python

install snapshots of distutils-based Python packages (e.g. Django) with setuptools

1
2
3
# from Ian Bicking's comment on
# http://jannisleidel.com/2007/11/using-django-with-setuptools/
python -c "import setuptools, os; __file__=os.path.abspath('setup.py'); execfile('setup.py')" develop
https://snipt.net/embed/48c936ac7d1744f560b2db764483c80f/
/raw/48c936ac7d1744f560b2db764483c80f/
48c936ac7d1744f560b2db764483c80f
python
Python
3
2019-07-21T13:58:26
True
False
False
/api/public/snipt/5324/
install-django-with-setuptools
<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="c1"># from Ian Bicking&#39;s comment on</span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># http://jannisleidel.com/2007/11/using-django-with-setuptools/</span> </span><span id="L-3"><a name="L-3"></a><span class="n">python</span> <span class="o">-</span><span class="n">c</span> <span class="s2">&quot;import setuptools, os; __file__=os.path.abspath(&#39;setup.py&#39;); execfile(&#39;setup.py&#39;)&quot;</span> <span class="n">develop</span> </span></pre></div> </td></tr></table>
distutils, django, install, python, setuptools