snipt

Ctrl+h for KB shortcuts

Text only

Delete from multiple tables using joins MySQL

1
2
3
4
DELETE table1, table2, table3 FROM table1
LEFT JOIN table2 USING(field)
LEFT JOIN table3 USING(field)
WHERE table1.field = 'value'
https://snippets.siftie.com/embed/d14c936ec5483be1ccc8f7451503f77c/
/raw/d14c936ec5483be1ccc8f7451503f77c/
d14c936ec5483be1ccc8f7451503f77c
text
Text only
4
2019-02-03T06:11:30
True
False
False
Feb 12, 2013 at 09:29 AM
/api/public/snipt/55627/
delete-from-multiple-tables-using-joins-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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>DELETE table1, table2, table3 FROM table1 </span><span id="L-2"><a name="L-2"></a>LEFT JOIN table2 USING(field) </span><span id="L-3"><a name="L-3"></a>LEFT JOIN table3 USING(field) </span><span id="L-4"><a name="L-4"></a>WHERE table1.field = &#39;value&#39; </span></pre></div> </td></tr></table>

Text only

Force reboot when "reboot" command does not work ubuntu 8.04LTS

sudo su
echo b > /proc/sysrq-trigger
https://snippets.siftie.com/embed/dc9aba8fc4bbb2b14c658b143eee426f/
/raw/dc9aba8fc4bbb2b14c658b143eee426f/
dc9aba8fc4bbb2b14c658b143eee426f
text
Text only
2
2019-02-19T05:32:05
True
False
False
Jan 28, 2013 at 05:28 PM
/api/public/snipt/54674/
force-reboot-when-reboot-command-does-not-work-ubuntu-804lts
<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>sudo su </span><span id="L-2"><a name="L-2"></a>echo b &gt; /proc/sysrq-trigger </span></pre></div> </td></tr></table>
"ubuntu reboot", reboot

Bash Session

fix network when cloning ubuntu

sudo rm /etc/udev/rules.d/70-persistent-net.rules
https://snippets.siftie.com/embed/890a5bc9175ab370407d99f22b2426b8/
/raw/890a5bc9175ab370407d99f22b2426b8/
890a5bc9175ab370407d99f22b2426b8
console
Bash Session
1
2016-12-30T03:43:22
True
False
False
Jul 10, 2012 at 09:27 AM
/api/public/snipt/43713/
fix-network-when-cloning-ubuntu
<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="go">sudo rm /etc/udev/rules.d/70-persistent-net.rules</span> </span></pre></div> </td></tr></table>

Bash

Determine size of directories in linux

du -h --max-depth=1 .
https://snippets.siftie.com/embed/857ebb68495f6f066f6afb4c1a376a73/
/raw/857ebb68495f6f066f6afb4c1a376a73/
857ebb68495f6f066f6afb4c1a376a73
bash
Bash
1
2019-02-19T05:22:20
True
False
False
/api/public/snipt/37504/
determine-size-of-directories-in-linux
<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>du -h --max-depth<span class="o">=</span><span class="m">1</span> . </span></pre></div> </td></tr></table>
"directory size", du, linux

PHP

let browser / user decide how to handle a file download

1
2
3
4
5
6
7
8
<?php

header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$filename;");
header("cache-control: private");
header("pragma: private");

?>
https://snippets.siftie.com/embed/c81581d99ff960204e8ef555fdc987f5/
/raw/c81581d99ff960204e8ef555fdc987f5/
c81581d99ff960204e8ef555fdc987f5
php
PHP
8
2019-02-19T05:23:20
True
False
False
/api/public/snipt/34308/
let-browser-user-decide-how-to-handle-a-file-download
<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> <a href="#L-8">8</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="nb">header</span><span class="p">(</span><span class="s2">&quot;Content-type: application/octet-stream&quot;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="nb">header</span><span class="p">(</span><span class="s2">&quot;Content-Disposition: attachment; filename=</span><span class="si">$filename</span><span class="s2">;&quot;</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="nb">header</span><span class="p">(</span><span class="s2">&quot;cache-control: private&quot;</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a><span class="nb">header</span><span class="p">(</span><span class="s2">&quot;pragma: private&quot;</span><span class="p">);</span> </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
download, file, php