snipt

Ctrl+h for KB shortcuts

PHP

api key generator

1
2
3
$key = implode('-', str_split(substr(strtolower(md5(microtime().rand(1000, 9999))), 0, 30), 6));

// bd9772-7ee404-56be09-848cdd-061e62
https://snipt.net/embed/e9754b12af7212f4ed4aafd9f612caf7/
/raw/e9754b12af7212f4ed4aafd9f612caf7/
e9754b12af7212f4ed4aafd9f612caf7
php
PHP
4
2019-08-19T16:07:50
True
False
False
Aug 15, 2019 at 04:04 PM
/api/public/snipt/353468/
api-key-generator
<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="x">$key = implode(&#39;-&#39;, str_split(substr(strtolower(md5(microtime().rand(1000, 9999))), 0, 30), 6));</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="x">// bd9772-7ee404-56be09-848cdd-061e62</span> </span></pre></div> </td></tr></table>
key

PHP

php - finding keys in an array that match a pattern

1
2
3
<?php

$vals = array_intersect_key( $this->input->post(), array_flip( preg_grep( '/^title/i', array_keys( $this->input->post() ) ) ) );
https://snipt.net/embed/45421794a489aedf059e12a82ccd6aec/
/raw/45421794a489aedf059e12a82ccd6aec/
45421794a489aedf059e12a82ccd6aec
php
PHP
3
2019-08-19T12:33:33
True
False
False
Mar 08, 2016 at 03:00 AM
/api/public/snipt/144620/
php-finding-keys-in-an-array-that-match-a-pattern
<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="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="nv">$vals</span> <span class="o">=</span> <span class="nb">array_intersect_key</span><span class="p">(</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">input</span><span class="o">-&gt;</span><span class="na">post</span><span class="p">(),</span> <span class="nb">array_flip</span><span class="p">(</span> <span class="nb">preg_grep</span><span class="p">(</span> <span class="s1">&#39;/^title/i&#39;</span><span class="p">,</span> <span class="nb">array_keys</span><span class="p">(</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">input</span><span class="o">-&gt;</span><span class="na">post</span><span class="p">()</span> <span class="p">)</span> <span class="p">)</span> <span class="p">)</span> <span class="p">);</span> </span></pre></div> </td></tr></table>
key, match, php

Bash

add gpg key to apt keyring

url="http://www.example.com/gpg.key"
wget -O - "$url" | sudo apt-key add -
https://snipt.net/embed/14af6e64ee94a94600c79800a4daed82/
/raw/14af6e64ee94a94600c79800a4daed82/
14af6e64ee94a94600c79800a4daed82
bash
Bash
2
2019-08-19T12:34:08
True
False
False
/api/public/snipt/141321/
add-gpg-key-to-apt
<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="nv">url</span><span class="o">=</span><span class="s2">&quot;http://www.example.com/gpg.key&quot;</span> </span><span id="L-2"><a name="L-2"></a>wget -O - <span class="s2">&quot;</span><span class="nv">$url</span><span class="s2">&quot;</span> <span class="p">|</span> sudo apt-key add - </span></pre></div> </td></tr></table>
apt, gpg, key, linux

Bash

generate ssh key

ssh-keygen -b 4096 -t dsa -f filename
https://snipt.net/embed/779c999a7ab2e994f60c97d030df3edb/
/raw/779c999a7ab2e994f60c97d030df3edb/
779c999a7ab2e994f60c97d030df3edb
bash
Bash
2
2019-08-19T12:36:34
True
False
False
/api/public/snipt/27980/
generate-ssh-key
<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>ssh-keygen -b <span class="m">4096</span> -t dsa -f filename </span></pre></div> </td></tr></table>
key, ssh