snipt

Ctrl+h for KB shortcuts

Ruby

delete whole riak instance

Ripple.client.buckets.each {|b| b.keys(reload: true).each {|k| b.delete(k); @count ||= 0 ; @count += 1}} ; p @count
https://snipt.net/embed/834266b42ccb85cdccb603418df0bf43/
/raw/834266b42ccb85cdccb603418df0bf43/
834266b42ccb85cdccb603418df0bf43
rb
Ruby
1
2019-07-09T22:04:37
True
False
False
/api/public/snipt/26590/
delete-whole-riak-instance
<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="no">Ripple</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">buckets</span><span class="o">.</span><span class="n">each</span> <span class="p">{</span><span class="o">|</span><span class="n">b</span><span class="o">|</span> <span class="n">b</span><span class="o">.</span><span class="n">keys</span><span class="p">(</span><span class="ss">reload</span><span class="p">:</span> <span class="kp">true</span><span class="p">)</span><span class="o">.</span><span class="n">each</span> <span class="p">{</span><span class="o">|</span><span class="n">k</span><span class="o">|</span> <span class="n">b</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">k</span><span class="p">);</span> <span class="vi">@count</span> <span class="o">||=</span> <span class="mi">0</span> <span class="p">;</span> <span class="vi">@count</span> <span class="o">+=</span> <span class="mi">1</span><span class="p">}}</span> <span class="p">;</span> <span class="nb">p</span> <span class="vi">@count</span> </span></pre></div> </td></tr></table>
riak, ruby

Ruby

Autovivification for hashes in Ruby

hash = Hash.new(&(p=lambda{|h,k| h[k] = Hash.new(&p)}))
https://snipt.net/embed/9f5d51f51a0270f5ab4be0792776242c/
/raw/9f5d51f51a0270f5ab4be0792776242c/
9f5d51f51a0270f5ab4be0792776242c
rb
Ruby
1
2019-07-09T22:09:20
True
False
False
/api/public/snipt/23230/
autovivification-for-hashes-in-ruby
<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">hash</span> <span class="o">=</span> <span class="no">Hash</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="o">&amp;</span><span class="p">(</span><span class="nb">p</span><span class="o">=</span><span class="nb">lambda</span><span class="p">{</span><span class="o">|</span><span class="n">h</span><span class="p">,</span><span class="n">k</span><span class="o">|</span> <span class="n">h</span><span class="o">[</span><span class="n">k</span><span class="o">]</span> <span class="o">=</span> <span class="no">Hash</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="o">&amp;</span><span class="nb">p</span><span class="p">)}))</span> </span></pre></div> </td></tr></table>
ruby

Bash

Find deleted stashes and other lost commits in git

git fsck --no-reflog | awk '/dangling commit/ {print $3}'
https://snipt.net/embed/a92ae3656170649338cbf1fa3faf7f80/
/raw/a92ae3656170649338cbf1fa3faf7f80/
a92ae3656170649338cbf1fa3faf7f80
bash
Bash
1
2019-07-10T16:37:26
True
False
False
/api/public/snipt/23012/
find-deleted-stashes-and-other-lost-commits-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></span><span id="L-1"><a name="L-1"></a>git fsck --no-reflog <span class="p">|</span> awk <span class="s1">&#39;/dangling commit/ {print $3}&#39;</span> </span></pre></div> </td></tr></table>
git

Bash

copy a mysql database

1
2
3
4
5
mysql -u root
create database new_database; 
^D

mysqldump -u root old_database | mysql -u root -D new_database
https://snipt.net/embed/fd6587344d53edd6e1c43aaf378d2cf4/
/raw/fd6587344d53edd6e1c43aaf378d2cf4/
fd6587344d53edd6e1c43aaf378d2cf4
bash
Bash
5
2019-07-08T07:33:25
True
False
False
/api/public/snipt/17198/
copy-a-mysql-database
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>mysql -u root </span><span id="L-2"><a name="L-2"></a>create database new_database<span class="p">;</span> </span><span id="L-3"><a name="L-3"></a>^D </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>mysqldump -u root old_database <span class="p">|</span> mysql -u root -D new_database </span></pre></div> </td></tr></table>
database, mysql

Bash

Kill an unresponsive ssh session

RET ~.
https://snipt.net/embed/107f31fdcedecba0ec5f6a29c47bcb2d/
/raw/107f31fdcedecba0ec5f6a29c47bcb2d/
107f31fdcedecba0ec5f6a29c47bcb2d
bash
Bash
1
2019-07-10T19:23:22
True
False
False
/api/public/snipt/14307/
kill-an-unresponsive-ssh-session
<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>RET ~. </span></pre></div> </td></tr></table>
shell, ssh

Bash

show sockets on OS X

lsof -iTCP -n -P
https://snipt.net/embed/013c90460edd2542ff782775478f446d/
/raw/013c90460edd2542ff782775478f446d/
013c90460edd2542ff782775478f446d
bash
Bash
1
2019-07-18T15:56:49
True
False
False
/api/public/snipt/12853/
show-sockets-on-os-x
<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>lsof -iTCP -n -P </span></pre></div> </td></tr></table>
connection, mac, osx

HTML

mail link containing various contents already

<a href="mailto:[email protected]?body=The message's first paragraph.%0A%0aSecond paragraph.%0A%0AThird Paragraph.">
https://snipt.net/embed/57d926f9263e63ea74cf933d1d484ba7/
/raw/57d926f9263e63ea74cf933d1d484ba7/
57d926f9263e63ea74cf933d1d484ba7
html
HTML
1
2019-07-17T11:55:05
True
False
False
/api/public/snipt/6289/
mail-link-containing-various-contents-already
<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="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;mailto:[email protected]?body=The message&#39;s first paragraph.%0A%0aSecond paragraph.%0A%0AThird Paragraph.&quot;</span><span class="p">&gt;</span> </span></pre></div> </td></tr></table>
html, link, mailto, web

Bash

forward CouchDB Futon to local port

ssh -L 5985:127.0.0.1:5984 couchhost.com
https://snipt.net/embed/2fbf95f5b6b5e19828ff50220c851fe7/
/raw/2fbf95f5b6b5e19828ff50220c851fe7/
2fbf95f5b6b5e19828ff50220c851fe7
bash
Bash
1
2019-07-22T17:36:13
True
False
False
/api/public/snipt/3949/
forward-couchdb-futon-to-local-port
<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>ssh -L 5985:127.0.0.1:5984 couchhost.com </span></pre></div> </td></tr></table>
couchdb, futon, server, ssh

Bash

edit commit log for svn

cd path/to/commit/path
svn propedit --revprop -r45119 svn:log
https://snipt.net/embed/c36ff75909c9e29248c127ed24246472/
/raw/c36ff75909c9e29248c127ed24246472/
c36ff75909c9e29248c127ed24246472
bash
Bash
2
2019-07-22T14:33:04
True
False
False
/api/public/snipt/1579/
edit-commit-log-for-svn
<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> path/to/commit/path </span><span id="L-2"><a name="L-2"></a>svn propedit --revprop -r45119 svn:log </span></pre></div> </td></tr></table>
scm, svn