snipt

Ctrl+h for KB shortcuts

PostgreSQL console (psql)

Dump data from postgreSQL and compress it via gzip

psql -d news -c "\copy (select * from cnyes where newstime between '2015-1-1' and '2016-3-31') to stdout WITH (FORMAT CSV, HEADER TRUE, FORCE_QUOTE *)"  | gzip > /home/aha/cnyes.csv.gz
https://snipt.net/embed/7ecf3e734986d2ffd64027234dc64bac/
/raw/7ecf3e734986d2ffd64027234dc64bac/
7ecf3e734986d2ffd64027234dc64bac
psql
PostgreSQL console (psql)
1
2019-05-24T23:27:15
True
False
False
Apr 09, 2016 at 08:30 AM
/api/public/snipt/145288/
dump-data-from-postgresql-and-compress-it-via-gzip
<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="n">psql</span> <span class="o">-</span><span class="n">d</span> <span class="n">news</span> <span class="o">-</span><span class="n">c</span> <span class="s s-Name">&quot;\copy (select * from cnyes where newstime between &#39;2015-1-1&#39; and &#39;2016-3-31&#39;) to stdout WITH (FORMAT CSV, HEADER TRUE, FORCE_QUOTE *)&quot;</span> <span class="o">|</span> <span class="n">gzip</span> <span class="o">&gt;</span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">aha</span><span class="o">/</span><span class="n">cnyes</span><span class="mf">.</span><span class="k">csv</span><span class="mf">.</span><span class="n">gz</span> </span></pre></div> </td></tr></table>
csv, gzip, postgresql, sql

JavaScript

Inject jQuery into Chrome console

1
2
3
4
5
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type.
jQuery.noConflict();
https://snipt.net/embed/f550f796f2c31b07a2a64f57e29ca03d/
/raw/f550f796f2c31b07a2a64f57e29ca03d/
f550f796f2c31b07a2a64f57e29ca03d
js
JavaScript
5
2019-08-22T14:40:25
True
False
False
Apr 04, 2016 at 02:09 PM
/api/public/snipt/145151/
inject-jquery-into-chrome-console
<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="kd">var</span> <span class="nx">jq</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">&#39;script&#39;</span><span class="p">);</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">jq</span><span class="p">.</span><span class="nx">src</span> <span class="o">=</span> <span class="s2">&quot;https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js&quot;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;head&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">].</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">jq</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="c1">// ... give time for script to load, then type.</span> </span><span id="L-5"><a name="L-5"></a><span class="nx">jQuery</span><span class="p">.</span><span class="nx">noConflict</span><span class="p">();</span> </span></pre></div> </td></tr></table>
Chrome, jQuery, javascript

Bash

拉回git 遠端branch

git checkout --track -b foobar origin/foobar 
# 將遠端的 branch checkout 回來並建立一個新的 local branch,加上 --track 表示你之後還要pull、push回去,所以請 Git 記住對應關係。
https://snipt.net/embed/e29c7918ceec0898b25249475481b39e/
/raw/e29c7918ceec0898b25249475481b39e/
e29c7918ceec0898b25249475481b39e
bash
Bash
2
2019-08-21T09:47:22
True
False
False
Mar 09, 2016 at 09:01 PM
/api/public/snipt/144644/
git-branch
<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>git checkout --track -b foobar origin/foobar </span><span id="L-2"><a name="L-2"></a><span class="c1"># 將遠端的 branch checkout 回來並建立一個新的 local branch,加上 --track 表示你之後還要pull、push回去,所以請 Git 記住對應關係。</span> </span></pre></div> </td></tr></table>
git, sh