snipt

Ctrl+h for KB shortcuts

MySQL

Drop tables with a certain prefix

1
2
3
4
-- This will compose an SQL query that you can run afterwards:
SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) 
    AS statement FROM information_schema.tables 
    WHERE table_schema = 'database_name' AND table_name LIKE 'myprefix_%';
https://snipt.net/embed/ab590505c05b5327738ec81b444a6bc7/
/raw/ab590505c05b5327738ec81b444a6bc7/
ab590505c05b5327738ec81b444a6bc7
mysql
MySQL
4
2019-07-15T18:47:46
True
False
False
/api/public/snipt/35894/
drop-tables-with-a-certain-prefix
<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="c1">-- This will compose an SQL query that you can run afterwards:</span> </span><span id="L-2"><a name="L-2"></a><span class="k">SELECT</span> <span class="nf">CONCAT</span><span class="p">(</span> <span class="s1">&#39;DROP TABLE &#39;</span><span class="p">,</span> <span class="nf">GROUP_CONCAT</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> <span class="p">,</span> <span class="s1">&#39;;&#39;</span> <span class="p">)</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">AS</span> <span class="n">statement</span> <span class="k">FROM</span> <span class="n">information_schema</span><span class="p">.</span><span class="kp">tables</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">WHERE</span> <span class="n">table_schema</span> <span class="o">=</span> <span class="s1">&#39;database_name&#39;</span> <span class="k">AND</span> <span class="n">table_name</span> <span class="k">LIKE</span> <span class="s1">&#39;myprefix_%&#39;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
mysql

PHP

Inject data into a module position

1
2
3
4
// Inject data from your component into the right module position
JFactory::getDocument()->setBuffer($data, 'modules', 'right');

// Note: Data will not be shown unless there are "real" modules present in position right
https://snipt.net/embed/59aaa7762502d28b3510bf05eeff312f/
/raw/59aaa7762502d28b3510bf05eeff312f/
59aaa7762502d28b3510bf05eeff312f
php
PHP
4
2019-07-18T09:39:10
True
False
False
/api/public/snipt/27729/
inject-data-into-a-module-position
<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">// Inject data from your component into the right module position</span> </span><span id="L-2"><a name="L-2"></a><span class="x">JFactory::getDocument()-&gt;setBuffer($data, &#39;modules&#39;, &#39;right&#39;);</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="x">// Note: Data will not be shown unless there are &quot;real&quot; modules present in position right</span> </span></pre></div> </td></tr></table>
joomla, modules

Bash

Fire up an MKV-file with an external ac3-file in VLC

/Applications/VLC.app/Contents/MacOS/VLC file.mkv --input-slave file.ac3
https://snipt.net/embed/0e083fc0be5f32d5b7aacee1836f2d2a/
/raw/0e083fc0be5f32d5b7aacee1836f2d2a/
0e083fc0be5f32d5b7aacee1836f2d2a
bash
Bash
1
2019-07-17T17:46:22
True
False
False
/api/public/snipt/22245/
fire-up-an-mkv-file-with-an-external-ac3-file-in-vlc
<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>/Applications/VLC.app/Contents/MacOS/VLC file.mkv --input-slave file.ac3 </span></pre></div> </td></tr></table>
ac3, mkv, osx, video, vlc

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/
/raw/fda42d21d2b6ec448a154963753734d3/
fda42d21d2b6ec448a154963753734d3
mysql
MySQL
5
2019-07-06T08:55:19
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></span><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