Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Lua

Fibaro - Check if scene is already running

1
2
3
4
if (fibaro:countScenes()>1) then 
  --fibaro:debug('Kill second scene!'); 
  fibaro:abort(); 
end 
https://snipt.net/embed/48c672305b5966948eb5012a46ca257c/
https://snipt.net/raw/48c672305b5966948eb5012a46ca257c/
48c672305b5966948eb5012a46ca257c
lua
Lua
4
2016-12-02T21:26:49
True
False
False
Oct 12, 2015 at 03:40 AM
/api/public/snipt/141627/
fibaro-check-if-scene-is-already-running
<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><span class="k">if</span> <span class="p">(</span><span class="n">fibaro</span><span class="p">:</span><span class="n">countScenes</span><span class="p">()</span><span class="o">&gt;</span><span class="mi">1</span><span class="p">)</span> <span class="k">then</span> </span><span id="L-2"><a name="L-2"></a> <span class="c1">--fibaro:debug(&#39;Kill second scene!&#39;); </span> </span><span id="L-3"><a name="L-3"></a> <span class="n">fibaro</span><span class="p">:</span><span class="n">abort</span><span class="p">();</span> </span><span id="L-4"><a name="L-4"></a><span class="k">end</span> </span></pre></div> </td></tr></table>
Fibaro;, LUA;, Scenes, check

JavaScript

Test if href points image

1
2
3
4
if($(this).attr('href').indexOf('.jpg') > 0) // or any other extension
{
    //do what you want
}
https://snipt.net/embed/6b6e76de0f8d48d7e980f025b5f0f153/
https://snipt.net/raw/6b6e76de0f8d48d7e980f025b5f0f153/
6b6e76de0f8d48d7e980f025b5f0f153
js
JavaScript
4
2016-12-02T10:00:16
True
False
False
Mar 17, 2014 at 01:11 PM
/api/public/snipt/122560/
test-if-href-points-image
<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><span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;href&#39;</span><span class="p">).</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;.jpg&#39;</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="c1">// or any other extension</span> </span><span id="L-2"><a name="L-2"></a><span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="c1">//do what you want</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
check, href, image, img, javascript, jpeg, jpg, jquery, js, test

JavaScript

Check if images are loaded

1
2
3
$('img').load(function() {
	console.log('image load successful');
});
https://snipt.net/embed/0b8599f3aa0e7180e0640d69b8ad82db/
https://snipt.net/raw/0b8599f3aa0e7180e0640d69b8ad82db/
0b8599f3aa0e7180e0640d69b8ad82db
js
JavaScript
3
2016-12-02T10:25:27
True
False
False
/api/public/snipt/109798/
check-if-images-are-loaded
<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="nx">$</span><span class="p">(</span><span class="s1">&#39;img&#39;</span><span class="p">).</span><span class="nx">load</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;image load successful&#39;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
check, images, jquery, load

Markdown

Command check version mack os

check version and detail os

system_profiler SPSoftwareDataType

check version only

sw_vers -productVersion

https://snipt.net/embed/5e3210d06d55408f3ef81bfc50e64f38/
https://snipt.net/raw/5e3210d06d55408f3ef81bfc50e64f38/
5e3210d06d55408f3ef81bfc50e64f38
markdown
Markdown
8
2016-11-30T17:15:12
True
False
True
Dec 04, 2013 at 04:20 AM
/api/public/snipt/98426/
command-check-version-mack-os
<p>check version and detail os</p> <p><code>system_profiler SPSoftwareDataType</code></p> <p>check version only </p> <p><code>sw_vers -productVersion</code></p>
check, command, osx, version

PHP

Check for pictures available by url

1
2
3
4
5
6
7
8
<?php
/* © AcidChristStudio, www.acidchrist.ru */

$image_url = 'http://site.com/folder/image.png';
$headers = @get_headers($image_url);
echo (strpos($headers[0], '200')) ? 'Exist;' : 'Not exist;';

?>
https://snipt.net/embed/bb7d41ec9d3c9ef0496fda381f133e03/
https://snipt.net/raw/bb7d41ec9d3c9ef0496fda381f133e03/
bb7d41ec9d3c9ef0496fda381f133e03
php
PHP
8
2016-11-30T02:04:58
True
False
True
Sep 11, 2013 at 12:12 PM
/api/public/snipt/80363/
check-for-pictures-available-by-url
<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> <a href="#L-8">8</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">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="cm">/* © AcidChristStudio, www.acidchrist.ru */</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="nv">$image_url</span> <span class="o">=</span> <span class="s1">&#39;http://site.com/folder/image.png&#39;</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a><span class="nv">$headers</span> <span class="o">=</span> <span class="o">@</span><span class="nb">get_headers</span><span class="p">(</span><span class="nv">$image_url</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a><span class="k">echo</span> <span class="p">(</span><span class="nb">strpos</span><span class="p">(</span><span class="nv">$headers</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s1">&#39;200&#39;</span><span class="p">))</span> <span class="o">?</span> <span class="s1">&#39;Exist;&#39;</span> <span class="o">:</span> <span class="s1">&#39;Not exist;&#39;</span><span class="p">;</span> </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
check, image
Copyrighted, illegal, or inappropriate content? Email [email protected].