snipt

Ctrl+h for KB shortcuts

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/
https://snipt.net/raw/45421794a489aedf059e12a82ccd6aec/
45421794a489aedf059e12a82ccd6aec
php
PHP
3
2016-09-28T17:32:13
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 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/
https://snipt.net/raw/14af6e64ee94a94600c79800a4daed82/
14af6e64ee94a94600c79800a4daed82
bash
Bash
2
2016-09-28T17:44:19
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 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/
https://snipt.net/raw/779c999a7ab2e994f60c97d030df3edb/
779c999a7ab2e994f60c97d030df3edb
bash
Bash
2
2016-09-26T23:49:32
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 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

Text only

gpg key import

1
2
3
4
5
6
7
8
MySQL.com, you must first import and register their public GPG key:

   1. Download public key named build@mysql.com from http://www.keyserver.net/ with one of two methods:
          * wget --output-document=pubkey_mysql.asc http://keyserver.veridis.com:11371/export?id=-8326718950139043339
            (Saves key 0x5072E1F5 as file pubkey_mysql.asc)
          * gpg --keyserver keyserver.veridis.com --recv-key 5072e1f5
            gpg --export -a 5072e1f5 > pubkey_mysql.asc 
   2. Import key: rpm --import pubkey_mysql.asc 
https://snipt.net/embed/045bf903920fe2d9f906897d0ced6b34/
https://snipt.net/raw/045bf903920fe2d9f906897d0ced6b34/
045bf903920fe2d9f906897d0ced6b34
text
Text only
8
2016-09-28T07:16:48
True
False
False
/api/public/snipt/15974/
gpg-key-import
<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 id="L-1"><a name="L-1"></a>MySQL.com, you must first import and register their public GPG key: </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> 1. Download public key named build@mysql.com from http://www.keyserver.net/ with one of two methods: </span><span id="L-4"><a name="L-4"></a> * wget --output-document=pubkey_mysql.asc http://keyserver.veridis.com:11371/export?id=-8326718950139043339 </span><span id="L-5"><a name="L-5"></a> (Saves key 0x5072E1F5 as file pubkey_mysql.asc) </span><span id="L-6"><a name="L-6"></a> * gpg --keyserver keyserver.veridis.com --recv-key 5072e1f5 </span><span id="L-7"><a name="L-7"></a> gpg --export -a 5072e1f5 &gt; pubkey_mysql.asc </span><span id="L-8"><a name="L-8"></a> 2. Import key: rpm --import pubkey_mysql.asc </span></pre></div> </td></tr></table>
gpg, import, key
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.