snipt

Ctrl+h for KB shortcuts
Notice: Snipt is moving away from free accounts on May 1st, 2014. Read more about the transition here.
#29766

Ruby irb session

List all routes for a Rails app

1
2
3
4
5
6
# Concise method
puts ActionController::Routing::Routes.routes

# Expanded method
rts = ActionController::Routing::Routes
puts rts.routes
https://snipt.net/embed/8b7de54f1e478564b69cdb56da54f965/
https://snipt.net/raw/8b7de54f1e478564b69cdb56da54f965/
8b7de54f1e478564b69cdb56da54f965
rbcon
Ruby irb session
6
2014-04-19T10:34:29
True
False
/api/public/snipt/29766/
list-all-routes-for-a-rails-app
<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 id="L-1"><a name="L-1"></a><span class="go"># Concise method</span> </span><span id="L-2"><a name="L-2"></a><span class="go">puts ActionController::Routing::Routes.routes</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="go"># Expanded method</span> </span><span id="L-5"><a name="L-5"></a><span class="go">rts = ActionController::Routing::Routes</span> </span><span id="L-6"><a name="L-6"></a><span class="go">puts rts.routes</span> </span></pre></div> </td></tr></table>
information, rails, routes, ruby
#29203

Bash

Clear OS X Log to speed up Terminal loading.

sudo rm -rf /private/var/log/asl/*.asl
https://snipt.net/embed/ff9fe35b9cc1d6c543689f1ac02ca20c/
https://snipt.net/raw/ff9fe35b9cc1d6c543689f1ac02ca20c/
ff9fe35b9cc1d6c543689f1ac02ca20c
bash
Bash
1
2014-04-19T12:12:42
True
False
/api/public/snipt/29203/
clear-os-x-log-to-speed-up-terminal-loading
<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>sudo rm -rf /private/var/log/asl/*.asl </span></pre></div> </td></tr></table>
"os x", bash, cmd, faster, log, mac, osx, speed, terminal
#29102

Bash

Enable "Do Nothing" on laptop lid close in Ubuntu.

gconftool-2 --type string --set /apps/gnome-power-manager/buttons/lid_ac "nothing"
https://snipt.net/embed/a27fed662e464b400cae6f0bf6705863/
https://snipt.net/raw/a27fed662e464b400cae6f0bf6705863/
a27fed662e464b400cae6f0bf6705863
bash
Bash
1
2014-04-22T13:36:42
True
False
/api/public/snipt/29102/
enable-do-nothing-on-laptop-lid-close-in-ubuntu
<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>gconftool-2 --type string --set /apps/gnome-power-manager/buttons/lid_ac <span class="s2">&quot;nothing&quot;</span> </span></pre></div> </td></tr></table>
"power management", ubuntu
#28643

Bash

Add SSH Public Key to a server.

ssh-copy-id user@remote.server.com
https://snipt.net/embed/6e9566c195f35e05e9c309a8a292d46c/
https://snipt.net/raw/6e9566c195f35e05e9c309a8a292d46c/
6e9566c195f35e05e9c309a8a292d46c
bash
Bash
1
2014-04-14T12:14:14
True
False
/api/public/snipt/28643/
add-ssh-public-key-to-a-server
<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-copy-id user@remote.server.com </span></pre></div> </td></tr></table>
"public key", bash, copy, security, ssh
#28360

Ruby

Get current environment database configuration.

1
2
3
4
Rails.configuration.database_configuration[Rails.env]


=> {"encoding"=>"unicode", "username"=>"postgres", "adapter"=>"postgresql", "port"=>5432, "host"=>"localhost", "password"=>"postgres", "database"=>"mydb", "pool"=>5}
https://snipt.net/embed/1cc7c0a5f6940605863a6e551117f669/
https://snipt.net/raw/1cc7c0a5f6940605863a6e551117f669/
1cc7c0a5f6940605863a6e551117f669
rb
Ruby
4
2014-04-15T22:32:59
True
False
/api/public/snipt/28360/
get-current-environment-database-configuration
<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="no">Rails</span><span class="o">.</span><span class="n">configuration</span><span class="o">.</span><span class="n">database_configuration</span><span class="o">[</span><span class="no">Rails</span><span class="o">.</span><span class="n">env</span><span class="o">]</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="o">=&gt;</span> <span class="p">{</span><span class="s2">&quot;encoding&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;unicode&quot;</span><span class="p">,</span> <span class="s2">&quot;username&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;postgres&quot;</span><span class="p">,</span> <span class="s2">&quot;adapter&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;postgresql&quot;</span><span class="p">,</span> <span class="s2">&quot;port&quot;</span><span class="o">=&gt;</span><span class="mi">5432</span><span class="p">,</span> <span class="s2">&quot;host&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;localhost&quot;</span><span class="p">,</span> <span class="s2">&quot;password&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;postgres&quot;</span><span class="p">,</span> <span class="s2">&quot;database&quot;</span><span class="o">=&gt;</span><span class="s2">&quot;mydb&quot;</span><span class="p">,</span> <span class="s2">&quot;pool&quot;</span><span class="o">=&gt;</span><span class="mi">5</span><span class="p">}</span> </span></pre></div> </td></tr></table>
config, db, ruby
#28088

Bash

Set up a tracked remote branch in Git

git branch --track localBranchName origin/remoteBranchName
https://snipt.net/embed/76738e48604e27515ef03a1538761a81/
https://snipt.net/raw/76738e48604e27515ef03a1538761a81/
76738e48604e27515ef03a1538761a81
bash
Bash
1
2014-04-18T08:39:22
True
False
/api/public/snipt/28088/
set-up-a-tracked-remote-branch-in-git
<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>git branch --track localBranchName origin/remoteBranchName </span></pre></div> </td></tr></table>
branch, git, versioning
#28087

Bash

List all Git branches (local and remote)

git branch -a
https://snipt.net/embed/65636ff7a35976ad1d9263b861f20c57/
https://snipt.net/raw/65636ff7a35976ad1d9263b861f20c57/
65636ff7a35976ad1d9263b861f20c57
bash
Bash
1
2014-04-18T08:39:18
True
False
/api/public/snipt/28087/
list-all-git-branches-local-and-remote
<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>git branch -a </span></pre></div> </td></tr></table>
branch, git, versioning