snipt

Ctrl+h for KB shortcuts

Bash

Make iso images from CD

1
2
3
4
cat /dev/scd0 > /home/shamanstears/test.iso

#where scd0 is the identifier of the cd/dvd reader
#can find it through System Monitor in Ubuntu
https://snipt.net/embed/e32a49666c1a23a8849b552f7c841365/
/raw/e32a49666c1a23a8849b552f7c841365/
e32a49666c1a23a8849b552f7c841365
bash
Bash
4
2019-07-18T17:51:31
True
False
False
Mar 25, 2013 at 04:58 AM
/api/public/snipt/58241/
make-iso-images-from-cd
<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>cat /dev/scd0 &gt; /home/shamanstears/test.iso </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c1">#where scd0 is the identifier of the cd/dvd reader</span> </span><span id="L-4"><a name="L-4"></a><span class="c1">#can find it through System Monitor in Ubuntu</span> </span></pre></div> </td></tr></table>
bash, cd, image, iso

NumPy

Dump Numpy array in a csv text file

savetxt("foo.csv", dataArray, delimiter="\t")
https://snipt.net/embed/4a1202477b401ee4905348097869871a/
/raw/4a1202477b401ee4905348097869871a/
4a1202477b401ee4905348097869871a
numpy
NumPy
1
2019-07-20T14:41:24
True
False
False
Dec 14, 2012 at 09:26 AM
/api/public/snipt/51845/
dump-numpy-array-in-a-csv-text-file
<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><span class="kp">savetxt</span><span class="p">(</span><span class="s2">&quot;foo.csv&quot;</span><span class="p">,</span> <span class="n">dataArray</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span><span class="p">)</span> </span></pre></div> </td></tr></table>
Numpy, array, csv, save, text

Python

Log plots in Matplotlib

1
2
3
4
5
6
7
from pylab import *
fig = figure()
ax = fig.add_subplot(1,1,1)

#changes x oy y axis to logscale
ax.set_xscale('log')
ax.set_yscale('log')
https://snipt.net/embed/67807134d08e59dd7d9599fa1f3bee67/
/raw/67807134d08e59dd7d9599fa1f3bee67/
67807134d08e59dd7d9599fa1f3bee67
python
Python
7
2019-07-18T21:33:47
True
False
False
Dec 06, 2012 at 09:22 AM
/api/public/snipt/51343/
log-plots-in-matplotlib
<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="kn">from</span> <span class="nn">pylab</span> <span class="kn">import</span> <span class="o">*</span> </span><span id="L-2"><a name="L-2"></a><span class="n">fig</span> <span class="o">=</span> <span class="n">figure</span><span class="p">()</span> </span><span id="L-3"><a name="L-3"></a><span class="n">ax</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">add_subplot</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="c1">#changes x oy y axis to logscale</span> </span><span id="L-6"><a name="L-6"></a><span class="n">ax</span><span class="o">.</span><span class="n">set_xscale</span><span class="p">(</span><span class="s1">&#39;log&#39;</span><span class="p">)</span> </span><span id="L-7"><a name="L-7"></a><span class="n">ax</span><span class="o">.</span><span class="n">set_yscale</span><span class="p">(</span><span class="s1">&#39;log&#39;</span><span class="p">)</span> </span></pre></div> </td></tr></table>
Matplotlib, Python, axis, log, logscale

NumPy

Sort array by nth column in Numpy/Python

# sort array with regards to nth column
arr = arr[arr[:,n].argsort()]
https://snipt.net/embed/40d7e32447ad183bf59483a74b6a6fbb/
/raw/40d7e32447ad183bf59483a74b6a6fbb/
40d7e32447ad183bf59483a74b6a6fbb
numpy
NumPy
2
2019-07-22T16:57:48
True
False
False
/api/public/snipt/51255/
sort-array-by-nth-column-in-numpypython
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</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"># sort array with regards to nth column</span> </span><span id="L-2"><a name="L-2"></a><span class="n">arr</span> <span class="o">=</span> <span class="n">arr</span><span class="p">[</span><span class="n">arr</span><span class="p">[:,</span><span class="n">n</span><span class="p">]</span><span class="o">.</span><span class="kp">argsort</span><span class="p">()]</span> </span></pre></div> </td></tr></table>
Python, array, numpy, sort

Python

Legend with only one marker in Matplotlib

1
2
3
4
5
#for markers
legend(numpoints = 1)

#for scatter
legend(scatterpoints = 1)
https://snipt.net/embed/9cab831021c7af9ee84da1b6750a231a/
/raw/9cab831021c7af9ee84da1b6750a231a/
9cab831021c7af9ee84da1b6750a231a
python
Python
5
2019-07-18T17:44:47
True
False
False
/api/public/snipt/50698/
legend-with-only-one-marker-in-matplotlib
<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="c1">#for markers</span> </span><span id="L-2"><a name="L-2"></a><span class="n">legend</span><span class="p">(</span><span class="n">numpoints</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1">#for scatter</span> </span><span id="L-5"><a name="L-5"></a><span class="n">legend</span><span class="p">(</span><span class="n">scatterpoints</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span> </span></pre></div> </td></tr></table>
Matplotlib, legend, scatter

Python

Hide axis ticks and labels in Matplotlib

1
2
3
4
5
ax.set_xticklabels([])
ax.set_yticklabels([])

ax.set_xticks([])
ax.set_yticks([])
https://snipt.net/embed/9df107414900dc35b90623acea14fd30/
/raw/9df107414900dc35b90623acea14fd30/
9df107414900dc35b90623acea14fd30
python
Python
5
2019-07-20T08:03:21
True
False
False
Nov 24, 2012 at 03:43 AM
/api/public/snipt/50696/
hide-axis-ticks-and-labels-in-matplotlib
<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="n">ax</span><span class="o">.</span><span class="n">set_xticklabels</span><span class="p">([])</span> </span><span id="L-2"><a name="L-2"></a><span class="n">ax</span><span class="o">.</span><span class="n">set_yticklabels</span><span class="p">([])</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="n">ax</span><span class="o">.</span><span class="n">set_xticks</span><span class="p">([])</span> </span><span id="L-5"><a name="L-5"></a><span class="n">ax</span><span class="o">.</span><span class="n">set_yticks</span><span class="p">([])</span> </span></pre></div> </td></tr></table>
"hide axis ticks and labels", Matplotlib, Python, hide, labels, ticks

Bash

Superimpose PDFs with pdfTK

pdftk file1.pdf background file2.pdf output combinedfile.pdf
https://snipt.net/embed/657628a4b7e6ca42b22fb473ab8b708b/
/raw/657628a4b7e6ca42b22fb473ab8b708b/
657628a4b7e6ca42b22fb473ab8b708b
bash
Bash
1
2019-07-22T17:40:33
True
False
False
Nov 20, 2012 at 02:52 PM
/api/public/snipt/50532/
superimpose-pdfs-with-pdftk
<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>pdftk file1.pdf background file2.pdf output combinedfile.pdf </span></pre></div> </td></tr></table>
PDF, Superimpose, pdfTK