tag:blogger.com,1999:blog-45593300326908402782024-02-07T10:36:12.917-08:00Ruby on Rails mini-blogsPAGE NO LONGER MAINTAINED, all articles were moved to <a href="http://www.eq8.eu/tils">http://www.eq8.eu/tils</a> where I'll continue adding more !
This page contains simple small Ruby on Rails and web-development hints that are too small for a real blog. You can visit my real blog at <a href="http://www.eq8.eu/blogs">http://www.eq8.eu</a>Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-4559330032690840278.post-63218853728571107482016-03-02T04:13:00.002-08:002016-03-02T04:13:14.261-08:00Removing old release branches<span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 20.48px;">After some time release branches piles up and we may want to clean up our Github from old</span><span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 20.48px;"> </span><code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; line-height: 20.48px; margin: 0px; padding: 0.2em 0px;">live-*</code><span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 20.48px;"> </span><span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 20.48px;">branches</span><br />
<span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 20.48px;"><br /></span>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 20.48px; margin-bottom: 16px;">
Given we name our release branches <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0px;">live-20150821</code> (<code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0px;">live-yearmmdd</code>) here is an example how to remove all live branches from previous year (Given it's 2016)</div>
<ul style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 20.48px; margin-bottom: 16px; margin-top: 0px; padding: 0px 0px 0px 2em;">
<li style="box-sizing: border-box;">cd to the repo of your project you want to cleanup</li>
<li style="box-sizing: border-box;">create the <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0px;">cleanup.rb</code> with content bellow</li>
<li style="box-sizing: border-box;">lunch <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0px;">ruby cleanup.rb</code></li>
</ul>
<div class="highlight highlight-source-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; line-height: 20.48px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: #969896;"># cleanup.rb</span>
old_live_branches <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">=</span> <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">`</span>git fetch origin && git branch -r | grep live-2015<span class="pl-pds" style="box-sizing: border-box;">`</span></span> <span class="pl-c" style="box-sizing: border-box; color: #969896;"># all branches `live-2015*`</span>
old_live_branches
.split(<span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">"</span><span class="pl-cce" style="box-sizing: border-box;">\n</span><span class="pl-pds" style="box-sizing: border-box;">"</span></span>)
.map(<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">&</span><span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">:strip</span>)
.map { |<span class="pl-smi" style="box-sizing: border-box;">i</span>| i.gsub(<span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">"</span>/<span class="pl-pds" style="box-sizing: border-box;">"</span></span>, <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span> :<span class="pl-pds" style="box-sizing: border-box;">'</span></span>) }
.each <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">do </span>|<span class="pl-smi" style="box-sizing: border-box;">destroy</span>|
<span class="pl-c" style="box-sizing: border-box; color: #969896;"># e.g.: git push origin :live-20151129</span>
puts <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">`</span>git push <span class="pl-pse" style="box-sizing: border-box;">#{</span><span class="pl-s1" style="box-sizing: border-box; color: #333333;">destroy</span><span class="pl-pse" style="box-sizing: border-box;"><span class="pl-s1" style="box-sizing: border-box;">}</span></span><span class="pl-pds" style="box-sizing: border-box;">`</span></span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span></pre>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2016-03-02-removing-old-remote-branches-in-bulk.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2016-03-02-removing-old-remote-branches-in-bulk.md</a></div>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-91492750051680383952015-10-15T09:47:00.005-07:002015-10-15T09:47:46.879-07:00solving Ubuntu 14.04 Ruby C dependancy <div style="-webkit-text-stroke-width: 0px; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25.6px; margin-bottom: 16px; margin-top: 0px !important; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
Given you are running Ubuntu 14.04 and you are installing/upgrading some Ruby gems (let sey Rails 4.2.4 gem, or RSpec, ...) and you get this error:</div>
<pre style="-webkit-text-stroke-width: 0px; background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.45; margin-bottom: 16px; margin-top: 0px; orphans: auto; overflow: auto; padding: 16px; text-align: start; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; line-height: inherit; margin: 0px; max-width: initial; overflow: initial; padding: 0px; white-space: pre; word-break: normal; word-wrap: normal;">Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/home/tomi/.rvm/rubies/ruby-2.2.3/bin/ruby -r ./siteconf20151015-21730-1qh2hm1.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.so
/usr/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
make: *** [generator.so] Error 1
make failed, exit code 2
Gem files will remain installed in /home/tomi/.rvm/gems/ruby-2.2.3@maze_magic/gems/json-1.8.3 for inspection.
Results logged to /home/tomi/.rvm/gems/ruby-2.2.3@maze_magic/extensions/x86_64-linux/2.2.0/json-1.8.3/gem_make.out
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.
</code></pre>
<div style="-webkit-text-stroke-width: 0px; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25.6px; margin-bottom: 16px; margin-top: 0px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
run:</div>
<pre style="-webkit-text-stroke-width: 0px; background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.45; margin-bottom: 16px; margin-top: 0px; orphans: auto; overflow: auto; padding: 16px; text-align: start; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; line-height: inherit; margin: 0px; max-width: initial; overflow: initial; padding: 0px; white-space: pre; word-break: normal; word-wrap: normal;">sudo apt-get install libgmp-dev
</code></pre>
<div style="-webkit-text-stroke-width: 0px; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25.6px; margin-bottom: 16px; margin-top: 0px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
or</div>
<pre style="-webkit-text-stroke-width: 0px; background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.45; margin-bottom: 16px; margin-top: 0px; orphans: auto; overflow: auto; padding: 16px; text-align: start; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; line-height: inherit; margin: 0px; max-width: initial; overflow: initial; padding: 0px; white-space: pre; word-break: normal; word-wrap: normal;">sudo apt-get install libgmp3-dev
</code></pre>
<div style="-webkit-text-stroke-width: 0px; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25.6px; margin-bottom: 16px; margin-top: 0px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
should solve the problem.</div>
<ul style="-webkit-text-stroke-width: 0px; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25.6px; margin-bottom: 0px !important; margin-top: 0px; orphans: auto; padding: 0px 0px 0px 2em; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
<li style="box-sizing: border-box;"><a href="http://stackoverflow.com/questions/29317640/gem-install-rails-fails-on-ubuntu/32965803#32965803" style="background-color: transparent; box-sizing: border-box; color: #4078c0; text-decoration: none;">http://stackoverflow.com/questions/29317640/gem-install-rails-fails-on-ubuntu/32965803#32965803</a></li>
<li style="box-sizing: border-box;"> <a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-10-01-ubuntu-14-04-ruby-rails-c-dependancy-solution.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-10-01-ubuntu-14-04-ruby-rails-c-dependancy-solution.md</a></li>
</ul>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-37496831188732346432015-08-24T04:45:00.001-07:002015-08-24T04:45:12.451-07:00Rails log - display partials log only<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
...or: show me only the log of what is being rendered.</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
Let say your Rails log is doing to much and you just want to see which partials or layouts are beeing rendered.</div>
<div class="highlight highlight-bash" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">cd</span> <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">~</span>/my-rails-application
tail -f log/development.log <span class="pl-c" style="box-sizing: border-box; color: #969896;"># entire log as it is</span>
tail -f log/development.log <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">|</span> grep -e <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>Render<span class="pl-pds" style="box-sizing: border-box;">'</span></span> <span class="pl-c" style="box-sizing: border-box; color: #969896;"># just what is rendered</span>
<span class="pl-c" style="box-sizing: border-box; color: #969896;"># partials / layouts</span></pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
This can be anything you want</div>
<div class="highlight highlight-bash" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;">tail -f log/development.log <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">|</span> grep -e <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>anything<span class="pl-pds" style="box-sizing: border-box;">'</span></span></pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<br /></div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
mirror:</div>
<div style="box-sizing: border-box; margin-bottom: 16px;">
</div>
<ul>
<li><span style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; line-height: 25.6000003814697px;">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-08-24-rails-log-only-partials.md</span></li>
</ul>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-49318993640956961612015-07-22T01:33:00.001-07:002015-07-22T01:33:54.213-07:00how to include Capybara RSpec matchers in RSpec<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
let say you want to use <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; margin: 0px; padding: 0.2em 0px;">have_content</code> and <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; margin: 0px; padding: 0.2em 0px;">have_selector</code> in non rails-helper spec</div>
<div class="highlight highlight-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: #969896;"># Gemfile</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">gem</span> <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>capybara<span class="pl-pds" style="box-sizing: border-box;">'</span></span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">gem</span> <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>rspec<span class="pl-pds" style="box-sizing: border-box;">'</span></span></pre>
</div>
<div class="highlight highlight-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: #969896;"># spec/spec_helper.rb</span>
<span class="pl-c" style="box-sizing: border-box; color: #969896;">#...</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">require</span> <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>capybara/rspec<span class="pl-pds" style="box-sizing: border-box;">'</span></span>
<span class="pl-c" style="box-sizing: border-box; color: #969896;">#...</span></pre>
</div>
<div class="highlight highlight-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">require</span> <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>spec_helper<span class="pl-pds" style="box-sizing: border-box;">'</span></span>
<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">RSpec</span>.describe <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">MyPresenter</span> <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">do</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">include</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">Capybara</span>::<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">RSpecMatchers</span>
it <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">do </span>
expect(<span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">"</span><b>abc</b><span class="pl-pds" style="box-sizing: border-box;">"</span></span>).to have_selector(<span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">"</span>b<span class="pl-pds" style="box-sizing: border-box;">"</span></span>)
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span></pre>
</div>
raw: <a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-07-22-capybara-matchers-in-rspec.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-07-22-capybara-matchers-in-rspec.md</a>Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-39795202439295202032015-06-17T07:20:00.004-07:002015-06-17T07:20:39.907-07:00Rails mysql gem (>= 2.9.0) throwing errorchecking for mysql_query() in -lmysqlclient... no<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
My settup:</div>
<ul style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px; margin-top: 0px; padding: 0px 0px 0px 2em;">
<li style="box-sizing: border-box;">Ubuntu 14.04</li>
<li style="box-sizing: border-box;">Rails 4.2.x</li>
<li style="box-sizing: border-box;">Ruby 2.2.0</li>
</ul>
<h3 style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 1.5em; line-height: 1.43; margin-bottom: 16px; margin-top: 1em; position: relative;">
<a aria-hidden="true" class="anchor" href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-06-17-error-hint-mysql-gem.md#error" id="user-content-error" style="box-sizing: border-box; color: #4078c0; display: block; left: 0px; line-height: 1.2; margin-left: -30px; padding-left: 30px; padding-right: 6px; position: absolute; text-decoration: none; top: 0px;"></a>Error:</h3>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; line-height: inherit; margin: 0px; max-width: initial; overflow: initial; padding: 0px; word-break: normal; word-wrap: normal;">Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/home/tomi/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20150617-4359-1xygr4t.rb extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/tomi/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
extconf failed, exit code 1
Gem files will remain installed in /home/tomi/.rvm/gems/ruby-2.2.0@rails-framework-4.2/gems/mysql-2.9.1 for inspection.
Results logged to /home/tomi/.rvm/gems/ruby-2.2.0@rails-framework-4.2/extensions/x86_64-linux/2.2.0/mysql-2.9.1/gem_make.out
</code></pre>
<h3 style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 1.5em; line-height: 1.43; margin-bottom: 16px; margin-top: 1em; position: relative;">
<a aria-hidden="true" class="anchor" href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-06-17-error-hint-mysql-gem.md#solution" id="user-content-solution" style="box-sizing: border-box; color: #4078c0; display: block; left: 0px; line-height: 1.2; margin-left: -30px; padding-left: 30px; padding-right: 6px; position: absolute; text-decoration: none; top: 0px;"></a>solution:</h3>
<div class="highlight highlight-bash" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;">sudo apt-get install libmysqlclient-dev</pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
if not try</div>
<div class="highlight highlight-bash" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"> sudo apt-get install mysql-server</pre>
</div>
<div>
<br /></div>
<div>
Mirror:<a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-06-17-error-hint-mysql-gem.md"> https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-06-17-error-hint-mysql-gem.md</a></div>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-74920590128967490872015-04-23T15:21:00.003-07:002015-04-23T15:21:57.888-07:00Use Rails (ActiveSupport) delegation class in plain ruby<div class="highlight highlight-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 28.4444465637207px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: #969896;"># Gemfile</span>
source <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">"</span>https://rubygems.org<span class="pl-pds" style="box-sizing: border-box;">"</span></span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">gem</span> <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>active_support<span class="pl-pds" style="box-sizing: border-box;">'</span></span></pre>
</div>
<div class="highlight highlight-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 28.4444465637207px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">require</span> <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>active_support/core_ext/module/delegation<span class="pl-pds" style="box-sizing: border-box;">'</span></span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">class</span> <span class="pl-en" style="box-sizing: border-box; color: #795da3;">Foo</span>
delegate <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">:call</span>, <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">to:</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">:other</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">def</span> <span class="pl-en" style="box-sizing: border-box; color: #795da3;">other</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">-</span><span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">></span>(){ <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>foo<span class="pl-pds" style="box-sizing: border-box;">'</span></span> }
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">Foo</span>.<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">new</span>.call
<span class="pl-c" style="box-sizing: border-box; color: #969896;"># => 'foo'</span></pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 28.4444465637207px;">
source: <a href="http://guides.rubyonrails.org/active_support_core_extensions.html#method-delegation%60" style="box-sizing: border-box; color: #4183c4; text-decoration: none;">http://guides.rubyonrails.org/active_support_core_extensions.html#method-delegation`</a></div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 28.4444465637207px;">
github: <a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-04-23-use-rails-delegate-lib-only.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-04-23-use-rails-delegate-lib-only.md</a></div>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-6993195619018608542015-03-31T06:30:00.002-07:002015-03-31T06:34:00.054-07:00Run multiple instances of RSpec on same machine<h1 style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 2.25em; line-height: 1.2; margin-bottom: 16px; margin-left: 0px; margin-right: 0px; margin-top: 0px !important; padding-bottom: 0.3em; position: relative;">
</h1>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
Sime times you are stuck with realy badly written Rails project (or other application which comunicates with Database) which entire test suite takes ages to run. You want to run all the tests but you while they running you want to continue your TDD work.</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
If you run RSpec multiple times (multiple instances at a same time) you may break one of test suits because you will write data to same database both RSpec instances are comunicating with.</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
One way to handle this is if you run rspecs on different databases</div>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; line-height: inherit; margin: 0px; max-width: initial; overflow: initial; padding: 0px; word-break: normal; word-wrap: normal;"># config/database.yml
default: &default
adapter: mysql2
encoding: utf8
reconnect: false
pool: 5
username: root
password: my_development_password
socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: myapp_development
test:
<<: *default
database: myapp_test<%= ENV['TEST_ENV_NUMBER'] %>
</code></pre>
<div class="highlight highlight-sh" style="box-sizing: border-box; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"> RAILS_ENV=<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">test</span> TEST_ENV_NUMBER=2 rake db:create
RAILS_ENV=<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">test</span> TEST_ENV_NUMBER=2 rake db:migrate
TEST_ENV_NUMBER=2 rspec spec/</pre>
<pre style="border-radius: 3px; box-sizing: border-box; font-stretch: normal; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span style="color: #333333; font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"> If you are looking for solution how to run same test suite on multiple databases check https://github.com/grosser/parallel_tests</span></pre>
<pre style="border-radius: 3px; box-sizing: border-box; font-stretch: normal; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span style="color: #333333; font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;">
</span></pre>
<pre style="border-radius: 3px; box-sizing: border-box; font-stretch: normal; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span style="color: #333333; font-family: Consolas, Liberation Mono, Menlo, Courier, monospace;"><span style="background-color: white; font-size: 13.6000003814697px; line-height: 19.7199993133545px;"><a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-03-30-run-multiple-times-rspec-on-same-machine.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-03-30-run-multiple-times-rspec-on-same-machine.md</a></span></span></pre>
</div>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-26851257816134904532015-03-31T05:02:00.002-07:002015-03-31T05:03:26.065-07:00Override Rails default rake task<br />
<div class="highlight highlight-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;">desc <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">"</span>this will be now a default task<span class="pl-pds" style="box-sizing: border-box;">"</span></span>
task <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">info:</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">:environment</span> <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">do</span>
puts <span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>Run rake test to test<span class="pl-pds" style="box-sizing: border-box;">'</span></span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
task(<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">:default</span>).clear.enhance([<span class="pl-s" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span>info<span class="pl-pds" style="box-sizing: border-box;">'])</span></span></pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
source</div>
<ul class="task-list" style="box-sizing: border-box; margin-bottom: 0px !important; margin-top: 0px; padding: 0px 0px 0px 2em;">
<li style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px;"><a href="http://stackoverflow.com/questions/8112074/overriding-rails-default-rake-tasks" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">http://stackoverflow.com/questions/8112074/overriding-rails-default-rake-tasks</a></li>
<li style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px;"><a href="http://blog.codingspree.net/2012/04/26/overwriting_rake_spec_task.html" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">http://blog.codingspree.net/2012/04/26/overwriting_rake_spec_task.html</a></li>
<li style="box-sizing: border-box;"><span style="color: #333333; font-family: Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif;"><span style="line-height: 25.6000003814697px;"><a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-03-30-override-default-rake-task-of-rails.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-03-30-override-default-rake-task-of-rails.md</a></span></span></li>
</ul>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-28542520535504670212015-03-03T07:14:00.003-08:002015-03-03T08:14:45.907-08:00Carrierwave uploader not triggering proces in RSpec<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
processing is turn off for sake of test speed</div>
<div class="highlight highlight-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: #969896;"># spec/my_test.spec</span>
before <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">do</span>
<span class="pl-s3" style="box-sizing: border-box; color: #0086b3;">DocumentUploader</span>.enable_processing <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">=</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">true</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span></pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
It's probably because you have something like</div>
<div class="highlight highlight-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: #969896;"># config/initializers/carrierwave.rb</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">if</span> <span class="pl-s3" style="box-sizing: border-box; color: #0086b3;">Rails</span>.env.test?
<span class="pl-s3" style="box-sizing: border-box; color: #0086b3;">CarrierWave</span>.configure <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">do </span>|<span class="pl-vo" style="box-sizing: border-box;">config</span>|
config.storage <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">=</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">:file</span>
config.enable_processing <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">=</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">false</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">else</span>
<span class="pl-s3" style="box-sizing: border-box; color: #0086b3;">CarrierWave</span>.configure <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">do </span>|<span class="pl-vo" style="box-sizing: border-box;">config</span>|
config.storage <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">=</span> <span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">:fog</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span></pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px;">
I recommend to keep the <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin: 0px; padding: 0.2em 0px;">enable_processing = false</code> and just overide it when needed</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px;">
<br /></div>
<div style="box-sizing: border-box;">
<span style="color: #333333; font-family: Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif;"><span style="line-height: 25.6000003814697px;"><a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-03-03-carrierwave-uploader-not-processing-in-rspec.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-03-03-carrierwave-uploader-not-processing-in-rspec.md</a></span></span></div>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-11122678367627854232015-02-26T09:54:00.005-08:002015-02-26T09:54:57.904-08:00Troubles with reqexp encoding in Ruby<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
Today friend of my shown me problem that he encounter while he was working on his <a href="https://github.com/tom-lord/regexp-examples" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">regexp-examples gem</a></div>
<div class="highlight highlight-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-s1" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span><<span class="pl-pds" style="box-sizing: border-box;">'</span></span> <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">=~</span> <span class="pl-sr" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">/</span><span class="pl-src" style="box-sizing: border-box;">[[:punct:]</span>]<span class="pl-pds" style="box-sizing: border-box;">/</span></span>
<span class="pl-c" style="box-sizing: border-box; color: #969896;"># => nil</span>
<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">60</span>.chr <span class="pl-c" style="box-sizing: border-box; color: #969896;"># => '>'</span>
<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">60</span>.chr <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">=~</span> <span class="pl-sr" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">/</span><span class="pl-src" style="box-sizing: border-box;">[[:punct:]</span>]<span class="pl-pds" style="box-sizing: border-box;">/</span></span>
<span class="pl-c" style="box-sizing: border-box; color: #969896;"># => 0</span>
<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">60</span>.chr <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">==</span> <span class="pl-s1" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span><<span class="pl-pds" style="box-sizing: border-box;">'</span></span>
<span class="pl-c" style="box-sizing: border-box; color: #969896;"># => true</span>
<span class="pl-c1" style="box-sizing: border-box; color: #0086b3;">60</span>.chr <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">===</span> <span class="pl-s1" style="box-sizing: border-box; color: #183691;"><span class="pl-pds" style="box-sizing: border-box;">'</span><<span class="pl-pds" style="box-sizing: border-box;">'</span></span>
<span class="pl-c" style="box-sizing: border-box; color: #969896;"># => true</span></pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
It took him a while to figure out what was the problem</div>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;">'<'.encoding
# => #<Encoding:UTF-8>
60.chr.encoding
# => #<Encoding:US-ASCII>
</code></pre>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
solution :</div>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;">60.chr.encode('UTF-8') =~ /[[:punct:]]/
# => nil</code></pre>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-02-27-troubles-with-encoding.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-02-27-troubles-with-encoding.md</a></div>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-57208060122713544322015-01-28T09:32:00.003-08:002015-09-21T08:02:25.607-07:00Free up space on your Linux Ubuntu server<div class="blob instapaper_body" id="readme" style="background-color: white; box-sizing: border-box;">
<br />
<article class="markdown-body entry-content" itemprop="mainContentOfPage" style="border-radius: 0px; border: 0px; box-sizing: border-box; overflow: hidden; padding: 30px; word-wrap: break-word;"><div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
You can check your disk space usage with <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin: 0px; padding: 0.2em 0px;">df</code>, or particular folder <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin: 0px; padding: 0.2em 0px;">df -sh</code>.</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
You can check inode space usage by <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin: 0px; padding: 0.2em 0px;">df -i</code> (if you running caching server with file storage this will be often an issue)</div>
<h3 style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 1.5em; line-height: 1.43; margin-bottom: 16px; margin-top: 1em; position: relative;">
<a aria-hidden="true" class="anchor" href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-01-28-free-up-space-on-your-linux-server.md#delete-downloaded-packages-deb" id="user-content-delete-downloaded-packages-deb" style="background: transparent; box-sizing: border-box; color: #4183c4; display: block; left: 0px; line-height: 1.2; margin-left: -30px; padding-left: 30px; padding-right: 6px; position: absolute; text-decoration: none; top: 0px;"></a>Delete downloaded packages (.deb)</h3>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
E.g.: already installed (and no longer needed)</div>
<div class="highlight highlight-sh" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;">sudo apt-get clean</pre>
</div>
<h3 style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 1.5em; line-height: 1.43; margin-bottom: 16px; margin-top: 1em; position: relative;">
<a aria-hidden="true" class="anchor" href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-01-28-free-up-space-on-your-linux-server.md#remove-stored-archives-in-your-cache" id="user-content-remove-stored-archives-in-your-cache" style="background: transparent; box-sizing: border-box; color: #4183c4; display: block; left: 0px; line-height: 1.2; margin-left: -30px; padding-left: 30px; padding-right: 6px; position: absolute; text-decoration: none; top: 0px;"></a>Remove stored archives in your cache</h3>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
E.g.: packages that can not be downloaded anymore, packages are no longer in the repository or that have a newer version in the repository</div>
<div class="highlight highlight-sh" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;">sudo apt-get autoclean</pre>
</div>
<h3 style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 1.5em; line-height: 1.43; margin-bottom: 16px; margin-top: 1em; position: relative;">
<a aria-hidden="true" class="anchor" href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-01-28-free-up-space-on-your-linux-server.md#remove-packages-after-uninstalling-an-application" id="user-content-remove-packages-after-uninstalling-an-application" style="background: transparent; box-sizing: border-box; color: #4183c4; display: block; left: 0px; line-height: 1.2; margin-left: -30px; padding-left: 30px; padding-right: 6px; position: absolute; text-decoration: none; top: 0px;"></a>Remove packages after uninstalling an application</h3>
<div class="highlight highlight-sh" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;">sudo apt-get autoremove</pre>
</div>
<h3 style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 1.5em; line-height: 1.43; margin-bottom: 16px; margin-top: 1em; position: relative;">
<a aria-hidden="true" class="anchor" href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-01-28-free-up-space-on-your-linux-server.md#remove-old-unused-kernels" id="user-content-remove-old-unused-kernels" style="background: transparent; box-sizing: border-box; color: #4183c4; display: block; left: 0px; line-height: 1.2; margin-left: -30px; padding-left: 30px; padding-right: 6px; position: absolute; text-decoration: none; top: 0px;"></a>Remove old unused kernels</h3>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
list all your kernels (installed and deinstalled) :</div>
<div class="highlight highlight-sh" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;">dpkg --get-selections <span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">|</span> grep linux-image</pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<div style="box-sizing: border-box; line-height: 25.6000003814697px; margin-bottom: 16px;">
your currently used kernel</div>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; line-height: inherit; margin: 0px; max-width: initial; overflow: initial; padding: 0px; word-break: normal; word-wrap: normal;">uname -r</code></pre>
to remove particular kernel:</div>
<div class="highlight highlight-sh" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;">sudo apt-get remove --purge linux-image-X.X.XX-XX-generic</pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
You can also run this script that will remove all unecesarry kernels, Be really carefull with this !!</div>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;">#!/bin/sh
dpkg -l linux-* | \
awk '/^ii/{ print $2}' | \
grep -v -e `uname -r | cut -f1,2 -d"-"` | \
grep -e '[0-9]' | xargs sudo apt-get -y purge
</code></pre>
<ul class="task-list" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px; margin-top: 0px; padding: 0px 0px 0px 2em;">
<li style="box-sizing: border-box;"><code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin: 0px; padding: 0.2em 0px;">dpkg -l linux-*</code> list all kernels</li>
<li style="box-sizing: border-box;"><code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; margin: 0px; padding: 0.2em 0px;">uname -r</code> will tell you current kernel</li>
</ul>
<div>
<span style="color: #333333; font-family: Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif;"><span style="line-height: 25.6000003814697px;"><br /></span></span></div>
<div>
<h1 style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 2.25em; line-height: 1.2; margin: 1em 0px 16px; padding-bottom: 0.3em; position: relative;">
when stuff goes wrong</h1>
<h2 style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 1.75em; line-height: 1.225; margin-bottom: 16px; margin-top: 1em; padding-bottom: 0.3em; position: relative;">
<a aria-hidden="true" class="anchor" href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-01-28-free-up-space-on-your-linux-server.md#clean-up-boot-partition" id="user-content-clean-up-boot-partition" style="background-color: transparent; box-sizing: border-box; color: #4078c0; display: block; left: 0px; line-height: 1; margin-left: -30px; padding-left: 30px; padding-right: 6px; position: absolute; text-decoration: none; top: 0px;"></a>clean up /boot partition</h2>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
when you install kernel and you get error similar to this one:</div>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; line-height: inherit; margin: 0px; max-width: initial; overflow: initial; padding: 0px; word-break: normal; word-wrap: normal;">update-initramfs: Generating /boot/initrd.img-3.13.0-62-generic
gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.13.0-62-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return
code 1
dpkg: error processing package linux-image-extra-3.13.0-62-generic
(--configure):
subprocess installed post-installation script returned error exit
status 1
No apport report written because MaxReports has already been reached
Processing
triggers for initramfs-tools (0.103ubuntu4.2) ...
update-initramfs: Generating /boot/initrd.img-3.13.0-62-generic
gzip: stdout: No space left on device
</code></pre>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
it may be you run out of space on boot partition</div>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; line-height: inherit; margin: 0px; max-width: initial; overflow: initial; padding: 0px; word-break: normal; word-wrap: normal;">df /boot # 100%
ls /boot
</code></pre>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; line-height: inherit; margin: 0px; max-width: initial; overflow: initial; padding: 0px; word-break: normal; word-wrap: normal;">-rw-r--r-- 1 root root 1169023 May 26 20:18 abi-3.13.0-54-generic
-rw-r--r-- 1 root root 1169023 Jun 18 01:14 abi-3.13.0-55-generic
-rw-r--r-- 1 root root 1169201 Jun 19 10:30 abi-3.13.0-57-generic
-rw-r--r-- 1 root root 1169346 Jul 8 04:00 abi-3.13.0-58-generic
-rw-r--r-- 1 root root 1169346 Jul 24 23:11 abi-3.13.0-59-generic
-rw-r--r-- 1 root root 1169346 Jul 29 12:40 abi-3.13.0-61-generic
-rw-r--r-- 1 root root 1169478 Aug 11 15:51 abi-3.13.0-62-generic
-rw-r--r-- 1 root root 1169421 Aug 14 22:58 abi-3.13.0-63-generic
-rw-r--r-- 1 root root 169832 May 26 20:18 config-3.13.0-54-generic
-rw-r--r-- 1 root root 169832 Jun 18 01:14 config-3.13.0-55-generic
-rw-r--r-- 1 root root 169832 Jun 19 10:30 config-3.13.0-57-generic
-rw-r--r-- 1 root root 169832 Jul 8 04:00 config-3.13.0-58-generic
-rw-r--r-- 1 root root 169832 Jul 24 23:11 config-3.13.0-59-generic
-rw-r--r-- 1 root root 169833 Jul 29 12:40 config-3.13.0-61-generic
-rw-r--r-- 1 root root 169833 Aug 11 15:51 config-3.13.0-62-generic
-rw-r--r-- 1 root root 169833 Aug 14 22:58 config-3.13.0-63-generic
</code></pre>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
Remove the old kernels like this:</div>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6000003814697px; line-height: inherit; margin: 0px; max-width: initial; overflow: initial; padding: 0px; word-break: normal; word-wrap: normal;">sudo dpkg --purge linux-image-3.13.0-53-generic
sudo dpkg --purge linux-image-3.13.0-54-generic
# ...
sudo apt-get -f install # tell to continue installing the latest kernel
sudo apt-get autoremove</code></pre>
</div>
<h1 style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 2.25em; line-height: 1.2; margin: 1em 0px 16px; padding-bottom: 0.3em; position: relative;">
<a aria-hidden="true" class="anchor" href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-01-28-free-up-space-on-your-linux-server.md#source-of-information" id="user-content-source-of-information" style="background: transparent; box-sizing: border-box; color: #4183c4; display: block; left: 0px; line-height: 1; margin-left: -30px; padding-left: 30px; padding-right: 6px; position: absolute; text-decoration: none; top: 0px;"></a>source of information</h1>
<ul class="task-list" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 0px !important; margin-top: 0px; padding: 0px 0px 0px 2em;">
<li style="box-sizing: border-box;"><a href="http://askubuntu.com/questions/138026/how-do-i-delete-kernels-from-a-server" style="background: transparent; box-sizing: border-box; color: #4183c4; text-decoration: none;">http://askubuntu.com/questions/138026/how-do-i-delete-kernels-from-a-server</a></li>
<li style="box-sizing: border-box;"><a href="http://askubuntu.com/questions/5980/how-do-i-free-up-disk-space" style="background: transparent; box-sizing: border-box; color: #4183c4; text-decoration: none;">http://askubuntu.com/questions/5980/how-do-i-free-up-disk-space</a></li>
<li style="box-sizing: border-box;"><a href="http://ubuntuforums.org/showthread.php?t=2291788" style="background-color: transparent; box-sizing: border-box; color: #4078c0; text-decoration: none;">http://ubuntuforums.org/showthread.php?t=2291788</a></li>
</ul>
</div>
<ul class="task-list" style="box-sizing: border-box; margin-bottom: 0px !important; margin-top: 0px; padding: 0px 0px 0px 2em;">
<li style="box-sizing: border-box;"><span style="color: #333333; font-family: Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif;"><span style="line-height: 25.6000003814697px;"><a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-01-28-free-up-space-on-your-linux-server.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2015-01-28-free-up-space-on-your-linux-server.md</a> </span></span></li>
</ul>
</article></div>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-88118147762015600562014-12-16T07:07:00.001-08:002014-12-16T07:08:08.021-08:00Rails force_ssl causing NginX infinite loop<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
Today I was configuring some new security features on one of my employers websites. One of them was feature to always force ssl on application.</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
In Rails 3.2.x and 4.x you can do that by just using <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px; padding: 0.2em 0px;">force_ssl</code> in Controller or in <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px; padding: 0.2em 0px;">config/enviroment/production.rb</code><a href="http://api.rubyonrails.org/classes/ActionController/ForceSSL/ClassMethods.html" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">More info</a></div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
Everything worked nice then I deployed to Staging and my server neded up in relally dumb infinite loop:</div>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-stretch: normal; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;"># log/staging.log
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
Cache read: http://www.staging-my-app.com/?
</code></pre>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
Turns out that NginX needs to pass <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px; padding: 0.2em 0px;">X-Forwarded-Proto</code> header so that Rails recognize that "yes I'm on ssl"</div>
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-stretch: normal; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;"># /etc/nginx/nginx.conf # ..or one of your sites-enabled
# ...
location @unicorn {
# ...
proxy_set_header X-Forwarded-Proto https;
# ...
proxy_pass http://unicorn;
}
</code></pre>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
source:</div>
<ul class="task-list" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 0px !important; margin-top: 0px; padding: 0px 0px 0px 2em;">
<li style="box-sizing: border-box;"><a href="http://simonecarletti.com/blog/2011/05/configuring-rails-3-https-ssl/" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">http://simonecarletti.com/blog/2011/05/configuring-rails-3-https-ssl/</a></li>
<li style="box-sizing: border-box;"><a href="http://seaneshbaugh.com/posts/configuring-nginx-and-unicorn-for-force_ssl" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">http://seaneshbaugh.com/posts/configuring-nginx-and-unicorn-for-force_ssl</a></li>
<li style="box-sizing: border-box;"><a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2014-12-16-force-ssl-nginx-infinite-loop.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2014-12-16-force-ssl-nginx-infinite-loop.md</a></li>
</ul>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-40792851567345379842014-12-12T05:55:00.003-08:002014-12-12T05:56:57.078-08:00 change Rack Test default host<div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
If you're using <a href="https://github.com/brynary/rack-test" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">Rack Test</a> to test requests on your Sinatra application you will notice that by default the host is<code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px; padding: 0.2em 0px;">example.org</code>.</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
you can change this like this:</div>
<div class="highlight highlight-ruby" style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: #969896;"># spec/spec_helper.rb</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">def</span> <span class="pl-en" style="box-sizing: border-box; color: #795da3;">app</span>
<span class="pl-vo" style="box-sizing: border-box;">MySinatraOrRackApp</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">module</span> <span class="pl-en" style="box-sizing: border-box; color: #795da3;">Rack</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">module</span> <span class="pl-en" style="box-sizing: border-box; color: #795da3;">Test</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">module</span> <span class="pl-en" style="box-sizing: border-box; color: #795da3;">Methods</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">def</span> <span class="pl-en" style="box-sizing: border-box; color: #795da3;">build_rack_mock_session</span>
<span class="pl-s3" style="box-sizing: border-box; color: #0086b3;">Rack</span>::<span class="pl-s3" style="box-sizing: border-box; color: #0086b3;">MockSession</span>.<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">new</span>(app, <span class="pl-s1" style="box-sizing: border-box; color: #df5000;"><span class="pl-pds" style="box-sizing: border-box;">'</span>api.myapp.com<span class="pl-pds" style="box-sizing: border-box;">'</span></span>)
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
<span class="pl-k" style="box-sizing: border-box; color: #a71d5d;">end</span>
<span class="pl-c" style="box-sizing: border-box; color: #969896;"># this has to be done before you do `include Rack::Test::Methods`</span></pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; line-height: 25.6000003814697px;">
note: Rack Test is the lib that is repsonsible for request test, so when you do <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px; padding: 0.2em 0px;">post('/events')</code>, <code style="background-color: rgba(0, 0, 0, 0.0392157); border-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px; padding: 0.2em 0px;">get('/', token: 123)</code>, ...</div>
</div>
<div>
<br /></div>
<div>
source:</div>
<ul>
<li><a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2014-12-12-rack-test-change-default-host.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2014-12-12-rack-test-change-default-host.md</a></li>
</ul>
<br />Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-45749019430098870712014-11-11T04:57:00.002-08:002014-11-11T05:03:08.481-08:00Fetch Amazon s3 (aws) backup from console<h1>
<div style="box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; font-size: 16px; font-weight: normal; line-height: 25.6000003814697px; margin-bottom: 16px;">
<div style="box-sizing: border-box; line-height: 25.6000003814697px; margin-bottom: 16px;">
If you are using <a href="https://github.com/meskyanichi/backup" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">backup gem</a> for creating your backups to s3 bucket (or any other gem) logging to your AWS console web interface each time you want to download backup is painfull.</div>
<div style="box-sizing: border-box; line-height: 25.6000003814697px; margin-bottom: 16px;">
Much faster solution is to fetch the dump via console with <a href="http://s3tools.org/s3cmd" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">s3cmd</a></div>
<pre style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-stretch: normal; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;">sudo apt-get install s3cmd
</code></pre>
<div style="box-sizing: border-box; line-height: 25.6000003814697px; margin-bottom: 16px;">
First you need to create user <a href="http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_SettingUpUser.html" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_SettingUpUser.html</a> and add him a role that will allow s3 access (e.g. S3FullAccess )</div>
<div style="box-sizing: border-box; line-height: 25.6000003814697px; margin-bottom: 16px;">
Now that you have <code style="background-color: rgba(0, 0, 0, 0.0392157); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px; padding: 0.2em 0px;">Access Key ID</code> and <code style="background-color: rgba(0, 0, 0, 0.0392157); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px; padding: 0.2em 0px;">Secret Access Key</code> you can configure s3cmd</div>
<pre style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-stretch: normal; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;">s3cmd --configure
</code></pre>
<div style="box-sizing: border-box; line-height: 25.6000003814697px; margin-bottom: 16px;">
One thing you should avoid are special chars in passphraze <a href="http://stackoverflow.com/questions/16512312/s3cmd-incomplete-format-error/16714176#16714176" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; color: #4183c4; text-decoration: none;">http://stackoverflow.com/questions/16512312/s3cmd-incomplete-format-error/16714176#16714176</a></div>
<div style="box-sizing: border-box; line-height: 25.6000003814697px; margin-bottom: 16px;">
To try if it works do:</div>
<pre style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-stretch: normal; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;">s3cmd ls
</code></pre>
<div style="box-sizing: border-box; line-height: 25.6000003814697px; margin-bottom: 16px;">
You should see list of your bucket names. If you getting <code style="background-color: rgba(0, 0, 0, 0.0392157); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: normal; margin: 0px; padding: 0.2em 0px;">403</code> you didn't configure your user role ore you misspeld the key/secret</div>
<div style="box-sizing: border-box; line-height: 25.6000003814697px; margin-bottom: 16px;">
Depending on where/how you store backups you can list what's the latest backup with:</div>
<pre style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-stretch: normal; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;">s3cmd ls s3://my-project-production-dbbackup/production_db_backups/my-projcet_backup/
</code></pre>
<div style="box-sizing: border-box; line-height: 25.6000003814697px; margin-bottom: 16px;">
and download it with</div>
<pre style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; font-stretch: normal; line-height: 1.45; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-stretch: normal; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;">s3cmd get s3://my-project-production-dbbackup/production_db_backups/my-projcet_backup/2014.11.11.10.07.14/my-project_backup.tar /tmp/</code></pre>
<br />
raw file: https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2014-11-11-fetch-amazon-s3-backup-from-console.md</div>
</h1>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-69581805271713301312014-10-23T02:04:00.000-07:002014-10-23T02:40:13.957-07:00Yielding Haml block will return 0 (zero)<h1 style="border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif; margin-bottom: 16px; margin-left: 0px; margin-right: 0px; margin-top: 0px !important; padding-bottom: 0.3em; position: relative;">
<div style="box-sizing: border-box; font-size: 16px; font-weight: normal; line-height: 25px; margin-bottom: 16px;">
I had a presenter-view code like this one:</div>
<div class="highlight highlight-ruby" style="background-color: white; box-sizing: border-box; font-size: 16px; font-weight: normal; line-height: 25px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="k" style="box-sizing: border-box; font-weight: bold;">class</span> <span class="nc" style="box-sizing: border-box; color: #445588; font-weight: bold;">MyPresenter</span>
<span class="k" style="box-sizing: border-box; font-weight: bold;">def</span> <span class="nf" style="box-sizing: border-box; color: #945277; font-weight: bold;">render_content</span>
<span class="n" style="box-sizing: border-box;">view_header</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">=</span> <span class="kp" style="box-sizing: border-box; font-weight: bold;">true</span>
<span class="k" style="box-sizing: border-box; font-weight: bold;">yield</span><span class="p" style="box-sizing: border-box;">(</span><span class="nb" style="box-sizing: border-box; color: #0086b3;">self</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">view_header</span><span class="p" style="box-sizing: border-box;">)</span>
<span class="k" style="box-sizing: border-box; font-weight: bold;">end</span>
<span class="k" style="box-sizing: border-box; font-weight: bold;">def</span> <span class="nf" style="box-sizing: border-box; color: #945277; font-weight: bold;">tlt</span><span class="p" style="box-sizing: border-box;">(</span><span class="nb" style="box-sizing: border-box; color: #0086b3;">name</span><span class="p" style="box-sizing: border-box;">)</span>
<span class="s2" style="box-sizing: border-box; color: #df5000;">"fetching translation for </span><span class="si" style="box-sizing: border-box; color: #df5000;">#{</span><span class="nb" style="box-sizing: border-box; color: #0086b3;">name</span><span class="si" style="box-sizing: border-box; color: #df5000;">}</span><span class="s2" style="box-sizing: border-box; color: #df5000;">"</span>
<span class="k" style="box-sizing: border-box; font-weight: bold;">end</span>
<span class="k" style="box-sizing: border-box; font-weight: bold;">end</span>
</pre>
</div>
<div class="highlight highlight-haml" style="background-color: white; box-sizing: border-box; font-size: 16px; font-weight: normal; line-height: 25px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="p" style="box-sizing: border-box;">-</span> <span class="n" style="box-sizing: border-box;">language_presenter</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">=</span> <span class="no" style="box-sizing: border-box; color: #094e99;">MyPresenter</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">new</span>
<span class="p" style="box-sizing: border-box;">-</span> <span class="n" style="box-sizing: border-box;">language_presenter</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">render_content</span> <span class="k" style="box-sizing: border-box; font-weight: bold;">do</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">|</span><span class="n" style="box-sizing: border-box;">presenter</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">view_header</span><span class="o" style="box-sizing: border-box; font-weight: bold;">|</span>
<span class="p" style="box-sizing: border-box;">=</span> <span class="n" style="box-sizing: border-box;">content_tag</span> <span class="ss" style="box-sizing: border-box; color: #8b467f;">:h2</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">presenter</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">tlt</span><span class="p" style="box-sizing: border-box;">(</span><span class="s1" style="box-sizing: border-box; color: #df5000;">'top_header'</span><span class="p" style="box-sizing: border-box;">)</span> <span class="k" style="box-sizing: border-box; font-weight: bold;">if</span> <span class="n" style="box-sizing: border-box;">view_header</span>
<span class="p" style="box-sizing: border-box;">=</span> <span class="n" style="box-sizing: border-box;">presenter</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">tlt</span><span class="p" style="box-sizing: border-box;">(</span><span class="s1" style="box-sizing: border-box; color: #df5000;">'main_body'</span><span class="p" style="box-sizing: border-box;">)</span>
bla bla bla
</pre>
</div>
<div style="box-sizing: border-box; font-size: 16px; font-weight: normal; line-height: 25px; margin-bottom: 16px;">
but for some reason the value of <code style="background-color: rgba(0, 0, 0, 0.0392157); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: normal; margin: 0px; padding: 0.2em 0px;">yield(self, view_header)</code> was <code style="background-color: rgba(0, 0, 0, 0.0392157); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: normal; margin: 0px; padding: 0.2em 0px;">0</code>. Not nil, not empty string but a zero.</div>
<div style="box-sizing: border-box; font-size: 16px; font-weight: normal; line-height: 25px; margin-bottom: 16px;">
It turns out it was caused by the way how Haml outputs to the template. Long story short, using <code style="background-color: rgba(0, 0, 0, 0.0392157); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: normal; margin: 0px; padding: 0.2em 0px;">capture_haml</code> will capture Haml to sting, and if you render that string with <code style="background-color: rgba(0, 0, 0, 0.0392157); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: normal; margin: 0px; padding: 0.2em 0px;">=</code> that will make it work properly:</div>
<div class="highlight highlight-haml" style="background-color: white; box-sizing: border-box; font-size: 16px; font-weight: normal; line-height: 25px; margin-bottom: 16px;">
<pre style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 1.45; overflow: auto; padding: 16px; word-break: normal; word-wrap: normal;"><span class="p" style="box-sizing: border-box;">-</span> <span class="n" style="box-sizing: border-box;">language_presenter</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">=</span> <span class="no" style="box-sizing: border-box; color: #094e99;">MyPresenter</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">new</span>
<span class="p" style="box-sizing: border-box;">=</span> <span class="n" style="box-sizing: border-box;">language_presenter</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">render_content</span> <span class="k" style="box-sizing: border-box; font-weight: bold;">do</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">|</span><span class="n" style="box-sizing: border-box;">presenter</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">view_header</span><span class="o" style="box-sizing: border-box; font-weight: bold;">|</span>
<span class="p" style="box-sizing: border-box;">-</span> <span class="n" style="box-sizing: border-box;">capture_haml</span> <span class="k" style="box-sizing: border-box; font-weight: bold;">do</span>
<span class="p" style="box-sizing: border-box;">=</span> <span class="n" style="box-sizing: border-box;">content_tag</span> <span class="ss" style="box-sizing: border-box; color: #8b467f;">:h2</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">presenter</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">tlt</span><span class="p" style="box-sizing: border-box;">(</span><span class="s1" style="box-sizing: border-box; color: #df5000;">'top_header'</span><span class="p" style="box-sizing: border-box;">)</span> <span class="k" style="box-sizing: border-box; font-weight: bold;">if</span> <span class="n" style="box-sizing: border-box;">view_header</span>
<span class="p" style="box-sizing: border-box;">=</span> <span class="n" style="box-sizing: border-box;">presenter</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">tlt</span><span class="p" style="box-sizing: border-box;">(</span><span class="s1" style="box-sizing: border-box; color: #df5000;">'main_body'</span><span class="p" style="box-sizing: border-box;">)</span>
bla bla bla
</pre>
</div>
<div style="box-sizing: border-box; font-size: 16px; font-weight: normal; line-height: 25px; margin-bottom: 16px;">
source:</div>
<ul class="task-list" style="box-sizing: border-box; font-size: 16px; font-weight: normal; line-height: 25px; margin-bottom: 0px !important; margin-top: 0px; padding: 0px 0px 0px 2em;">
<li style="box-sizing: border-box;"><a href="http://stackoverflow.com/questions/3619699/haml-block-returning-0-on-yield" style="box-sizing: border-box; color: #4183c4; text-decoration: none;">http://stackoverflow.com/questions/3619699/haml-block-returning-0-on-yield</a></li>
<li style="box-sizing: border-box;"><a href="http://haml.info/docs/yardoc/Haml/Helpers.html#capture_haml-instance_method" style="box-sizing: border-box; color: #4183c4; text-decoration: none;">http://haml.info/docs/yardoc/Haml/Helpers.html#capture_haml-instance_method</a></li>
<li style="box-sizing: border-box;"><a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2014-10-23-yield-returning-zero-0.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2014-10-23-yield-returning-zero-0.md</a></li>
</ul>
<div>
<span style="font-size: small;"><span style="font-weight: normal; line-height: 25px;"><br /></span></span></div>
<br />
<div>
<span style="font-size: small;"><span style="font-weight: normal; line-height: 25px;"> </span></span></div>
</h1>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-50349014072299056832014-07-30T08:39:00.000-07:002014-07-30T08:39:11.159-07:00Rails deliver mail to local file<br />
If you want to debug mail deliveries in development mode and want to see what exactly will be sent
you can tell Rails to "deliver" emails to local folder file instead of sending them via <code>sendmail</code> or <code>smtp</code>.<br />
<br />
<div class="highlight highlight-ruby">
<pre><span class="c1"># config/environments/development.rb</span>
<span class="no">MyApp</span><span class="o">::</span><span class="no">Application</span><span class="o">.</span><span class="n">configure</span> <span class="k">do</span>
<span class="c1"># ...</span>
<span class="n">config</span><span class="o">.</span><span class="n">action_mailer</span><span class="o">.</span><span class="n">delivery_method</span> <span class="o">=</span> <span class="ss">:file</span>
<span class="no">ActionMailer</span><span class="o">::</span><span class="no">Base</span><span class="o">.</span><span class="n">file_settings</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">:location</span> <span class="o">=></span> <span class="no">Rails</span><span class="o">.</span><span class="n">root</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s1">'tmp/mail'</span><span class="p">)</span> <span class="p">}</span>
<span class="c1"># ...</span>
</pre>
<pre><span class="c1">end</span></pre>
<pre><span class="c1">
</span></pre>
</div>
In Rails 4.2 there is even better solution "Mail Previews" (... or <code>show_previews</code>)
more info <a href="http://edgeguides.rubyonrails.org/4_2_release_notes.html#action-mailer">http://edgeguides.rubyonrails.org/4_2_release_notes.html#action-mailer</a><br />
But still if you want ho have the raw mail output, this is still valid solution.<br />
source:<br />
<ul class="task-list">
<li><a href="http://api.rubyonrails.org/classes/ActionMailer/Base.html">http://api.rubyonrails.org/classes/ActionMailer/Base.html</a></li>
<li><a href="http://stackoverflow.com/questions/3763735/rails-mailer-sending-emails-to-a-local-file">http://stackoverflow.com/questions/3763735/rails-mailer-sending-emails-to-a-local-file</a></li>
</ul>
<div>
raw: <a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2014-07-30-rails-deliver-mail-to-file.md">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2014-07-30-rails-deliver-mail-to-file.md</a></div>
<div>
<br /></div>
<br />
keywords: Ruby on Rails 3, Rails 4, Rails 4.1, ActionMailer fileEquivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-21212585433696663552014-05-15T07:09:00.002-07:002014-05-15T07:18:18.989-07:00Heroku app CNAME on Go Daddy <br />
I'm Assuming:<br />
<br />
<ol>
<li> you registered your domain at GoDaddy</li>
<li>you have actual Heroku app that works on http://my_app.herokuapp.com</li>
<li> done everything correctly from <a href="https://devcenter.heroku.com/articles/custom-domains">https://devcenter.heroku.com/articles/custom-domains </a></li>
<li> you have added your domain and www subdomain to heroku app like this:</li>
</ol>
<br />
<pre><span class="function">$ ~/cd my_app</span></pre>
<pre><span class="function">$ gem install heroku</span></pre>
<pre><span class="function">$ heroku domains:add my_app.com</span></pre>
<pre><span class="function">$ </span>heroku domains:add www.my_app.com</pre>
<br />
now you want to point your GoDaddy domain to your Heroku app with CNAME<br />
<br />
1. login to goddady, and lunch your domain and click on "DNS Zone File" tab<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH2D6qfY-pwmbU6ydFGqfXJRphhIpp9gqoZEZNbdd0rMTB4vd7nAvxyKjo1i35fPzjWzWcuMrj19rWaptqUF3h39dekywmLA31DlYzDOkpLF2VBbxzNPCyhSMAn997r4h-67chlohCdD4/s1600/Screenshot-6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH2D6qfY-pwmbU6ydFGqfXJRphhIpp9gqoZEZNbdd0rMTB4vd7nAvxyKjo1i35fPzjWzWcuMrj19rWaptqUF3h39dekywmLA31DlYzDOkpLF2VBbxzNPCyhSMAn997r4h-67chlohCdD4/s1600/Screenshot-6.png" height="131" width="400" /></a></div>
<br />
<br />
2. Click "Add Record", Add CNAME, and point WWW to "my_app.heroku.com"<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY3aEVxqIhDJJBTnsdtUPO6GcXEXJoYzOC75vLhkL2Sr8Ewb4EPRg5iWlI4POCKONP_gobsNqzbk7TVS8bcB1fgxCntimehcS9XZ-45eWfo-mgkQdTgaukSmUhZUsfUPh2Yhdb631n8sc/s1600/Screenshot-5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY3aEVxqIhDJJBTnsdtUPO6GcXEXJoYzOC75vLhkL2Sr8Ewb4EPRg5iWlI4POCKONP_gobsNqzbk7TVS8bcB1fgxCntimehcS9XZ-45eWfo-mgkQdTgaukSmUhZUsfUPh2Yhdb631n8sc/s1600/Screenshot-5.png" height="193" width="320" /></a></div>
<br />
<br />
3. refering to <a href="http://support.godaddy.com/help/article/5289/updating-your-domain-names-ip-address-for-forwarding?locale=en&pc_split_value=3&countrysite=uk">http://support.godaddy.com/help/article/5289/updating-your-domain-names-ip-address-for-forwarding?locale=en&pc_split_value=3&countrysite=uk</a> you should point your A host record to <span style="font-family: 'Segoe UI', 'Lucida Grande', 'Helvetica Neue', sans-serif; font-size: 15px;">50.63.202.17</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
GoDaddy is changing design of their website too often, so if you cannot find these tabs, ...well, shit happens. Try to play around, they should be somewhere.<br />
<br />
if you are looking for how to<a href="http://ruby-on-rails-eq8.blogspot.co.uk/2014/05/how-to-redirect-naked-domains-for.html"> redirect / forward naked domain to www version directly from Go Daddy</a> check this article: <a href="http://ruby-on-rails-eq8.blogspot.co.uk/2014/05/how-to-redirect-naked-domains-for.html">http://ruby-on-rails-eq8.blogspot.co.uk/2014/05/how-to-redirect-naked-domains-for.html</a><br />
<br />
<br />
<br />
<br />Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-52295248786567304872014-05-15T06:46:00.000-07:002014-05-15T07:10:18.331-07:00how to redirect naked domains for Heroku in Go Daddy<div>
Assuming you already set your <a href="http://ruby-on-rails-eq8.blogspot.co.uk/2014/05/heroku-app-cname-on-go-daddy.html">CNAME to point www on GoDaddy </a>to your "http://my_app.herokuapp.com" (if not check this article: <a href="http://ruby-on-rails-eq8.blogspot.co.uk/2014/05/heroku-app-cname-on-go-daddy.html">http://ruby-on-rails-eq8.blogspot.co.uk/2014/05/heroku-app-cname-on-go-daddy.html</a>)</div>
<div>
<br /></div>
<div>
1. login to Go Daddy </div>
<div>
<br /></div>
<div>
2. Lunch your domain</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlMNdYYsDRoSf1TxpSjrMeWMdtHb9MpSeRYrC3ErA7i92CXZPsT9y1Zlu8oFvOgB8rdu31NG8NRS2U8jnXWTxzguEs-cGL_kWP-HFa50WSqpefL2fcLgQ6zSUmnMCxyTJq3vt5Zaax0xk/s1600/Screenshot-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlMNdYYsDRoSf1TxpSjrMeWMdtHb9MpSeRYrC3ErA7i92CXZPsT9y1Zlu8oFvOgB8rdu31NG8NRS2U8jnXWTxzguEs-cGL_kWP-HFa50WSqpefL2fcLgQ6zSUmnMCxyTJq3vt5Zaax0xk/s1600/Screenshot-1.png" height="252" width="400" /></a></div>
<div>
<br /></div>
<div>
3. In Forwarding section click "Manage"</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1X8PwGxsKGeN-RlgCQuJbgV2mz-Z6Bt21G_L_cwYyhtLV2L3D-BELXqiTtvXNgFC_-MvitR21WsaCJvtqimN4OkvsaMaXPC30dQ871qzFSuT9DdxtpKua081DM48JVMM5glkaOXKMdFk/s1600/Screenshot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1X8PwGxsKGeN-RlgCQuJbgV2mz-Z6Bt21G_L_cwYyhtLV2L3D-BELXqiTtvXNgFC_-MvitR21WsaCJvtqimN4OkvsaMaXPC30dQ871qzFSuT9DdxtpKua081DM48JVMM5glkaOXKMdFk/s1600/Screenshot.png" height="273" width="400" /></a></div>
<div>
<br /></div>
<div>
4. Redirect your naked domain to your "www.my_app.com" version that is CNAME redirected to "my_app.herokuapp.com" (http redirect should be fine unless you want access to https version from naked domain; use 301 so that Google will like you )</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKqUNOQysYI8Ybxf9lyBgYbGdA7VFtA1bVtzUC1cxn4JE0Ul4ZHoTjzI19ms-Oj30W4_SW0T2i3gy8poVKAQI5qdKc0yiYwWbVknMuBylj4cG1c7Si4ME2vKHDCoew7F819kkm6VMYdwY/s1600/Screenshot-2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKqUNOQysYI8Ybxf9lyBgYbGdA7VFtA1bVtzUC1cxn4JE0Ul4ZHoTjzI19ms-Oj30W4_SW0T2i3gy8poVKAQI5qdKc0yiYwWbVknMuBylj4cG1c7Si4ME2vKHDCoew7F819kkm6VMYdwY/s1600/Screenshot-2.png" height="225" width="400" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-52699997443847877282014-05-09T04:16:00.001-07:002014-05-09T04:17:36.104-07:00Make private method public in ruby<div class="blob instapaper_body" id="readme">
<br />
<br />
<br />
<article class="markdown-body entry-content" itemprop="mainContentOfPage"><div class="highlight highlight-ruby">
<pre><div class="highlight highlight-ruby" style="background-color: white; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px; margin-top: 0px !important; overflow-x: auto; overflow-y: hidden; white-space: normal;">
<pre style="background-color: #f8f8f8; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 13px; line-height: 19px; margin-bottom: 15px; margin-top: 15px; overflow: auto; padding: 6px 10px; word-wrap: normal;"><span class="k" style="box-sizing: border-box; font-weight: bold;">class</span> <span class="nc" style="box-sizing: border-box; color: #445588; font-weight: bold;">Foo</span>
<span class="kp" style="box-sizing: border-box; font-weight: bold;">private</span>
<span class="k" style="box-sizing: border-box; font-weight: bold;">def</span> <span class="nf" style="box-sizing: border-box; color: #990000; font-weight: bold;">my_method</span>
<span class="s1" style="box-sizing: border-box; color: #dd1144;">'it work !'</span>
<span class="k" style="box-sizing: border-box; font-weight: bold;">end</span>
<span class="k" style="box-sizing: border-box; font-weight: bold;">end</span>
</pre>
</div>
<div class="highlight highlight-ruby" style="background-color: white; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px; overflow-x: auto; overflow-y: hidden; white-space: normal;">
<pre style="background-color: #f8f8f8; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 13px; line-height: 19px; margin-bottom: 15px; margin-top: 15px; overflow: auto; padding: 6px 10px; word-wrap: normal;"><span class="no" style="box-sizing: border-box; color: teal;">Foo</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">new</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">my_method</span>
<span class="c1" style="box-sizing: border-box; color: #999988; font-style: italic;"># => NoMethodError: private method `my_method' called for #<Foo:0x00000003ddb8e8></span>
<span class="no" style="box-sizing: border-box; color: teal;">Foo</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">send</span> <span class="ss" style="box-sizing: border-box; color: #990073;">:public</span><span class="p" style="box-sizing: border-box;">,</span> <span class="ss" style="box-sizing: border-box; color: #990073;">:my_method</span>
<span class="no" style="box-sizing: border-box; color: teal;">Foo</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">new</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">my_method</span>
<span class="c1" style="box-sizing: border-box; color: #999988; font-style: italic;"># => "it work !" </span>
</pre>
</div>
<div class="highlight highlight-ruby" style="background-color: white; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px; overflow-x: auto; overflow-y: hidden; white-space: normal;">
<pre style="background-color: #f8f8f8; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 13px; line-height: 19px; margin-bottom: 15px; margin-top: 15px; overflow: auto; padding: 6px 10px; word-wrap: normal;"><span class="k" style="box-sizing: border-box; font-weight: bold;">class</span> <span class="nc" style="box-sizing: border-box; color: #445588; font-weight: bold;">Bar</span> <span class="o" style="box-sizing: border-box; font-weight: bold;"><</span> <span class="no" style="box-sizing: border-box; color: teal;">Foo</span>
<span class="kp" style="box-sizing: border-box; font-weight: bold;">public</span> <span class="ss" style="box-sizing: border-box; color: #990073;">:my_method</span>
<span class="k" style="box-sizing: border-box; font-weight: bold;">end</span>
</pre>
</div>
<div class="highlight highlight-ruby" style="background-color: white; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px; overflow-x: auto; overflow-y: hidden; white-space: normal;">
<pre style="background-color: #f8f8f8; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 13px; line-height: 19px; margin-bottom: 15px; margin-top: 15px; overflow: auto; padding: 6px 10px; word-wrap: normal;"><span class="no" style="box-sizing: border-box; color: teal;">Foo</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">new</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">my_method</span>
<span class="c1" style="box-sizing: border-box; color: #999988; font-style: italic;"># => NoMethodError: private method `my_method' called for #<Foo:0x00000003ddb8e8></span>
<span class="no" style="box-sizing: border-box; color: teal;">Bar</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">new</span><span class="o" style="box-sizing: border-box; font-weight: bold;">.</span><span class="n" style="box-sizing: border-box;">my_method</span>
<span class="c1" style="box-sizing: border-box; color: #999988; font-style: italic;"># => "it work !" </span>
</pre>
</div>
<div style="box-sizing: border-box; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px; margin-bottom: 15px; margin-top: 15px; white-space: normal;">
source</div>
<ul style="box-sizing: border-box; margin-bottom: 0px !important; margin-left: 0px; margin-right: 0px; margin-top: 15px; padding: 0px 0px 0px 30px;"><span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif;"><span style="font-size: 15px; line-height: 25px; white-space: normal;">
</span></span>
<li style="box-sizing: border-box; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px; white-space: normal;"><a href="http://ruby-doc.org/core-2.1.1/Module.html#method-i-private" style="box-sizing: border-box; color: #4183c4; text-decoration: none;">http://ruby-doc.org/core-2.1.1/Module.html#method-i-private</a></li>
<span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif;"><span style="font-size: 15px; line-height: 25px; white-space: normal;">
</span></span>
<li style="box-sizing: border-box; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px; white-space: normal;"><a href="http://stackoverflow.com/questions/2171743/make-instance-methods-private-in-runtime" style="box-sizing: border-box; color: #4183c4; text-decoration: none;">http://stackoverflow.com/questions/2171743/make-instance-methods-private-in-runtime</a></li>
<li style="box-sizing: border-box;"><span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif;"><span style="font-size: 15px; line-height: 25px; white-space: normal;">https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2014-05-make-private-method-public-in-ruby.md</span></span></li>
<span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif;"><span style="font-size: 15px; line-height: 25px; white-space: normal;">
</span></span></ul>
</pre>
</div>
<ul>
</ul>
</article></div>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.comtag:blogger.com,1999:blog-4559330032690840278.post-6176452864986210182014-04-17T01:51:00.000-07:002014-04-17T01:57:57.561-07:00Rails console no database connection<h1 id="rails-console-no-database-connection" style="color: #444444; font-family: Arvo, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 30px; line-height: 36px; margin: 0px; outline: 0px; text-rendering: optimizelegibility;">
Rails console no database connection</h1>
<div style="color: #444444; font-family: Arvo, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 9px; outline: 0px;">
if this happens to you right after you load Rails 4 console:</div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.14902); color: #444444; font-family: Menlo, Monaco, 'Courier New', monospace; font-size: 12px; line-height: 18px; margin-bottom: 9px; outline: 0px; padding: 8.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code class="lang-bash" style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Menlo, Monaco, 'Courier New', monospace; outline: 0px; padding: 0px;">rails c</code></pre>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.14902); color: #444444; font-family: Menlo, Monaco, 'Courier New', monospace; font-size: 12px; line-height: 18px; margin-bottom: 9px; outline: 0px; padding: 8.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code class="lang-ruby" style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Menlo, Monaco, 'Courier New', monospace; outline: 0px; padding: 0px;">User
=> User(no database connection)</code></pre>
<div style="color: #444444; font-family: Arvo, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 9px; outline: 0px;">
It just means that ActiveRecord has not yet connected to the database and therefore does not know the column information. This is so that will not connect to DB unless needed to (speed improvements in Rails 4).</div>
<div style="color: #444444; font-family: Arvo, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 9px; outline: 0px;">
to connect just call</div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.14902); color: #444444; font-family: Menlo, Monaco, 'Courier New', monospace; font-size: 12px; line-height: 18px; margin-bottom: 9px; outline: 0px; padding: 8.5px; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;"><code class="lang-ruby" style="background-color: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; color: inherit; font-family: Menlo, Monaco, 'Courier New', monospace; outline: 0px; padding: 0px;">User.connection
# or
User.last</code></pre>
<div style="color: #444444; font-family: Arvo, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 9px; outline: 0px;">
Rails 4</div>
<div style="color: #444444; font-family: Arvo, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; margin-bottom: 9px; outline: 0px;">
source: <a href="http://stackoverflow.com/a/19887408" style="color: blue; outline: 0px;">http://stackoverflow.com/a/19887408</a><br />
<br />
<a href="https://github.com/equivalent/scrapbook2/blob/master/archive/mini-blogs/2013-12-no-database-connection-in-rails-console.md" rel="nofollow">markdown version at github</a></div>
Equivalenthttp://www.blogger.com/profile/07833216975354220924noreply@blogger.com