Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Text only

Execute PHP CLI background mode

1
2
3
exec('/usr/bin/php  '.__PATH__.'/CLI/run-background.php '.$var1.' > /dev/null &',$output);
// $output is the variable return for command "exec"
// $var1 send variables in the string path- get array data with vars in run-background.php usign $argv
https://snipt.net/embed/55609c21d588a357b9caf876ccc39a0a/
https://snipt.net/raw/55609c21d588a357b9caf876ccc39a0a/
55609c21d588a357b9caf876ccc39a0a
text
Text only
3
2016-12-10T21:44:02
True
False
False
Jan 29, 2013 at 03:12 PM
/api/public/snipt/54745/
execute-php-cli-background-mode
<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>exec(&#39;/usr/bin/php &#39;.__PATH__.&#39;/CLI/run-background.php &#39;.$var1.&#39; &gt; /dev/null &amp;&#39;,$output); </span><span id="L-2"><a name="L-2"></a>// $output is the variable return for command &quot;exec&quot; </span><span id="L-3"><a name="L-3"></a>// $var1 send variables in the string path- get array data with vars in run-background.php usign $argv </span></pre></div> </td></tr></table>
"php cli", background, snippet

JavaScript

Trim string to length

1
2
3
4
5
function trimLength(str, length) {
	str = $.trim(str); // jQuery required
	str = str.slice(0, length);
	return str;
}
https://snipt.net/embed/b282ce90eccedb80413e42bfea8f0572/
https://snipt.net/raw/b282ce90eccedb80413e42bfea8f0572/
b282ce90eccedb80413e42bfea8f0572
js
JavaScript
5
2016-12-10T05:42:33
True
False
False
/api/public/snipt/23868/
trim-string-to-length
<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="kd">function</span> <span class="nx">trimLength</span><span class="p">(</span><span class="nx">str</span><span class="p">,</span> <span class="nx">length</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">str</span> <span class="o">=</span> <span class="nx">$</span><span class="p">.</span><span class="nx">trim</span><span class="p">(</span><span class="nx">str</span><span class="p">);</span> <span class="c1">// jQuery required</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">str</span> <span class="o">=</span> <span class="nx">str</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nx">length</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">return</span> <span class="nx">str</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
cut, function, helper, javascript, length, shorten, snippet, string, trim
Copyrighted, illegal, or inappropriate content? Email [email protected].