snipt

Ctrl+h for KB shortcuts

Bash

recursive grep in files

grep -R "funkcija" dir
https://snipt.net/embed/f8974d983e83723ab6814a10323edca7/
/raw/f8974d983e83723ab6814a10323edca7/
f8974d983e83723ab6814a10323edca7
bash
Bash
1
2019-05-22T05:03:36
True
False
False
/api/public/snipt/5186/
recursive-grep-in-files
<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>grep -R <span class="s2">&quot;funkcija&quot;</span> dir </span></pre></div> </td></tr></table>
grep

MySQL

Extract image filepaths from a particular prog_gallery galery

SELECT f.filepath FROM prog_gallery_images gal_i JOIN node n ON n.nid=gal_i.i_nid JOIN image i ON i.nid=gal_i.i_nid JOIN files f ON f.fid=i.fid WHERE g_nid=352 AND i.image_size='_original'
https://snipt.net/embed/a061976420fd6e21363a2d5858b810da/
/raw/a061976420fd6e21363a2d5858b810da/
a061976420fd6e21363a2d5858b810da
mysql
MySQL
1
2019-05-22T13:30:45
True
False
False
/api/public/snipt/4888/
extract-image-filepaths-from-a-particular-prog_gallery-galery
<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="k">SELECT</span> <span class="n">f</span><span class="p">.</span><span class="n">filepath</span> <span class="k">FROM</span> <span class="n">prog_gallery_images</span> <span class="n">gal_i</span> <span class="k">JOIN</span> <span class="n">node</span> <span class="n">n</span> <span class="k">ON</span> <span class="n">n</span><span class="p">.</span><span class="n">nid</span><span class="o">=</span><span class="n">gal_i</span><span class="p">.</span><span class="n">i_nid</span> <span class="k">JOIN</span> <span class="n">image</span> <span class="n">i</span> <span class="k">ON</span> <span class="n">i</span><span class="p">.</span><span class="n">nid</span><span class="o">=</span><span class="n">gal_i</span><span class="p">.</span><span class="n">i_nid</span> <span class="k">JOIN</span> <span class="n">files</span> <span class="n">f</span> <span class="k">ON</span> <span class="n">f</span><span class="p">.</span><span class="n">fid</span><span class="o">=</span><span class="n">i</span><span class="p">.</span><span class="n">fid</span> <span class="k">WHERE</span> <span class="n">g_nid</span><span class="o">=</span><span class="mi">352</span> <span class="k">AND</span> <span class="n">i</span><span class="p">.</span><span class="n">image_size</span><span class="o">=</span><span class="s1">&#39;_original&#39;</span> </span></pre></div> </td></tr></table>
drupal, prog_gallery

Bash

edit crontab in your favorite editor

host:~ user$ export EDITOR='pico'
host:~ user$ crontab -e
https://snipt.net/embed/94a16ce987d8b12f475fce8b4cbab897/
/raw/94a16ce987d8b12f475fce8b4cbab897/
94a16ce987d8b12f475fce8b4cbab897
bash
Bash
3
2019-05-20T17:00:10
True
False
False
/api/public/snipt/4874/
edit-crontab-in-your-favorite-editor
<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>host:~ user$ <span class="nb">export</span> <span class="nv">EDITOR</span><span class="o">=</span><span class="s1">&#39;pico&#39;</span> </span><span id="L-2"><a name="L-2"></a>host:~ user$ crontab -e </span></pre></div> </td></tr></table>
hate, vi

SQL

Select images and galeries from Drupal Acidfree gallery

SELECT f.filepath,td.name FROM node n JOIN files f ON f.nid=n.nid JOIN term_node tn ON tn.nid=n.nid JOIN term_data td ON td.tid=tn.tid WHERE n.type='image' AND filename='_original' ORDER BY td.name
https://snipt.net/embed/25fa9dbfefeb17c93fec0e7d42ef3ce0/
/raw/25fa9dbfefeb17c93fec0e7d42ef3ce0/
25fa9dbfefeb17c93fec0e7d42ef3ce0
sql
SQL
1
2019-05-20T17:26:12
True
False
False
/api/public/snipt/3807/
select-images-and-galeries-from-drupal-acidfree-gallery
<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="k">SELECT</span> <span class="n">f</span><span class="p">.</span><span class="n">filepath</span><span class="p">,</span><span class="n">td</span><span class="p">.</span><span class="n">name</span> <span class="k">FROM</span> <span class="n">node</span> <span class="n">n</span> <span class="k">JOIN</span> <span class="n">files</span> <span class="n">f</span> <span class="k">ON</span> <span class="n">f</span><span class="p">.</span><span class="n">nid</span><span class="o">=</span><span class="n">n</span><span class="p">.</span><span class="n">nid</span> <span class="k">JOIN</span> <span class="n">term_node</span> <span class="n">tn</span> <span class="k">ON</span> <span class="n">tn</span><span class="p">.</span><span class="n">nid</span><span class="o">=</span><span class="n">n</span><span class="p">.</span><span class="n">nid</span> <span class="k">JOIN</span> <span class="n">term_data</span> <span class="n">td</span> <span class="k">ON</span> <span class="n">td</span><span class="p">.</span><span class="n">tid</span><span class="o">=</span><span class="n">tn</span><span class="p">.</span><span class="n">tid</span> <span class="k">WHERE</span> <span class="n">n</span><span class="p">.</span><span class="k">type</span><span class="o">=</span><span class="s1">&#39;image&#39;</span> <span class="k">AND</span> <span class="n">filename</span><span class="o">=</span><span class="s1">&#39;_original&#39;</span> <span class="k">ORDER</span> <span class="k">BY</span> <span class="n">td</span><span class="p">.</span><span class="n">name</span> </span></pre></div> </td></tr></table>
acidfree, drupal, sql

Bash

Create a patch

cd /Applications/MAMP/htdocs/drupal/sites/all/modules/uc_discounts/
diff -up original.php new.php > filename.patch
https://snipt.net/embed/01b42cf1772da29851130c66c3aaa0c8/
/raw/01b42cf1772da29851130c66c3aaa0c8/
01b42cf1772da29851130c66c3aaa0c8
bash
Bash
2
2019-05-22T06:45:03
True
False
False
/api/public/snipt/1254/
create-a-patch
<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="nb">cd</span> /Applications/MAMP/htdocs/drupal/sites/all/modules/uc_discounts/ </span><span id="L-2"><a name="L-2"></a>diff -up original.php new.php &gt; filename.patch </span></pre></div> </td></tr></table>
bash

Bash

apply patch

patch -p0 < patch.txt
https://snipt.net/embed/d7434435766bb9bb67ed07db37d1c78b/
/raw/d7434435766bb9bb67ed07db37d1c78b/
d7434435766bb9bb67ed07db37d1c78b
bash
Bash
1
2019-05-16T18:53:54
True
False
False
/api/public/snipt/458/
apply-patch
<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>patch -p0 &lt; patch.txt </span></pre></div> </td></tr></table>
bash, linux, unix

Bash

show working directory

pwd
https://snipt.net/embed/34cdda62d6e7fcd085da03c184f6fb8c/
/raw/34cdda62d6e7fcd085da03c184f6fb8c/
34cdda62d6e7fcd085da03c184f6fb8c
bash
Bash
1
2019-05-22T05:24:46
True
False
False
/api/public/snipt/254/
show-working-directory
<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="nb">pwd</span> </span></pre></div> </td></tr></table>
bash, linux, unix