Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

Test

1
2
3
<?php

echo "This is a message for test.";
https://snipt.net/embed/d1b01eae2070e46be310267acee41813/
https://snipt.net/raw/d1b01eae2070e46be310267acee41813/
d1b01eae2070e46be310267acee41813
php
PHP
3
2016-12-04T03:49:07
True
False
False
Feb 18, 2016 at 03:14 AM
/api/public/snipt/144324/
test-674f2b3c
<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="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="k">echo</span> <span class="s2">&quot;This is a message for test.&quot;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
"php code", test

PHP

test

1
2
3
4
function test($tag)
{
	return strtolower(urlencode(preg_replace('`\s+`', '-', $tag)));
}
https://snipt.net/embed/a17ac211eff4f8da5a60574a954a63ec/
https://snipt.net/raw/a17ac211eff4f8da5a60574a954a63ec/
a17ac211eff4f8da5a60574a954a63ec
php
PHP
4
2016-12-04T03:50:35
True
False
False
Jan 13, 2016 at 09:55 AM
/api/public/snipt/143538/
14553b90
<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="x">function test($tag)</span> </span><span id="L-2"><a name="L-2"></a><span class="x">{</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> return strtolower(urlencode(preg_replace(&#39;`\s+`&#39;, &#39;-&#39;, $tag)));</span> </span><span id="L-4"><a name="L-4"></a><span class="x">}</span> </span></pre></div> </td></tr></table>
test

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-04T03:52:19
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

Test snippet

console.log("hello world!");
https://snipt.net/embed/d4dd457438a8bd86f15a9c0abe204d35/
https://snipt.net/raw/d4dd457438a8bd86f15a9c0abe204d35/
d4dd457438a8bd86f15a9c0abe204d35
js
JavaScript
1
2016-12-04T03:53:53
True
False
False
Jan 24, 2014 at 12:42 PM
/api/public/snipt/108329/
test-snippet-12
<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="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;hello world!&quot;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
test, wlcr

Text only

Fill in form with test results.

1
2
3
4
5
6
$("input[type='text']").val("test"); 
$("input[name='email']").val("[email protected]");
$("input[type='email']").val("[email protected]");
$("textarea").val("This is a test.");
$("select").each(function(){$(this).children().last().attr("selected","selected");});
$("input[type='checkbox']").attr('checked', true);
https://snipt.net/embed/0c8821e4e847c0fd4ac03b8fdbb672de/
https://snipt.net/raw/0c8821e4e847c0fd4ac03b8fdbb672de/
0c8821e4e847c0fd4ac03b8fdbb672de
text
Text only
6
2016-12-04T03:55:20
True
False
False
/api/public/snipt/81249/
fill-in-form-with-test-results
<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>$(&quot;input[type=&#39;text&#39;]&quot;).val(&quot;test&quot;); </span><span id="L-2"><a name="L-2"></a>$(&quot;input[name=&#39;email&#39;]&quot;).val(&quot;[email protected]&quot;); </span><span id="L-3"><a name="L-3"></a>$(&quot;input[type=&#39;email&#39;]&quot;).val(&quot;[email protected]&quot;); </span><span id="L-4"><a name="L-4"></a>$(&quot;textarea&quot;).val(&quot;This is a test.&quot;); </span><span id="L-5"><a name="L-5"></a>$(&quot;select&quot;).each(function(){$(this).children().last().attr(&quot;selected&quot;,&quot;selected&quot;);}); </span><span id="L-6"><a name="L-6"></a>$(&quot;input[type=&#39;checkbox&#39;]&quot;).attr(&#39;checked&#39;, true); </span></pre></div> </td></tr></table>
"dummy info", debugging, forms, test, testing

Markdown

Choosing Test Fixture Names

Page 86 of Agile Web Development with Rails 4

But what do we do with fixtures that can’t easily get a self-explanatory name like valid_order_for_fred? Pick natural names that you have an easier time associating to a role. For example, instead of using order1, use christmas_order. Instead of customer1, use fred. Once you get into the habit of natural names, you’ll soon be weaving a nice little story about how fred is paying for his christmas_order with his invalid_credit_card first, then paying with his valid_credit_card, and finally choosing to ship it all off to aunt_mary.

https://snipt.net/embed/cb2adf9c28f4b9c34d1ea90eba2d0aff/
https://snipt.net/raw/cb2adf9c28f4b9c34d1ea90eba2d0aff/
cb2adf9c28f4b9c34d1ea90eba2d0aff
markdown
Markdown
2
2016-12-07T16:01:36
True
False
True
Jun 27, 2013 at 02:46 AM
/api/public/snipt/65815/
choosing-test-fixture-names
<p>Page 86 of Agile Web Development with Rails 4</p> <blockquote> <p>But what do we do with fixtures that can’t easily get a self-explanatory name like <code>valid_order_for_fred</code>? Pick natural names that you have an easier time associating to a role. For example, instead of using <code>order1</code>, use <code>christmas_order</code>. Instead of <code>customer1</code>, use fred. Once you get into the habit of natural names, you’ll soon be weaving a nice little story about how <code>fred</code> is paying for his <code>christmas_order</code> with his <code>invalid_credit_card</code> first, then paying with his <code>valid_credit_card</code>, and finally choosing to ship it all off to <code>aunt_mary</code>.</p> </blockquote>
fixtures, quote, rails, test
Copyrighted, illegal, or inappropriate content? Email [email protected].