Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Python

Python: Unzipping files that are flying in through a pipe

# source at serverfault.co: http://va.mu/WEFT
alias unzip-stream="python -c \"import zipfile,sys,StringIO;zipfile.ZipFile(StringIO.StringIO(sys.stdin.read())).extractall(sys.argv[1] if len(sys.argv) == 2 else '.')\""
https://snipt.net/embed/d20428459ad0a35baa7651c1476bb27d/
https://snipt.net/raw/d20428459ad0a35baa7651c1476bb27d/
d20428459ad0a35baa7651c1476bb27d
python
Python
2
2016-12-09T19:43:51
True
False
False
/api/public/snipt/42675/
python-unzip-stream-alias
<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"># source at serverfault.co: http://va.mu/WEFT</span> </span><span id="L-2"><a name="L-2"></a><span class="n">alias</span> <span class="n">unzip</span><span class="o">-</span><span class="n">stream</span><span class="o">=</span><span class="s2">&quot;python -c </span><span class="se">\&quot;</span><span class="s2">import zipfile,sys,StringIO;zipfile.ZipFile(StringIO.StringIO(sys.stdin.read())).extractall(sys.argv[1] if len(sys.argv) == 2 else &#39;.&#39;)</span><span class="se">\&quot;</span><span class="s2">&quot;</span> </span></pre></div> </td></tr></table>
alias, bash, bashrc, python, unzip

Bash

Bash aliases for printing a "horizontal rule" on a terminal. Useful when iteratively reviewing compilation errors. 'hr' is a single line. 'HR' is multiple lines.

alias hr='printf "%$(tput cols)s\n"|tr " " "="'
alias HR='printf "%$(tput cols)s\n" `date`|tr " " "="'
https://snipt.net/embed/4cc620ccb31ec818684eb812c50712ae/
https://snipt.net/raw/4cc620ccb31ec818684eb812c50712ae/
4cc620ccb31ec818684eb812c50712ae
bash
Bash
2
2016-12-10T15:14:42
True
False
False
/api/public/snipt/34877/
bash-aliases-for-printing-a-horizontal-rule-on-a-terminal-useful-when-iteratively-reviewing-compilation-errors-hr-is-a-single-line-hr-is-multiple-lines
<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="nb">alias</span> <span class="nv">hr</span><span class="o">=</span><span class="s1">&#39;printf &quot;%$(tput cols)s\n&quot;|tr &quot; &quot; &quot;=&quot;&#39;</span> </span><span id="L-2"><a name="L-2"></a><span class="nb">alias</span> <span class="nv">HR</span><span class="o">=</span><span class="s1">&#39;printf &quot;%$(tput cols)s\n&quot; `date`|tr &quot; &quot; &quot;=&quot;&#39;</span> </span></pre></div> </td></tr></table>
alias

Smarty

CMSMS | stampa link ai figli di una pagina dato l'alias

1
2
3
4
5
6
7
{content block='aliasPagina' oneline='true' assign='aliasPagina'}
{$cgsimple->get_children($aliasPagina,'',variabile)}
{if count($variabile)}
{foreach from=$variabile item='varIndice'}
<a href="index.php?page={$varIndice.alias}">{$varIndice.title}</a>
{/foreach}
{/if}
https://snipt.net/embed/0ef941dbd3d428e6cc0be5c3489ea2b2/
https://snipt.net/raw/0ef941dbd3d428e6cc0be5c3489ea2b2/
0ef941dbd3d428e6cc0be5c3489ea2b2
smarty
Smarty
7
2016-12-07T03:57:40
True
False
False
/api/public/snipt/30606/
cmsms-stampa-figli-di-una-pagina-dato-lalias
<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="cp">{</span><span class="nf">content</span> <span class="na">block</span><span class="o">=</span><span class="s1">&#39;aliasPagina&#39;</span> <span class="na">oneline</span><span class="o">=</span><span class="s1">&#39;true&#39;</span> <span class="na">assign</span><span class="o">=</span><span class="s1">&#39;aliasPagina&#39;</span><span class="cp">}</span><span class="x"></span> </span><span id="L-2"><a name="L-2"></a><span class="cp">{</span><span class="nv">$cgsimple</span><span class="o">-&gt;</span><span class="na">get_children</span><span class="o">(</span><span class="nv">$aliasPagina</span><span class="o">,</span><span class="s1">&#39;&#39;</span><span class="o">,</span><span class="na">variabile</span><span class="o">)</span><span class="cp">}</span><span class="x"></span> </span><span id="L-3"><a name="L-3"></a><span class="cp">{</span><span class="nf">if</span> <span class="na">count</span><span class="o">(</span><span class="nv">$variabile</span><span class="o">)</span><span class="cp">}</span><span class="x"></span> </span><span id="L-4"><a name="L-4"></a><span class="cp">{</span><span class="nf">foreach</span> <span class="na">from</span><span class="o">=</span><span class="nv">$variabile</span> <span class="na">item</span><span class="o">=</span><span class="s1">&#39;varIndice&#39;</span><span class="cp">}</span><span class="x"></span> </span><span id="L-5"><a name="L-5"></a><span class="x">&lt;a href=&quot;index.php?page=</span><span class="cp">{</span><span class="nv">$varIndice.alias</span><span class="cp">}</span><span class="x">&quot;&gt;</span><span class="cp">{</span><span class="nv">$varIndice.title</span><span class="cp">}</span><span class="x">&lt;/a&gt;</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">{</span><span class="nf">/foreach</span><span class="cp">}</span><span class="x"></span> </span><span id="L-7"><a name="L-7"></a><span class="cp">{</span><span class="nf">/if</span><span class="cp">}</span><span class="x"></span> </span></pre></div> </td></tr></table>
alias, cmsms, smarty

Smarty

CMSMS | stampa alias come id del body

<body id="{$page_alias}">
https://snipt.net/embed/2a577b9dec2ee36ecb9cb5baf051e01d/
https://snipt.net/raw/2a577b9dec2ee36ecb9cb5baf051e01d/
2a577b9dec2ee36ecb9cb5baf051e01d
smarty
Smarty
1
2016-12-09T23:55:26
True
False
False
/api/public/snipt/30605/
cmsms-stampa-alias-come-id-del-body
<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="x">&lt;body id=&quot;</span><span class="cp">{</span><span class="nv">$page_alias</span><span class="cp">}</span><span class="x">&quot;&gt;</span> </span></pre></div> </td></tr></table>
alias, cmsms, smarty
Copyrighted, illegal, or inappropriate content? Email [email protected].