snipt

Ctrl+h for KB shortcuts

Python

create an alias/partial in python

1
2
3
# create a partial that can be applied using map with the give size
checkThisSize = functools.partial(checkSize, size=options.size, quiet=False)
checked = map(checkThisSize, queues)
https://snippets.siftie.com/embed/d87ad598037174ab3e56867222140fae/
/raw/d87ad598037174ab3e56867222140fae/
d87ad598037174ab3e56867222140fae
python
Python
4
2019-03-10T09:55:59
True
False
False
/api/public/snipt/985/
create-an-aliaspartial-in-python
<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"># create a partial that can be applied using map with the give size</span> </span><span id="L-2"><a name="L-2"></a><span class="n">checkThisSize</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">partial</span><span class="p">(</span><span class="n">checkSize</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="n">options</span><span class="o">.</span><span class="n">size</span><span class="p">,</span> <span class="n">quiet</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span> </span><span id="L-3"><a name="L-3"></a><span class="n">checked</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">checkThisSize</span><span class="p">,</span> <span class="n">queues</span><span class="p">)</span> </span></pre></div> </td></tr></table>
functional, partial, python

Bash

accessing args from previous command

1
2
3
ls -alrt /tmp /var/ /usr
cd !:2
-> cd /tmp
https://snippets.siftie.com/embed/41b4e5329cc9c53b50317fdae5da61e4/
/raw/41b4e5329cc9c53b50317fdae5da61e4/
41b4e5329cc9c53b50317fdae5da61e4
bash
Bash
3
2019-03-08T19:54:16
True
False
False
/api/public/snipt/967/
accessing-args-from-previous-command
<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>ls -alrt /tmp /var/ /usr </span><span id="L-2"><a name="L-2"></a><span class="nb">cd</span> !:2 </span><span id="L-3"><a name="L-3"></a>-&gt; <span class="nb">cd</span> /tmp </span></pre></div> </td></tr></table>
bash, shell

Bash

shell substitution

1
2
3
cl config.ini config.ini.bak
^cl^cp
!!:gs/cl/cp/
https://snippets.siftie.com/embed/d9b0ea9425b7633b25d6e597bd46baa4/
/raw/d9b0ea9425b7633b25d6e597bd46baa4/
d9b0ea9425b7633b25d6e597bd46baa4
bash
Bash
3
2019-03-03T09:24:58
True
False
False
/api/public/snipt/966/
shell-substitution
<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>cl config.ini config.ini.bak </span><span id="L-2"><a name="L-2"></a>^cl^cp </span><span id="L-3"><a name="L-3"></a>!!:gs/cl/cp/ </span></pre></div> </td></tr></table>
bash, shell