snipt

Ctrl+h for KB shortcuts

JavaScript

js: checkboxes

1
2
3
4
5
6
var cbox = '';
//alert($("input[name=bulk_checkboxes]:checked").size());
$('input[name=bulk_checkboxes]:checked').each(function() {
     cbox += $(this).val() + ",";
});
alert(cbox);
https://snipt.net/embed/705a00c81cc2fd9defe760e69beeabe8/
/raw/705a00c81cc2fd9defe760e69beeabe8/
705a00c81cc2fd9defe760e69beeabe8
js
JavaScript
6
2019-07-11T03:07:15
True
False
False
/api/public/snipt/36414/
js-checkboxes
<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="kd">var</span> <span class="nx">cbox</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">//alert($(&quot;input[name=bulk_checkboxes]:checked&quot;).size());</span> </span><span id="L-3"><a name="L-3"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;input[name=bulk_checkboxes]:checked&#39;</span><span class="p">).</span><span class="nx">each</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="nx">cbox</span> <span class="o">+=</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">val</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot;,&quot;</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a><span class="p">});</span> </span><span id="L-6"><a name="L-6"></a><span class="nx">alert</span><span class="p">(</span><span class="nx">cbox</span><span class="p">);</span> </span></pre></div> </td></tr></table>
checkboxes, javascript, jquery

PHP

wordpress: theme dir

1
2
3
4
5
<?
// output the theme path
echo get_bloginfo('template_directory', 'raw');

?>
https://snipt.net/embed/29a89772fa7bacf14702376e2842d888/
/raw/29a89772fa7bacf14702376e2842d888/
29a89772fa7bacf14702376e2842d888
php
PHP
5
2019-07-22T14:20:56
True
False
False
/api/public/snipt/35082/
wordpress-theme-dir
<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="cp">&lt;?</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">// output the theme path</span> </span><span id="L-3"><a name="L-3"></a><span class="k">echo</span> <span class="nx">get_bloginfo</span><span class="p">(</span><span class="s1">&#39;template_directory&#39;</span><span class="p">,</span> <span class="s1">&#39;raw&#39;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
wordpress

HTML

IE stuff

<!-- force latest rendering -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
https://snipt.net/embed/c1799ff7408b75502e89097df08d6e35/
/raw/c1799ff7408b75502e89097df08d6e35/
c1799ff7408b75502e89097df08d6e35
html
HTML
2
2019-07-20T16:13:59
True
False
False
/api/public/snipt/35070/
ie-stuff
<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="c">&lt;!-- force latest rendering --&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">&quot;X-UA-Compatible&quot;</span> <span class="na">content</span><span class="o">=</span><span class="s">&quot;IE=edge,chrome=1&quot;</span> <span class="p">/&gt;</span> </span></pre></div> </td></tr></table>
browser, ie

PHP

PHP time date setting

1
2
3
4
5
6
<?php
    //date_default_timezone_set('EST'); 
    date_default_timezone_set('America/Chicago');
    echo date('h:i', $_SERVER['REQUEST_TIME']) . '<br/>';
    echo date('m-d-Y h:i a e O P T', strtotime('now'));
?>
https://snipt.net/embed/a0e81b6998729c956958214233b41820/
/raw/a0e81b6998729c956958214233b41820/
a0e81b6998729c956958214233b41820
php
PHP
6
2019-07-21T14:42:19
True
False
False
/api/public/snipt/31136/
php-time-date-setting
<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="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> <span class="c1">//date_default_timezone_set(&#39;EST&#39;); </span> </span><span id="L-3"><a name="L-3"></a> <span class="nb">date_default_timezone_set</span><span class="p">(</span><span class="s1">&#39;America/Chicago&#39;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">echo</span> <span class="nb">date</span><span class="p">(</span><span class="s1">&#39;h:i&#39;</span><span class="p">,</span> <span class="nv">$_SERVER</span><span class="p">[</span><span class="s1">&#39;REQUEST_TIME&#39;</span><span class="p">])</span> <span class="o">.</span> <span class="s1">&#39;&lt;br/&gt;&#39;</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">echo</span> <span class="nb">date</span><span class="p">(</span><span class="s1">&#39;m-d-Y h:i a e O P T&#39;</span><span class="p">,</span> <span class="nb">strtotime</span><span class="p">(</span><span class="s1">&#39;now&#39;</span><span class="p">));</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
date, php, time

PHP

clean filename

1
2
3
4
<?php

// clean filename:
$filename = preg_replace("/[^a-z0-9\-\.]/i", "_" , $filename); 
https://snipt.net/embed/d0742c5953ff7f605e76470beec9f31c/
/raw/d0742c5953ff7f605e76470beec9f31c/
d0742c5953ff7f605e76470beec9f31c
php
PHP
4
2019-07-20T23:41:06
True
False
False
/api/public/snipt/30588/
clean-filename
<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="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="c1">// clean filename:</span> </span><span id="L-4"><a name="L-4"></a><span class="nv">$filename</span> <span class="o">=</span> <span class="nb">preg_replace</span><span class="p">(</span><span class="s2">&quot;/[^a-z0-9\-\.]/i&quot;</span><span class="p">,</span> <span class="s2">&quot;_&quot;</span> <span class="p">,</span> <span class="nv">$filename</span><span class="p">);</span> </span></pre></div> </td></tr></table>
clean, file, image, php, upload

CSS+PHP

html5 validation overrides for forms

1
2
3
4
<style>
input:invalid {-moz-box-shadow: none;}
input:focus {border-color:#fff; outline: none; -moz-box-shadow: 0 0 0.25em #fff; -webkit-box-shadow: 0 0 0.25em #fff; box-shadow: 0 0 0.25em #fff;}
</style>
https://snipt.net/embed/cb59dfe886f349b76f6060dc06466c1b/
/raw/cb59dfe886f349b76f6060dc06466c1b/
cb59dfe886f349b76f6060dc06466c1b
css+php
CSS+PHP
4
2019-07-15T14:15:30
True
False
False
/api/public/snipt/29550/
html5-validation-overrides-for-forms
<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="o">&lt;</span><span class="nt">style</span><span class="o">&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="nt">input</span><span class="nd">:invalid</span> <span class="p">{</span><span class="o">-</span><span class="n">moz</span><span class="o">-</span><span class="n">box</span><span class="o">-</span><span class="n">shadow</span><span class="o">:</span> <span class="nb">none</span><span class="p">;}</span> </span><span id="L-3"><a name="L-3"></a><span class="nt">input</span><span class="nd">:focus</span> <span class="p">{</span><span class="nb">border-color</span><span class="o">:</span><span class="m">#fff</span><span class="p">;</span> <span class="nb">outline</span><span class="o">:</span> <span class="nb">none</span><span class="p">;</span> <span class="o">-</span><span class="n">moz</span><span class="o">-</span><span class="n">box</span><span class="o">-</span><span class="n">shadow</span><span class="o">:</span> <span class="m">0</span> <span class="m">0</span> <span class="m">0.25em</span> <span class="m">#fff</span><span class="p">;</span> <span class="o">-</span><span class="n">webkit</span><span class="o">-</span><span class="n">box</span><span class="o">-</span><span class="n">shadow</span><span class="o">:</span> <span class="m">0</span> <span class="m">0</span> <span class="m">0.25em</span> <span class="m">#fff</span><span class="p">;</span> <span class="n">box</span><span class="o">-</span><span class="n">shadow</span><span class="o">:</span> <span class="m">0</span> <span class="m">0</span> <span class="m">0.25em</span> <span class="m">#fff</span><span class="p">;}</span> </span><span id="L-4"><a name="L-4"></a><span class="o">&lt;/</span><span class="nt">style</span><span class="o">&gt;</span> </span></pre></div> </td></tr></table>
forms, html5, validation