snipt

Ctrl+h for KB shortcuts

JavaScript

Jquery Submenu - active - remove and add

1
2
3
4
$("#submenu01").on("click", "a:not(.active)", function ( event ) {
    $(".active", event.delegateTarget).removeClass("active");
    $(this).addClass("active");
});
https://snipt.net/embed/af6aade45f123b2636cd4b7b8558e28f/
https://snipt.net/raw/af6aade45f123b2636cd4b7b8558e28f/
af6aade45f123b2636cd4b7b8558e28f
js
JavaScript
5
2016-09-24T01:51:30
True
False
False
Aug 05, 2013 at 12:29 PM
/api/public/snipt/72025/
jquery-submenu-active-remove-and-add
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#submenu01&quot;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s2">&quot;click&quot;</span><span class="p">,</span> <span class="s2">&quot;a:not(.active)&quot;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span> <span class="nx">event</span> <span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">$</span><span class="p">(</span><span class="s2">&quot;.active&quot;</span><span class="p">,</span> <span class="nx">event</span><span class="p">.</span><span class="nx">delegateTarget</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s2">&quot;active&quot;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s2">&quot;active&quot;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
active, add, addClass, class, jquery, remove

XML

Ubuntu Add Screen Size

xrandr --newmode "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync
xrandr --addmode VGA-0 1440x900
https://snipt.net/embed/2d70eb3df64f207a06a5c8880e17f409/
https://snipt.net/raw/2d70eb3df64f207a06a5c8880e17f409/
2d70eb3df64f207a06a5c8880e17f409
xml
XML
2
2016-09-23T14:57:03
True
False
False
/api/public/snipt/32852/
ubuntu-add-screen-size
<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>xrandr --newmode &quot;1440x900_60.00&quot; 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync </span><span id="L-2"><a name="L-2"></a>xrandr --addmode VGA-0 1440x900 </span></pre></div> </td></tr></table>
add, screen, size, ubuntu, xrandr

Ruby

Add column migration

1
2
3
4
5
6
7
def self.up
    add_column :table_name, :field_name, :string
  end
 
  def self.down
    remove_column :table_name, :field_name
  end
https://snipt.net/embed/4339ae7eee6c52f644a4207a5c903073/
https://snipt.net/raw/4339ae7eee6c52f644a4207a5c903073/
4339ae7eee6c52f644a4207a5c903073
rb
Ruby
7
2016-09-24T12:44:43
True
False
False
/api/public/snipt/25874/
add-column-migration
<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 id="L-1"><a name="L-1"></a><span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">up</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">add_column</span> <span class="ss">:table_name</span><span class="p">,</span> <span class="ss">:field_name</span><span class="p">,</span> <span class="ss">:string</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">end</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a> <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">down</span> </span><span id="L-6"><a name="L-6"></a> <span class="n">remove_column</span> <span class="ss">:table_name</span><span class="p">,</span> <span class="ss">:field_name</span> </span><span id="L-7"><a name="L-7"></a> <span class="k">end</span> </span></pre></div> </td></tr></table>
add, column, migration, rails, ruby

Bash

add string to top of text file

$ sed -e '1i\#!/bin/bash' -i backup.sh
https://snipt.net/embed/d7deda70543d69f572cda5b21d46807e/
https://snipt.net/raw/d7deda70543d69f572cda5b21d46807e/
d7deda70543d69f572cda5b21d46807e
bash
Bash
1
2016-09-22T10:48:48
True
False
False
/api/public/snipt/13984/
add-string-to-top-of-text-file
<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><span class="nv">$ </span>sed -e <span class="s1">&#39;1i\#!/bin/bash&#39;</span> -i backup.sh </span></pre></div> </td></tr></table>
add, bash, linux, script, string

Bash

useradd

useradd -d /DIRECTORY/USER_FOLDER -g MAIN_USER_GID_(or group name) -G OTHER,USER,GROUPS -s /sbin/nologin USERNAME
https://snipt.net/embed/2fff73ee83a2bd3ee6e95350b9607eb9/
https://snipt.net/raw/2fff73ee83a2bd3ee6e95350b9607eb9/
2fff73ee83a2bd3ee6e95350b9607eb9
bash
Bash
2
2016-09-24T12:31:26
True
False
False
/api/public/snipt/3019/
useradd
<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>useradd -d /DIRECTORY/USER_FOLDER -g MAIN_USER_GID_<span class="o">(</span>or group name<span class="o">)</span> -G OTHER,USER,GROUPS -s /sbin/nologin USERNAME </span></pre></div> </td></tr></table>
add, bash, group, user
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.