snipt

Ctrl+h for KB shortcuts

Text only

Snippet - Simple Form

 - claim_reason_collection = ClaimReason.all.map { |cr| [cr.to_s, cr.id, { data: { ids: cr.accounting_ids } }] }
 = f.input :claim_reason_static_id, collection: claim_reason_collection
https://snipt.net/embed/c5a242b6c6258936864f4451911a78ef/
https://snipt.net/raw/c5a242b6c6258936864f4451911a78ef/
c5a242b6c6258936864f4451911a78ef
text
Text only
2
2016-09-21T10:34:55
True
False
False
/api/public/snipt/144778/
simple-form-409e7fa9
<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> - claim_reason_collection = ClaimReason.all.map { |cr| [cr.to_s, cr.id, { data: { ids: cr.accounting_ids } }] } </span><span id="L-2"><a name="L-2"></a> = f.input :claim_reason_static_id, collection: claim_reason_collection </span></pre></div> </td></tr></table>
haml, snippet

Text only

Convert RoR Project to HAML

haml --rails path/to/app
https://snipt.net/embed/37fee8be8070d6eb2d091b8228f00b33/
https://snipt.net/raw/37fee8be8070d6eb2d091b8228f00b33/
37fee8be8070d6eb2d091b8228f00b33
text
Text only
1
2016-09-24T00:42:29
True
False
False
/api/public/snipt/3370/
convert-ror-project-to-haml
<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>haml --rails path/to/app </span></pre></div> </td></tr></table>
haml

Ruby

Case Statement

1
2
3
4
5
- case parameter
  - when "this"
    do this
  - when "or_this"
    do this
https://snipt.net/embed/a0b3dbe47f948e0dc7f12d5f2d8bc830/
https://snipt.net/raw/a0b3dbe47f948e0dc7f12d5f2d8bc830/
a0b3dbe47f948e0dc7f12d5f2d8bc830
rb
Ruby
5
2016-09-23T17:05:22
True
False
False
/api/public/snipt/1846/
case-statement
<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 id="L-1"><a name="L-1"></a><span class="o">-</span> <span class="k">case</span> <span class="n">parameter</span> </span><span id="L-2"><a name="L-2"></a> <span class="o">-</span> <span class="k">when</span> <span class="s2">&quot;this&quot;</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">do</span> <span class="n">this</span> </span><span id="L-4"><a name="L-4"></a> <span class="o">-</span> <span class="k">when</span> <span class="s2">&quot;or_this&quot;</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">do</span> <span class="n">this</span> </span></pre></div> </td></tr></table>
haml, ruby

Text only

HTML2HAML

1
2
3
4
5
6
find . -name '*erb' | \
xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}'

find . -name '*erb' | \
xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}' | \
bash
https://snipt.net/embed/7ffab0cebf9c1705699b3e330818532c/
https://snipt.net/raw/7ffab0cebf9c1705699b3e330818532c/
7ffab0cebf9c1705699b3e330818532c
text
Text only
7
2016-09-21T20:44:34
True
False
False
/api/public/snipt/1361/
html2haml
<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>find . -name &#39;*erb&#39; | \ </span><span id="L-2"><a name="L-2"></a>xargs ruby -e &#39;ARGV.each { |i| puts &quot;html2haml -r #{i} #{i.sub(/erb$/,&quot;haml&quot;)}&quot;}&#39; </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>find . -name &#39;*erb&#39; | \ </span><span id="L-5"><a name="L-5"></a>xargs ruby -e &#39;ARGV.each { |i| puts &quot;html2haml -r #{i} #{i.sub(/erb$/,&quot;haml&quot;)}&quot;}&#39; | \ </span><span id="L-6"><a name="L-6"></a>bash </span></pre></div> </td></tr></table>
haml
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.