snipt

Ctrl+h for KB shortcuts

PHP

providing node templates in a module directory

1
2
3
4
5
6
7
<?php

function mymodule_theme_registry_alter(&$theme_registry) {
  $theme_hook = 'node';
  $modulepath = drupal_get_path('module', 'mymodule');
  array_unshift($theme_registry[$theme_hook]['theme paths'], $modulepath);
}
https://snippets.siftie.com/embed/ded0a5f2411a2d6a83824a3d7f70a17d/
/raw/ded0a5f2411a2d6a83824a3d7f70a17d/
ded0a5f2411a2d6a83824a3d7f70a17d
php
PHP
8
2019-04-13T17:50:48
True
False
False
/api/public/snipt/72/
providing-node-templates-in-a-module-directory
<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></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="k">function</span> <span class="nf">mymodule_theme_registry_alter</span><span class="p">(</span><span class="o">&amp;</span><span class="nv">$theme_registry</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">$theme_hook</span> <span class="o">=</span> <span class="s1">&#39;node&#39;</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a> <span class="nv">$modulepath</span> <span class="o">=</span> <span class="nx">drupal_get_path</span><span class="p">(</span><span class="s1">&#39;module&#39;</span><span class="p">,</span> <span class="s1">&#39;mymodule&#39;</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a> <span class="nb">array_unshift</span><span class="p">(</span><span class="nv">$theme_registry</span><span class="p">[</span><span class="nv">$theme_hook</span><span class="p">][</span><span class="s1">&#39;theme paths&#39;</span><span class="p">],</span> <span class="nv">$modulepath</span><span class="p">);</span> </span><span id="L-7"><a name="L-7"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
"node template", "theme registry", drupal

Bash

svn delete all files marked for deletion

svn status |grep '^!' |sed 's/^!      /svn delete "/g' |sed 's/$/"/g' |sh
https://snippets.siftie.com/embed/13be4cf6c9164f255653122f1f9bad8d/
/raw/13be4cf6c9164f255653122f1f9bad8d/
13be4cf6c9164f255653122f1f9bad8d
bash
Bash
1
2019-04-02T16:26:19
True
False
False
/api/public/snipt/69/
svn-delete-all-files-marked-for-deletion
<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>svn status <span class="p">|</span>grep <span class="s1">&#39;^!&#39;</span> <span class="p">|</span>sed <span class="s1">&#39;s/^! /svn delete &quot;/g&#39;</span> <span class="p">|</span>sed <span class="s1">&#39;s/$/&quot;/g&#39;</span> <span class="p">|</span>sh </span></pre></div> </td></tr></table>
subversion

Bash

svn add all files marked for add

svn status |grep '^?' |sed 's/^?      /svn add "/g' |sed 's/$/"/g' |sh
https://snippets.siftie.com/embed/d08a99d87660f35353d5fb6cd0f1b15b/
/raw/d08a99d87660f35353d5fb6cd0f1b15b/
d08a99d87660f35353d5fb6cd0f1b15b
bash
Bash
1
2019-02-17T20:30:43
True
False
False
/api/public/snipt/68/
svn-add-all-files-marked-for-add
<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>svn status <span class="p">|</span>grep <span class="s1">&#39;^?&#39;</span> <span class="p">|</span>sed <span class="s1">&#39;s/^? /svn add &quot;/g&#39;</span> <span class="p">|</span>sed <span class="s1">&#39;s/$/&quot;/g&#39;</span> <span class="p">|</span>sh </span></pre></div> </td></tr></table>
subversion

Bash

recursively remove all .svn directories

find . -name .svn -print0 | xargs -0 rm -rf
https://snippets.siftie.com/embed/c1a0386cbfe673d8aecaf85d012372c2/
/raw/c1a0386cbfe673d8aecaf85d012372c2/
c1a0386cbfe673d8aecaf85d012372c2
bash
Bash
1
2019-02-17T20:30:42
True
False
False
/api/public/snipt/67/
recursively-remove-all-svn-directories
<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>find . -name .svn -print0 <span class="p">|</span> xargs -0 rm -rf </span></pre></div> </td></tr></table>
subversion

JavaScript

grab selected option from select element

$('#selectList').val();
https://snippets.siftie.com/embed/ab9f23364ec4895ead234c065ad7466f/
/raw/ab9f23364ec4895ead234c065ad7466f/
ab9f23364ec4895ead234c065ad7466f
js
JavaScript
1
2019-04-08T23:37:53
True
False
False
/api/public/snipt/46/
grab-selected-option-from-select-element
<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="nx">$</span><span class="p">(</span><span class="s1">&#39;#selectList&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span> </span></pre></div> </td></tr></table>
javascript, jquery

Bash

add existing user to primary group

usermod -a -G ftp tony
https://snippets.siftie.com/embed/7af5ed24e4ea83713e0524eed086e631/
/raw/7af5ed24e4ea83713e0524eed086e631/
7af5ed24e4ea83713e0524eed086e631
bash
Bash
1
2019-04-10T13:29:52
True
False
False
/api/public/snipt/42/
add-existing-user-to-primary-group
<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>usermod -a -G ftp tony </span></pre></div> </td></tr></table>
unix

HTML

ie6 conditional

<!--[if IE 6]><![endif]-->
https://snippets.siftie.com/embed/a04ce83e4441d1d1af0b6dcbd6cf27a4/
/raw/a04ce83e4441d1d1af0b6dcbd6cf27a4/
a04ce83e4441d1d1af0b6dcbd6cf27a4
html
HTML
1
2019-04-01T20:20:46
True
False
False
/api/public/snipt/40/
ie6-conditional
<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="c">&lt;!--[if IE 6]&gt;&lt;![endif]--&gt;</span> </span></pre></div> </td></tr></table>
ie

CSS

css clearfix

1
2
3
4
5
6
.clearfix:after {content: "."; display: block; height: 0; clear: both; visibility: hidden;}
.clearfix {display: inline-block;}
/* \*/
* html .clearfix {height: 1%;}
.clearfix {display: block;}
/* */
https://snippets.siftie.com/embed/bfa696b8d476ed26288efb5aa41af154/
/raw/bfa696b8d476ed26288efb5aa41af154/
bfa696b8d476ed26288efb5aa41af154
css
CSS
6
2019-04-20T01:18:42
True
False
False
/api/public/snipt/35/
css-clearfix
<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><span class="nc">.clearfix</span><span class="nd">:after</span> <span class="p">{</span><span class="nb">content</span><span class="o">:</span> <span class="s2">&quot;.&quot;</span><span class="p">;</span> <span class="nb">display</span><span class="o">:</span> <span class="nb">block</span><span class="p">;</span> <span class="nb">height</span><span class="o">:</span> <span class="m">0</span><span class="p">;</span> <span class="nb">clear</span><span class="o">:</span> <span class="nb">both</span><span class="p">;</span> <span class="nb">visibility</span><span class="o">:</span> <span class="nb">hidden</span><span class="p">;}</span> </span><span id="L-2"><a name="L-2"></a><span class="nc">.clearfix</span> <span class="p">{</span><span class="nb">display</span><span class="o">:</span> <span class="nb">inline</span><span class="o">-</span><span class="nb">block</span><span class="p">;}</span> </span><span id="L-3"><a name="L-3"></a><span class="c">/* \*/</span> </span><span id="L-4"><a name="L-4"></a><span class="o">*</span> <span class="nt">html</span> <span class="nc">.clearfix</span> <span class="p">{</span><span class="nb">height</span><span class="o">:</span> <span class="m">1%</span><span class="p">;}</span> </span><span id="L-5"><a name="L-5"></a><span class="nc">.clearfix</span> <span class="p">{</span><span class="nb">display</span><span class="o">:</span> <span class="nb">block</span><span class="p">;}</span> </span><span id="L-6"><a name="L-6"></a><span class="c">/* */</span> </span></pre></div> </td></tr></table>
css

CSS

css reset

1
2
3
4
5
6
7
8
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline;}
:focus {outline: 0;}
body {line-height: 1; color: black; background: white;}
ol, ul {list-style: none;}
table {border-collapse: separate; border-spacing: 0;}
caption, th, td {text-align: left; font-weight: normal;}
blockquote:before, blockquote:after, q:before, q:after {content: "";}
blockquote, q {quotes: "" "";}
https://snippets.siftie.com/embed/87e715ec82ab19a75e811e2481e94b56/
/raw/87e715ec82ab19a75e811e2481e94b56/
87e715ec82ab19a75e811e2481e94b56
css
CSS
8
2019-04-11T07:31:38
True
False
False
/api/public/snipt/31/
css-reset
<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="nt">html</span><span class="o">,</span> <span class="nt">body</span><span class="o">,</span> <span class="nt">div</span><span class="o">,</span> <span class="nt">span</span><span class="o">,</span> <span class="nt">applet</span><span class="o">,</span> <span class="nt">object</span><span class="o">,</span> <span class="nt">iframe</span><span class="o">,</span> <span class="nt">h1</span><span class="o">,</span> <span class="nt">h2</span><span class="o">,</span> <span class="nt">h3</span><span class="o">,</span> <span class="nt">h4</span><span class="o">,</span> <span class="nt">h5</span><span class="o">,</span> <span class="nt">h6</span><span class="o">,</span> <span class="nt">p</span><span class="o">,</span> <span class="nt">blockquote</span><span class="o">,</span> <span class="nt">pre</span><span class="o">,</span> <span class="nt">a</span><span class="o">,</span> <span class="nt">abbr</span><span class="o">,</span> <span class="nt">acronym</span><span class="o">,</span> <span class="nt">address</span><span class="o">,</span> <span class="nt">big</span><span class="o">,</span> <span class="nt">cite</span><span class="o">,</span> <span class="nt">code</span><span class="o">,</span> <span class="nt">del</span><span class="o">,</span> <span class="nt">dfn</span><span class="o">,</span> <span class="nt">em</span><span class="o">,</span> <span class="nt">font</span><span class="o">,</span> <span class="nt">img</span><span class="o">,</span> <span class="nt">ins</span><span class="o">,</span> <span class="nt">kbd</span><span class="o">,</span> <span class="nt">q</span><span class="o">,</span> <span class="nt">s</span><span class="o">,</span> <span class="nt">samp</span><span class="o">,</span> <span class="nt">small</span><span class="o">,</span> <span class="nt">strike</span><span class="o">,</span> <span class="nt">strong</span><span class="o">,</span> <span class="nt">sub</span><span class="o">,</span> <span class="nt">sup</span><span class="o">,</span> <span class="nt">tt</span><span class="o">,</span> <span class="nt">var</span><span class="o">,</span> <span class="nt">dl</span><span class="o">,</span> <span class="nt">dt</span><span class="o">,</span> <span class="nt">dd</span><span class="o">,</span> <span class="nt">ol</span><span class="o">,</span> <span class="nt">ul</span><span class="o">,</span> <span class="nt">li</span><span class="o">,</span> <span class="nt">fieldset</span><span class="o">,</span> <span class="nt">form</span><span class="o">,</span> <span class="nt">label</span><span class="o">,</span> <span class="nt">legend</span><span class="o">,</span> <span class="nt">table</span><span class="o">,</span> <span class="nt">caption</span><span class="o">,</span> <span class="nt">tbody</span><span class="o">,</span> <span class="nt">tfoot</span><span class="o">,</span> <span class="nt">thead</span><span class="o">,</span> <span class="nt">tr</span><span class="o">,</span> <span class="nt">th</span><span class="o">,</span> <span class="nt">td</span> <span class="p">{</span><span class="nb">margin</span><span class="o">:</span> <span class="m">0</span><span class="p">;</span> <span class="nb">padding</span><span class="o">:</span> <span class="m">0</span><span class="p">;</span> <span class="nb">border</span><span class="o">:</span> <span class="m">0</span><span class="p">;</span> <span class="nb">outline</span><span class="o">:</span> <span class="m">0</span><span class="p">;</span> <span class="nb">font-weight</span><span class="o">:</span> <span class="nb">inherit</span><span class="p">;</span> <span class="nb">font-style</span><span class="o">:</span> <span class="nb">inherit</span><span class="p">;</span> <span class="nb">font-size</span><span class="o">:</span> <span class="m">100%</span><span class="p">;</span> <span class="nb">font-family</span><span class="o">:</span> <span class="nb">inherit</span><span class="p">;</span> <span class="nb">vertical-align</span><span class="o">:</span> <span class="nb">baseline</span><span class="p">;}</span> </span><span id="L-2"><a name="L-2"></a><span class="nd">:focus</span> <span class="p">{</span><span class="nb">outline</span><span class="o">:</span> <span class="m">0</span><span class="p">;}</span> </span><span id="L-3"><a name="L-3"></a><span class="nt">body</span> <span class="p">{</span><span class="nb">line-height</span><span class="o">:</span> <span class="m">1</span><span class="p">;</span> <span class="nb">color</span><span class="o">:</span> <span class="nb">black</span><span class="p">;</span> <span class="nb">background</span><span class="o">:</span> <span class="nb">white</span><span class="p">;}</span> </span><span id="L-4"><a name="L-4"></a><span class="nt">ol</span><span class="o">,</span> <span class="nt">ul</span> <span class="p">{</span><span class="nb">list-style</span><span class="o">:</span> <span class="nb">none</span><span class="p">;}</span> </span><span id="L-5"><a name="L-5"></a><span class="nt">table</span> <span class="p">{</span><span class="nb">border-collapse</span><span class="o">:</span> <span class="nb">separate</span><span class="p">;</span> <span class="nb">border-spacing</span><span class="o">:</span> <span class="m">0</span><span class="p">;}</span> </span><span id="L-6"><a name="L-6"></a><span class="nt">caption</span><span class="o">,</span> <span class="nt">th</span><span class="o">,</span> <span class="nt">td</span> <span class="p">{</span><span class="nb">text-align</span><span class="o">:</span> <span class="nb">left</span><span class="p">;</span> <span class="nb">font-weight</span><span class="o">:</span> <span class="nb">normal</span><span class="p">;}</span> </span><span id="L-7"><a name="L-7"></a><span class="nt">blockquote</span><span class="nd">:before</span><span class="o">,</span> <span class="nt">blockquote</span><span class="nd">:after</span><span class="o">,</span> <span class="nt">q</span><span class="nd">:before</span><span class="o">,</span> <span class="nt">q</span><span class="nd">:after</span> <span class="p">{</span><span class="nb">content</span><span class="o">:</span> <span class="s2">&quot;&quot;</span><span class="p">;}</span> </span><span id="L-8"><a name="L-8"></a><span class="nt">blockquote</span><span class="o">,</span> <span class="nt">q</span> <span class="p">{</span><span class="nb">quotes</span><span class="o">:</span> <span class="s2">&quot;&quot;</span> <span class="s2">&quot;&quot;</span><span class="p">;}</span> </span></pre></div> </td></tr></table>
css