snipt

Ctrl+h for KB shortcuts

Bash

show frequently used commands

history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
https://snipt.net/embed/55c7a0685ce9e4bf9e96eed9a3288164/
/raw/55c7a0685ce9e4bf9e96eed9a3288164/
55c7a0685ce9e4bf9e96eed9a3288164
bash
Bash
1
2019-06-13T00:31:25
True
False
False
/api/public/snipt/463/
show-frequently-used-commands
<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="nb">history</span> <span class="m">1000</span> <span class="p">|</span> awk <span class="s1">&#39;{a[$2]++}END{for(i in a){print a[i] &quot; &quot; i}}&#39;</span> <span class="p">|</span> sort -rn <span class="p">|</span> head </span></pre></div> </td></tr></table>
bash

Bash

apply patch

patch -p0 < patch.txt
https://snipt.net/embed/d7434435766bb9bb67ed07db37d1c78b/
/raw/d7434435766bb9bb67ed07db37d1c78b/
d7434435766bb9bb67ed07db37d1c78b
bash
Bash
1
2019-06-15T06:57:49
True
False
False
/api/public/snipt/458/
apply-patch
<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>patch -p0 &lt; patch.txt </span></pre></div> </td></tr></table>
bash, linux, unix

HTML

Slightly modified pie chart

http://chart.apis.google.com/chart?cht=p&chd=t:60,40&chs=500x200&chl=Florida|Oklahoma&chco=ff4a00,bb0000
https://snipt.net/embed/0b93d989801779a3a8d558dea53c9be7/
/raw/0b93d989801779a3a8d558dea53c9be7/
0b93d989801779a3a8d558dea53c9be7
html
HTML
1
2019-06-18T13:39:52
True
False
False
/api/public/snipt/456/
slightly-modified-pie-chart
<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>http://chart.apis.google.com/chart?cht=p<span class="err">&amp;</span>chd=t:60,40<span class="err">&amp;</span>chs=500x200<span class="err">&amp;</span>chl=Florida|Oklahoma<span class="err">&amp;</span>chco=ff4a00,bb0000 </span></pre></div> </td></tr></table>
chart, google, rest

HTML

Google Charts default 3d-pie chart

http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World
https://snipt.net/embed/2873506b509ed734d225eb494654f730/
/raw/2873506b509ed734d225eb494654f730/
2873506b509ed734d225eb494654f730
html
HTML
1
2019-06-19T01:21:59
True
False
False
/api/public/snipt/455/
google-charts-default-3d-pie-chart
<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>http://chart.apis.google.com/chart?cht=p3<span class="err">&amp;</span>chd=t:60,40<span class="err">&amp;</span>chs=250x100<span class="err">&amp;</span>chl=Hello|World </span></pre></div> </td></tr></table>
chart, google, rest

Python

Convert Python generator function to return lists instead.

1
2
3
4
5
6
def generator_to_list(function):
    def wrapper(*args, **kwargs):
        return list(function(*args, **kwargs))
    wrapper.__name__ = function.__name__
    wrapper.__doc__ = function.__doc__
    return wrapper
https://snipt.net/embed/e6a235fa8d3b47e9bcf6e046473f75d9/
/raw/e6a235fa8d3b47e9bcf6e046473f75d9/
e6a235fa8d3b47e9bcf6e046473f75d9
python
Python
6
2019-06-17T00:01:01
True
False
False
/api/public/snipt/450/
convert-python-generator-function-to-return-lists-instead
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">def</span> <span class="nf">generator_to_list</span><span class="p">(</span><span class="n">function</span><span class="p">):</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">def</span> <span class="nf">wrapper</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">))</span> </span><span id="L-4"><a name="L-4"></a> <span class="n">wrapper</span><span class="o">.</span><span class="n">__name__</span> <span class="o">=</span> <span class="n">function</span><span class="o">.</span><span class="n">__name__</span> </span><span id="L-5"><a name="L-5"></a> <span class="n">wrapper</span><span class="o">.</span><span class="n">__doc__</span> <span class="o">=</span> <span class="n">function</span><span class="o">.</span><span class="n">__doc__</span> </span><span id="L-6"><a name="L-6"></a> <span class="k">return</span> <span class="n">wrapper</span> </span></pre></div> </td></tr></table>
python