snipt

Ctrl+h for KB shortcuts

CSS

Media query

@media all and (min-width: 800px) {  }
https://snipt.net/embed/fbbc29898d3b78f2ab5e8f3f2d60cda9/
/raw/fbbc29898d3b78f2ab5e8f3f2d60cda9/
fbbc29898d3b78f2ab5e8f3f2d60cda9
css
CSS
1
2019-06-17T09:30:36
True
False
False
/api/public/snipt/35152/
media-query-2
<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="k">@media</span> <span class="nt">all</span> <span class="nt">and</span> <span class="o">(</span><span class="nt">min-width</span><span class="o">:</span> <span class="nt">800px</span><span class="o">)</span> <span class="p">{</span> <span class="p">}</span> </span></pre></div> </td></tr></table>
media, query

CSS

Media query

@media (min-width: 800px) {  }
https://snipt.net/embed/a134af7c8dbb5ba1c94b0c8c57d227f7/
/raw/a134af7c8dbb5ba1c94b0c8c57d227f7/
a134af7c8dbb5ba1c94b0c8c57d227f7
css
CSS
1
2019-06-17T09:30:46
True
False
False
/api/public/snipt/35151/
media-query-1
<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="k">@media</span> <span class="o">(</span><span class="nt">min-width</span><span class="o">:</span> <span class="nt">800px</span><span class="o">)</span> <span class="p">{</span> <span class="p">}</span> </span></pre></div> </td></tr></table>
media, query

PHP

WordPress Sticky Posts

1
2
3
4
5
6
7
<!--show latest sticky post-->
<?php
$sticky = rsort(get_option('sticky_posts'));
$sticky = array_slice($sticky,0,1);
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );
?>
<?php while ( have_posts() ) : the_post(); ?>
https://snipt.net/embed/82a4a002660036c59cdfa30e51ce3b2b/
/raw/82a4a002660036c59cdfa30e51ce3b2b/
82a4a002660036c59cdfa30e51ce3b2b
php
PHP
7
2019-06-19T20:38:39
True
False
False
/api/public/snipt/26428/
wordpress-sticky-posts
<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="x">&lt;!--show latest sticky post--&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="cp">&lt;?php</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">$sticky</span> <span class="o">=</span> <span class="nb">rsort</span><span class="p">(</span><span class="nx">get_option</span><span class="p">(</span><span class="s1">&#39;sticky_posts&#39;</span><span class="p">));</span> </span><span id="L-4"><a name="L-4"></a><span class="nv">$sticky</span> <span class="o">=</span> <span class="nb">array_slice</span><span class="p">(</span><span class="nv">$sticky</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="nx">query_posts</span><span class="p">(</span> <span class="k">array</span><span class="p">(</span> <span class="s1">&#39;post__in&#39;</span> <span class="o">=&gt;</span> <span class="nv">$sticky</span><span class="p">,</span> <span class="s1">&#39;caller_get_posts&#39;</span> <span class="o">=&gt;</span> <span class="mi">1</span> <span class="p">)</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><span id="L-7"><a name="L-7"></a><span class="cp">&lt;?php</span> <span class="k">while</span> <span class="p">(</span> <span class="nx">have_posts</span><span class="p">()</span> <span class="p">)</span> <span class="o">:</span> <span class="nx">the_post</span><span class="p">();</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
query, sticky, wordpress

JavaScript

1st querystring value

var fisrtQueryStringValue = window.location.search.substring(1).split("=")[1];
https://snipt.net/embed/c38017c11ff15bc2f4200885c732b184/
/raw/c38017c11ff15bc2f4200885c732b184/
c38017c11ff15bc2f4200885c732b184
js
JavaScript
1
2019-06-17T12:54:44
True
False
False
/api/public/snipt/15044/
1st-querystring-value
<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="kd">var</span> <span class="nx">fisrtQueryStringValue</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">search</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span><span class="nx">split</span><span class="p">(</span><span class="s2">&quot;=&quot;</span><span class="p">)[</span><span class="mi">1</span><span class="p">];</span> </span></pre></div> </td></tr></table>
query, string

PHP

Query with Pagination

1
2
3
4
<?php
     query_posts('posts_per_page=10' . '&paged=' . $paged .'&cat=63'); 
     if (have_posts()) : ?><?php while (have_posts()) : the_post(); 		
?>
https://snipt.net/embed/469b9c5474643741f7fbf6442ec9862b/
/raw/469b9c5474643741f7fbf6442ec9862b/
469b9c5474643741f7fbf6442ec9862b
php
PHP
4
2019-05-29T10:13:05
True
False
False
/api/public/snipt/14555/
query-with-pagination
<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 class="nx">query_posts</span><span class="p">(</span><span class="s1">&#39;posts_per_page=10&#39;</span> <span class="o">.</span> <span class="s1">&#39;&amp;paged=&#39;</span> <span class="o">.</span> <span class="nv">$paged</span> <span class="o">.</span><span class="s1">&#39;&amp;cat=63&#39;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">if</span> <span class="p">(</span><span class="nx">have_posts</span><span class="p">())</span> <span class="o">:</span> <span class="cp">?&gt;&lt;?php</span> <span class="k">while</span> <span class="p">(</span><span class="nx">have_posts</span><span class="p">())</span> <span class="o">:</span> <span class="nx">the_post</span><span class="p">();</span> </span><span id="L-4"><a name="L-4"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
pagination, query

MySQL

Find 10 largest MySQL Tables

SELECT concat(table_schema,'.',table_name),concat(round(table_rows/1000000,2),'M') rows,concat(round(data_length/(1024*1024*1024),2),'G') DATA,concat(round(index_length/(1024*1024*1024),2),'G') idx,concat(round((data_length+index_length)/(1024*1024*1024),2),'G') total_size,round(index_length/data_length,2) idxfrac FROM information_schema.TABLES ORDER BY data_length+index_length DESC LIMIT 10;
https://snipt.net/embed/fcad8409f3be4cdf745de5ee524d5445/
/raw/fcad8409f3be4cdf745de5ee524d5445/
fcad8409f3be4cdf745de5ee524d5445
mysql
MySQL
1
2019-06-17T10:34:35
True
False
False
/api/public/snipt/14507/
find-10-largest-mysql-tables
<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="k">SELECT</span> <span class="nf">concat</span><span class="p">(</span><span class="n">table_schema</span><span class="p">,</span><span class="s1">&#39;.&#39;</span><span class="p">,</span><span class="n">table_name</span><span class="p">),</span><span class="nf">concat</span><span class="p">(</span><span class="nf">round</span><span class="p">(</span><span class="n">table_rows</span><span class="o">/</span><span class="mi">1000000</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span><span class="s1">&#39;M&#39;</span><span class="p">)</span> <span class="n">rows</span><span class="p">,</span><span class="nf">concat</span><span class="p">(</span><span class="nf">round</span><span class="p">(</span><span class="n">data_length</span><span class="o">/</span><span class="p">(</span><span class="mi">1024</span><span class="o">*</span><span class="mi">1024</span><span class="o">*</span><span class="mi">1024</span><span class="p">),</span><span class="mi">2</span><span class="p">),</span><span class="s1">&#39;G&#39;</span><span class="p">)</span> <span class="n">DATA</span><span class="p">,</span><span class="nf">concat</span><span class="p">(</span><span class="nf">round</span><span class="p">(</span><span class="n">index_length</span><span class="o">/</span><span class="p">(</span><span class="mi">1024</span><span class="o">*</span><span class="mi">1024</span><span class="o">*</span><span class="mi">1024</span><span class="p">),</span><span class="mi">2</span><span class="p">),</span><span class="s1">&#39;G&#39;</span><span class="p">)</span> <span class="n">idx</span><span class="p">,</span><span class="nf">concat</span><span class="p">(</span><span class="nf">round</span><span class="p">((</span><span class="n">data_length</span><span class="o">+</span><span class="n">index_length</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="mi">1024</span><span class="o">*</span><span class="mi">1024</span><span class="o">*</span><span class="mi">1024</span><span class="p">),</span><span class="mi">2</span><span class="p">),</span><span class="s1">&#39;G&#39;</span><span class="p">)</span> <span class="n">total_size</span><span class="p">,</span><span class="nf">round</span><span class="p">(</span><span class="n">index_length</span><span class="o">/</span><span class="n">data_length</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span> <span class="n">idxfrac</span> <span class="k">FROM</span> <span class="n">information_schema</span><span class="p">.</span><span class="kp">TABLES</span> <span class="k">ORDER</span> <span class="k">BY</span> <span class="n">data_length</span><span class="o">+</span><span class="n">index_length</span> <span class="k">DESC</span> <span class="k">LIMIT</span> <span class="mi">10</span><span class="p">;</span> </span></pre></div> </td></tr></table>
mysql, query, size, space, tables