snipt

Ctrl+h for KB shortcuts

PHP

Module position count

1
2
3
4
5
<?php if ($this->countModules( 'position' )) : ?>
  <div>
    <jdoc:include type="modules" name="position" />
  </div>
<?php endif; ?>
https://snipt.net/embed/fb456f32b8fe58fb96fbd70db002da6e/
https://snipt.net/raw/fb456f32b8fe58fb96fbd70db002da6e/
fb456f32b8fe58fb96fbd70db002da6e
php
PHP
5
2016-09-29T23:13:43
True
False
False
Sep 25, 2013 at 02:25 PM
/api/public/snipt/67730/
module-position-count
<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 id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> <span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">countModules</span><span class="p">(</span> <span class="s1">&#39;position&#39;</span> <span class="p">))</span> <span class="o">:</span> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-2"><a name="L-2"></a><span class="x"> &lt;div&gt;</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> &lt;jdoc:include type=&quot;modules&quot; name=&quot;position&quot; /&gt;</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> &lt;/div&gt;</span> </span><span id="L-5"><a name="L-5"></a><span class="cp">&lt;?php</span> <span class="k">endif</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
count, joomla, module, position, template

Bash

Count WordPress plugin calls

strace php5 index.php 2>&1 | perl -ne 'print "$1\n" if (/wp-content\/plugins\/([\w-]*)/)' | sort | uniq -c | sort -n
https://snipt.net/embed/4bb4044d85a56a77a4e402b03422942d/
https://snipt.net/raw/4bb4044d85a56a77a4e402b03422942d/
4bb4044d85a56a77a4e402b03422942d
bash
Bash
1
2016-10-01T06:35:07
True
False
False
/api/public/snipt/29151/
count-wordpress-plugin-calls
<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 id="L-1"><a name="L-1"></a>strace php5 index.php 2&gt;<span class="p">&amp;</span><span class="m">1</span> <span class="p">|</span> perl -ne <span class="s1">&#39;print &quot;$1\n&quot; if (/wp-content\/plugins\/([\w-]*)/)&#39;</span> <span class="p">|</span> sort <span class="p">|</span> uniq -c <span class="p">|</span> sort -n </span></pre></div> </td></tr></table>
count, plugins, strace, wordpress

MySQL

Finding duplicate records in mysql

1
2
3
4
5
SELECT title, COUNT(title) AS num_found
FROM articles
GROUP BY title
HAVING num_found > 1
ORDER BY num_found DESC;
https://snipt.net/embed/fda42d21d2b6ec448a154963753734d3/
https://snipt.net/raw/fda42d21d2b6ec448a154963753734d3/
fda42d21d2b6ec448a154963753734d3
mysql
MySQL
5
2016-10-01T04:17:52
True
False
False
/api/public/snipt/22053/
finding-duplicate-records-in-mysql
<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 id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="n">title</span><span class="p">,</span> <span class="nf">COUNT</span><span class="p">(</span><span class="n">title</span><span class="p">)</span> <span class="k">AS</span> <span class="n">num_found</span> </span><span id="L-2"><a name="L-2"></a><span class="k">FROM</span> <span class="n">articles</span> </span><span id="L-3"><a name="L-3"></a><span class="k">GROUP</span> <span class="k">BY</span> <span class="n">title</span> </span><span id="L-4"><a name="L-4"></a><span class="k">HAVING</span> <span class="n">num_found</span> <span class="o">&gt;</span> <span class="mi">1</span> </span><span id="L-5"><a name="L-5"></a><span class="k">ORDER</span> <span class="k">BY</span> <span class="n">num_found</span> <span class="k">DESC</span><span class="p">;</span> </span></pre></div> </td></tr></table>
count, group, mysql, select

SQL

Count number of tables in a SQL Server database

1
2
3
USE YOURDBNAME
SELECT COUNT(*) from information_schema.tables
WHERE table_type = 'base table' 
https://snipt.net/embed/340d7c99c9bbb6921fe7594ef15e6a0d/
https://snipt.net/raw/340d7c99c9bbb6921fe7594ef15e6a0d/
340d7c99c9bbb6921fe7594ef15e6a0d
sql
SQL
3
2016-10-01T12:19:28
True
False
False
/api/public/snipt/14897/
count-number-of-tables-in-a-sql-server-database
<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 id="L-1"><a name="L-1"></a><span class="n">USE</span> <span class="n">YOURDBNAME</span> </span><span id="L-2"><a name="L-2"></a><span class="k">SELECT</span> <span class="k">COUNT</span><span class="p">(</span><span class="o">*</span><span class="p">)</span> <span class="k">from</span> <span class="n">information_schema</span><span class="p">.</span><span class="n">tables</span> </span><span id="L-3"><a name="L-3"></a><span class="k">WHERE</span> <span class="n">table_type</span> <span class="o">=</span> <span class="s1">&#39;base table&#39;</span> </span></pre></div> </td></tr></table>
count, tables, tsql

PHP

Returns the number of results

<?php echo $wp_query->found_posts; ?>
https://snipt.net/embed/8ab983b26990fbcd4421a5dbe746a118/
https://snipt.net/raw/8ab983b26990fbcd4421a5dbe746a118/
8ab983b26990fbcd4421a5dbe746a118
php
PHP
1
2016-10-01T11:29:51
True
False
False
/api/public/snipt/12535/
returns-the-number-of-results
<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 id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$wp_query</span><span class="o">-&gt;</span><span class="na">found_posts</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
count, number, results, wordpress
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.