snipt

Ctrl+h for KB shortcuts

MySQL

Copy table from 1 database to another.

DROP TABLE IF EXISTS `db1`.`tbl`;
CREATE TABLE `db2`.`tbl` SELECT * FROM `db1`.`tbl`;
https://snipt.net/embed/fc281313adf8a9c1ab00acccf85c93e5/
/raw/fc281313adf8a9c1ab00acccf85c93e5/
fc281313adf8a9c1ab00acccf85c93e5
mysql
MySQL
2
2019-06-22T17:32:36
True
False
False
/api/public/snipt/36543/
copy-table-from-1-database-to-another
<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="k">DROP</span> <span class="k">TABLE</span> <span class="k">IF</span> <span class="k">EXISTS</span> <span class="ss">`db1`</span><span class="p">.</span><span class="ss">`tbl`</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a><span class="k">CREATE</span> <span class="k">TABLE</span> <span class="ss">`db2`</span><span class="p">.</span><span class="ss">`tbl`</span> <span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="ss">`db1`</span><span class="p">.</span><span class="ss">`tbl`</span><span class="p">;</span> </span></pre></div> </td></tr></table>
copy, mysql, sync, table

Ruby

Return the value that was computed in Dispatch::Queue.sync

1
2
3
4
5
6
7
8
class Dispatch::Queue
    def niko_sync(&block)
        self.sync {@niko_return = block.call }
        ret = @niko_return
        @niko_return = nil
        ret
    end
end
https://snipt.net/embed/3132bd4aa84b885207a496ece1c47d78/
/raw/3132bd4aa84b885207a496ece1c47d78/
3132bd4aa84b885207a496ece1c47d78
rb
Ruby
8
2019-06-14T12:15:51
True
False
False
/api/public/snipt/27523/
return-the-value-that-was-computed-in-dispatchqueuesync
<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="k">class</span> <span class="nc">Dispatch</span><span class="o">::</span><span class="no">Queue</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">def</span> <span class="nf">niko_sync</span><span class="p">(</span><span class="o">&amp;</span><span class="n">block</span><span class="p">)</span> </span><span id="L-3"><a name="L-3"></a> <span class="nb">self</span><span class="o">.</span><span class="n">sync</span> <span class="p">{</span><span class="vi">@niko_return</span> <span class="o">=</span> <span class="n">block</span><span class="o">.</span><span class="n">call</span> <span class="p">}</span> </span><span id="L-4"><a name="L-4"></a> <span class="n">ret</span> <span class="o">=</span> <span class="vi">@niko_return</span> </span><span id="L-5"><a name="L-5"></a> <span class="vi">@niko_return</span> <span class="o">=</span> <span class="kp">nil</span> </span><span id="L-6"><a name="L-6"></a> <span class="n">ret</span> </span><span id="L-7"><a name="L-7"></a> <span class="k">end</span> </span><span id="L-8"><a name="L-8"></a><span class="k">end</span> </span></pre></div> </td></tr></table>
"macruby grandcentraldispatch gcd", sync

Bash

Time Synchronization using NTP

1
2
3
ntpdate 0.pool.ntp.org
ntpdate 1.pool.ntp.org
ntpdate 2.pool.ntp.org
https://snipt.net/embed/7a5f06bbebfe66af99f83573f419bbb9/
/raw/7a5f06bbebfe66af99f83573f419bbb9/
7a5f06bbebfe66af99f83573f419bbb9
bash
Bash
3
2019-06-23T19:50:52
True
False
False
/api/public/snipt/5641/
set-time-zone-1
<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></span><span id="L-1"><a name="L-1"></a>ntpdate 0.pool.ntp.org </span><span id="L-2"><a name="L-2"></a>ntpdate 1.pool.ntp.org </span><span id="L-3"><a name="L-3"></a>ntpdate 2.pool.ntp.org </span></pre></div> </td></tr></table>
date, ntp, server, sync, system, time, zone