snipt

Ctrl+h for KB shortcuts

PostgreSQL SQL dialect

postgres > select all custom plpgsql functions

1
2
3
4
5
6
7
8
select 
  pp.proname, 
  pg_get_functiondef(pp.oid)
from pg_proc pp
inner join pg_namespace pn on (pp.pronamespace = pn.oid)
inner join pg_language pl on (pp.prolang = pl.oid)
where pl.lanname IN ('plpgsql') 
  and pn.nspname <> 'information_schema';
https://snipt.net/embed/b0d97086d193266305bee10c8f8adbc4/
/raw/b0d97086d193266305bee10c8f8adbc4/
b0d97086d193266305bee10c8f8adbc4
postgresql
PostgreSQL SQL dialect
8
2019-08-22T03:38:37
True
False
False
/api/public/snipt/148005/
postgres-select-all-custom-functions
<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">select</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">pp</span><span class="mf">.</span><span class="n">proname</span><span class="p">,</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">pg_get_functiondef</span><span class="p">(</span><span class="n">pp</span><span class="mf">.</span><span class="n">oid</span><span class="p">)</span> </span><span id="L-4"><a name="L-4"></a><span class="k">from</span> <span class="n">pg_proc</span> <span class="n">pp</span> </span><span id="L-5"><a name="L-5"></a><span class="k">inner</span> <span class="k">join</span> <span class="n">pg_namespace</span> <span class="n">pn</span> <span class="k">on</span> <span class="p">(</span><span class="n">pp</span><span class="mf">.</span><span class="n">pronamespace</span> <span class="o">=</span> <span class="n">pn</span><span class="mf">.</span><span class="n">oid</span><span class="p">)</span> </span><span id="L-6"><a name="L-6"></a><span class="k">inner</span> <span class="k">join</span> <span class="n">pg_language</span> <span class="n">pl</span> <span class="k">on</span> <span class="p">(</span><span class="n">pp</span><span class="mf">.</span><span class="n">prolang</span> <span class="o">=</span> <span class="n">pl</span><span class="mf">.</span><span class="n">oid</span><span class="p">)</span> </span><span id="L-7"><a name="L-7"></a><span class="k">where</span> <span class="n">pl</span><span class="mf">.</span><span class="n">lanname</span> <span class="k">IN</span> <span class="p">(</span><span class="s1">&#39;plpgsql&#39;</span><span class="p">)</span> </span><span id="L-8"><a name="L-8"></a> <span class="k">and</span> <span class="n">pn</span><span class="mf">.</span><span class="n">nspname</span> <span class="o">&lt;&gt;</span> <span class="s1">&#39;information_schema&#39;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
postgres, postgresql, psql

Text only

javascript > math.js

0.3 - 0.2 // 0.09999999999999998
math.number(math.subtract(math.bignumber(0.3), math.bignumber(0.2))) // 0.1
https://snipt.net/embed/259948083580ef7fb062b1ad75aba2fe/
/raw/259948083580ef7fb062b1ad75aba2fe/
259948083580ef7fb062b1ad75aba2fe
text
Text only
4
2019-08-23T18:21:03
True
False
False
Feb 21, 2016 at 11:53 PM
/api/public/snipt/144381/
javascript-mathjs
<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>0.3 - 0.2 // 0.09999999999999998 </span><span id="L-2"><a name="L-2"></a>math.number(math.subtract(math.bignumber(0.3), math.bignumber(0.2))) // 0.1 </span></pre></div> </td></tr></table>
float, javascript, math

Text only

elixir decimal

1
2
3
4
5
6
0.3 - 0.1 # 0.19999999999999998
alias Decimal, as: D
D.sub(D.new(0.3), D.new(0.1)) # #Decimal<0.2>
D.sub(D.new(0.3), D.new(0.1)) |> D.to_string # "0.2"
{n, _} = D.sub(D.new(0.3), D.new(0.1)) |> D.to_string |> Float.parse # {0.2, ""}
n == 0.2 # true
https://snipt.net/embed/1637a2df443a7138ab88d0b3b18886f6/
/raw/1637a2df443a7138ab88d0b3b18886f6/
1637a2df443a7138ab88d0b3b18886f6
text
Text only
7
2019-08-23T18:19:41
True
False
False
/api/public/snipt/144380/
elixir-decimal
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>0.3 - 0.1 # 0.19999999999999998 </span><span id="L-2"><a name="L-2"></a>alias Decimal, as: D </span><span id="L-3"><a name="L-3"></a>D.sub(D.new(0.3), D.new(0.1)) # #Decimal&lt;0.2&gt; </span><span id="L-4"><a name="L-4"></a>D.sub(D.new(0.3), D.new(0.1)) |&gt; D.to_string # &quot;0.2&quot; </span><span id="L-5"><a name="L-5"></a>{n, _} = D.sub(D.new(0.3), D.new(0.1)) |&gt; D.to_string |&gt; Float.parse # {0.2, &quot;&quot;} </span><span id="L-6"><a name="L-6"></a>n == 0.2 # true </span></pre></div> </td></tr></table>
decimal, elixir, float, math

Elixir

elixir > list of all loaded module names

:code.all_loaded |> Enum.map(fn(t) -> IO.puts elem(t,0) end)
https://snipt.net/embed/d57f6b47a604e58c63d3fefeecf1bb4c/
/raw/d57f6b47a604e58c63d3fefeecf1bb4c/
d57f6b47a604e58c63d3fefeecf1bb4c
elixir
Elixir
1
2019-08-20T23:55:59
True
False
False
Jan 16, 2016 at 12:43 AM
/api/public/snipt/143607/
elixir-list-of-all-loaded-module-names
<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="ss">:code</span><span class="o">.</span><span class="n">all_loaded</span> <span class="o">|&gt;</span> <span class="nc">Enum</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="k">fn</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nc">IO</span><span class="o">.</span><span class="n">puts</span> <span class="n">elem</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span> <span class="k">end</span><span class="p">)</span> </span></pre></div> </td></tr></table>
elixir, erlang, iex, mix, modules

Bash

install elasticsearch-head plugin on osx

1
2
3
cd /usr/local/Cellar/elasticsearch/2.1.0_1/
bin/plugin install mobz/elasticsearch-head
open http://localhost:9200/_plugin/head
https://snipt.net/embed/8c31a72041f2f8ce8f50b4b2b72dd48a/
/raw/8c31a72041f2f8ce8f50b4b2b72dd48a/
8c31a72041f2f8ce8f50b4b2b72dd48a
bash
Bash
4
2019-08-23T09:43:44
True
False
False
Dec 17, 2015 at 12:44 PM
/api/public/snipt/143145/
install-elasticsearch-head-plugin-on-osx
<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><span class="nb">cd</span> /usr/local/Cellar/elasticsearch/2.1.0_1/ </span><span id="L-2"><a name="L-2"></a>bin/plugin install mobz/elasticsearch-head </span><span id="L-3"><a name="L-3"></a>open http://localhost:9200/_plugin/head </span></pre></div> </td></tr></table>
elasticsearch, osx, plugins

SQL

MySQL create user, grant privilege

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON my_db.* TO 'newuser'@'localhost';
https://snipt.net/embed/7d3ade302b050a58b4fecda7fcfa83b7/
/raw/7d3ade302b050a58b4fecda7fcfa83b7/
7d3ade302b050a58b4fecda7fcfa83b7
sql
SQL
3
2019-08-21T23:15:08
True
False
False
Oct 25, 2015 at 02:38 PM
/api/public/snipt/141931/
mysql-create-user-grant-privilege
<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">CREATE</span> <span class="k">USER</span> <span class="s1">&#39;newuser&#39;</span><span class="o">@</span><span class="s1">&#39;localhost&#39;</span> <span class="n">IDENTIFIED</span> <span class="k">BY</span> <span class="s1">&#39;password&#39;</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a><span class="k">GRANT</span> <span class="k">ALL</span> <span class="k">PRIVILEGES</span> <span class="k">ON</span> <span class="n">my_db</span><span class="p">.</span><span class="o">*</span> <span class="k">TO</span> <span class="s1">&#39;newuser&#39;</span><span class="o">@</span><span class="s1">&#39;localhost&#39;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
mysql, sql