snipt

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

Text only

Mobile App Development, iPhone Application Development Company AgileInfoways.com

1
2
3
4
5
Agile Infoways is a leading mobile app development company with over 600 apps built on iPhone, iPad and Android. Get free mobile app development quotes by http://www.agileinfoways.com/contact-us 

Our mobile application development services help businesses to mobilize their ... With a yearly rise in demand for Iphone apps, our developers and designers.

Find the feasible solutions for your business needs from a quality iPhone application development company who handle small to large projects.
https://snipt.net/embed/503bf95dc6b3e2d30771709de3c995e2/
https://snipt.net/raw/503bf95dc6b3e2d30771709de3c995e2/
503bf95dc6b3e2d30771709de3c995e2
text
Text only
5
2014-04-24T19:31:44
True
True
Apr 23, 2014 at 03:11 AM
/api/public/snipt/132125/
mobile-app-development-iphone-application-development-company-agileinfowayscom
<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>Agile Infoways is a leading mobile app development company with over 600 apps built on iPhone, iPad and Android. Get free mobile app development quotes by http://www.agileinfoways.com/contact-us </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>Our mobile application development services help businesses to mobilize their ... With a yearly rise in demand for Iphone apps, our developers and designers. </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>Find the feasible solutions for your business needs from a quality iPhone application development company who handle small to large projects. </span></pre></div> </td></tr></table>
"hire wordpress", agileinfoways.com, as3, bash, c++, css, django, drupal, git, html, java, javascript, jquery, js, linux, mysql, php, python, ruby, sql, wordpress
#66098

Ruby

rails > override as_json in model

1
2
3
4
def as_json(options = {})
  super(options.merge(include: :authors,
           except: [:password_digest]))
end
https://snipt.net/embed/b8877bff1091216699f8c1dbb0a6cf46/
https://snipt.net/raw/b8877bff1091216699f8c1dbb0a6cf46/
b8877bff1091216699f8c1dbb0a6cf46
rb
Ruby
6
2014-04-24T06:40:24
True
False
Jun 30, 2013 at 02:54 PM
/api/public/snipt/66098/
rails-override-as_json-in-model
<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="k">def</span> <span class="nf">as_json</span><span class="p">(</span><span class="n">options</span> <span class="o">=</span> <span class="p">{})</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">super</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="kp">include</span><span class="p">:</span> <span class="ss">:authors</span><span class="p">,</span> </span><span id="L-3"><a name="L-3"></a> <span class="ss">except</span><span class="p">:</span> <span class="o">[</span><span class="ss">:password_digest</span><span class="o">]</span><span class="p">))</span> </span><span id="L-4"><a name="L-4"></a><span class="k">end</span> </span></pre></div> </td></tr></table>
rails, ruby
#59485

Ruby

rails rename column

1
2
3
4
5
6
7
# $ rails g migration RenameOldColumnToNewColumn

class FixColumnName < ActiveRecord::Migration
  def change
    rename_column :table_name, :old_column, :new_column
  end
end
https://snipt.net/embed/59feee716999ce05bbdafcc5de5cb6f0/
https://snipt.net/raw/59feee716999ce05bbdafcc5de5cb6f0/
59feee716999ce05bbdafcc5de5cb6f0
rb
Ruby
7
2014-04-15T00:54:56
True
False
Apr 18, 2013 at 02:44 AM
/api/public/snipt/59485/
rails-rename-column
<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="c1"># $ rails g migration RenameOldColumnToNewColumn</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="k">class</span> <span class="nc">FixColumnName</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Migration</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">def</span> <span class="nf">change</span> </span><span id="L-5"><a name="L-5"></a> <span class="n">rename_column</span> <span class="ss">:table_name</span><span class="p">,</span> <span class="ss">:old_column</span><span class="p">,</span> <span class="ss">:new_column</span> </span><span id="L-6"><a name="L-6"></a> <span class="k">end</span> </span><span id="L-7"><a name="L-7"></a><span class="k">end</span> </span></pre></div> </td></tr></table>
database, migrate, rails, ruby
#59484

Bash

rails add column to table

$ rails generate migration AddEmailColumnToUsers email:string
https://snipt.net/embed/486ebd44a665eb3ca87e8157e4987864/
https://snipt.net/raw/486ebd44a665eb3ca87e8157e4987864/
486ebd44a665eb3ca87e8157e4987864
bash
Bash
1
2014-04-24T04:05:43
True
False
Apr 18, 2013 at 02:40 AM
/api/public/snipt/59484/
rails-add-column-to-table
<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>rails generate migration AddEmailColumnToUsers email:string </span></pre></div> </td></tr></table>
bash, database, postgresql, rails, ruby, sqlite
#59472

Bash

osx start redis server

$ redis-server /usr/local/etc/redis.conf
https://snipt.net/embed/5a8283aaea67da224543853b67542f46/
https://snipt.net/raw/5a8283aaea67da224543853b67542f46/
5a8283aaea67da224543853b67542f46
bash
Bash
1
2014-04-24T15:53:43
True
False
/api/public/snipt/59472/
osx-start-redis-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><span class="nv">$ </span>redis-server /usr/local/etc/redis.conf </span></pre></div> </td></tr></table>
database, rails, redis, ruby
#59111

Ruby

ruby > sqlite > escape string for insert

# this converts single ' quotes to double '' which sqlite treats as single o__O
mystring.gsub(/\\/, '\&\&').gsub(/'/, "''")
https://snipt.net/embed/b98d4881a5ebe77e80d50bea7b91a262/
https://snipt.net/raw/b98d4881a5ebe77e80d50bea7b91a262/
b98d4881a5ebe77e80d50bea7b91a262
rb
Ruby
3
2014-04-23T11:30:31
True
False
Apr 11, 2013 at 01:00 AM
/api/public/snipt/59111/
ruby-sqlite-escape-string-for-insert
<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><span class="c1"># this converts single &#39; quotes to double &#39;&#39; which sqlite treats as single o__O</span> </span><span id="L-2"><a name="L-2"></a><span class="n">mystring</span><span class="o">.</span><span class="n">gsub</span><span class="p">(</span><span class="sr">/\\/</span><span class="p">,</span> <span class="s1">&#39;\&amp;\&amp;&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">gsub</span><span class="p">(</span><span class="sr">/&#39;/</span><span class="p">,</span> <span class="s2">&quot;&#39;&#39;&quot;</span><span class="p">)</span> </span></pre></div> </td></tr></table>
ruby, sqlite, sqlite3