Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 24c2729e6e
Fetching contributors…

Cannot retrieve contributors at this time

491 lines (342 sloc) 28.64 kb
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Entreprevelopment adventures]]></title>
<link href="http://luisalima.github.com/atom.xml" rel="self"/>
<link href="http://luisalima.github.com/"/>
<updated>2012-12-19T19:58:35+00:00</updated>
<id>http://luisalima.github.com/</id>
<author>
<name><![CDATA[Luisa Lima]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[How I test part II - testing models]]></title>
<link href="http://luisalima.github.com/blog/2012/12/19/how-i-test-part-ii/"/>
<updated>2012-12-19T10:17:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/19/how-i-test-part-ii</id>
<content type="html"><![CDATA[<h2>Testing models</h2>
<p>From <a href="http://guides.rubyonrails.org/testing.html">rails guides</a>:</p>
<p>&#8220;Ideally, you would like to include a test for everything which could possibly break. It’s a good practice to have at least one test for each of your validations and at least one test for every method in your model.&#8221;</p>
<p>Which leads me to&#8230;</p>
<h2>Why I use shoulda</h2>
<p>I think that the best thing is just to take a peek at <a href="http://cheat.errtheblog.com/s/rspec_shoulda/">The shoulda cheat sheets</a>.</p>
<p>You actually get a guide of what to test by looking at the cheat sheet! It&#8217;s too bad that it&#8217;s not up to date (actually I think that the whole site is not up to date &#8211; even the gem doesn&#8217;t work anymore, which I think is too bad :-( )</p>
<p>Furthermore, it&#8217;s great for lazy people and it&#8217;s definitely easier on the eyes. Just check the following example:</p>
<div><script src='https://gist.github.com/4339197.js?file=shoulda_model.rb'></script>
<noscript><pre><code># without shoulda... tons of code :-)
it &quot;should belong to person&quot; do
Model.reflect_on_association(:person).macro.should == :belongs_to
end
# with shoulda... one-liner!
it{should belong_to(:person)}
</code></pre></noscript></div>
<p>Convinced? ;-)</p>
<h2>What I test exactly with shoulda</h2>
<p>I go through the whole list of shoulda macros for models, and I just use and abuse them. Since the cheat sheet is not up to date, I created a new one (just for models for now) at:</p>
<div><script src='https://gist.github.com/4339490.js?file=shoulda_cheat_model.rb'></script>
<noscript><pre><code># updated from the original @ http://cheat.errtheblog.com/s/rspec_shoulda
# just a subset -- models -- is included here. I'll update this, and create cheat sheets for others, as I go along.
# I marked the ones I added with NEW and also added the links to the corresponding code, as I think it's useful.
# Any comments/corrections are welcome!
# ================= Data and Associations =======================
# https://github.com/thoughtbot/shoulda-matchers/tree/master/lib/shoulda/matchers/active_record
it { should_not have_db_column(:admin).of_type(:boolean) }
it { should have_db_column(:salary).
of_type(:decimal).
with_options(:precision =&gt; 10, :scale =&gt; 2) }
it { should have_readonly_attributes(:password) }
it { should belong_to(:parent) }
it { should have_db_index(:id) } # NEW
it { should have_many(:friends) }
it { should have_many(:enemies).through(:friends) }
it { should have_many(:enemies).dependent(:destroy) }
it { should have_one(:god) }
it { should have_and_belong_to_many(:posts) }
it {should accept_nested_attributes_for(:user)} # NEW
# ================== Validation Matchers ============================
# https://github.com/thoughtbot/shoulda-matchers/tree/master/lib/shoulda/matchers/active_model
it { should validate_uniqueness_of(:keyword) }
it { should validate_uniqueness_of(:keyword).with_message(/dup/) }
it { should validate_uniqueness_of(:email).scoped_to(:name) }
it { should validate_uniqueness_of(:email).
scoped_to(:first_name, :last_name) }
it { should validate_uniqueness_of(:keyword).case_insensitive }
it { should validate_presence_of(:name) }
it { should validate_presence_of(:name).
with_message(/is not optional/) }
it { should validate_numericality_of(:age) }
it { should validate_format_of(:name).
with('12345').
with_message(/is not optional/) }
it { should validate_format_of(:name).
not_with('12D45').
with_message(/is not optional/) }
it { should validate_acceptance_of(:eula) }
it { should ensure_length_of(:password).
is_at_least(6).
is_at_most(20) }
it { should ensure_length_of(:name).
is_at_least(3).
with_short_message(/not long enough/) }
it { should ensure_length_of(:ssn).
is_equal_to(9).
with_message(/is invalid/) }
it { should ensure_inclusion_of(:age).in_range(0..100) }
it { should_not allow_mass_assignment_of(:password) }
it { should allow_mass_assignment_of(:first_name) }
it { should validate_format_of(:first_name).with(&quot;Carl&quot;) }
it { should validate_confirmation_of(:password) } # NEW</code></pre></noscript></div>
<p>Yes, it&#8217;s a bit tedious. But (1) you make sure that you are actually testing all these details, which is extremely useful when you are constantly refactoring your code, and (2) it&#8217;s not that slow with the multiple cursors of Sublime Text 2. You just need to have a scaffold.</p>
<h2>What I test without shoulda</h2>
<p>Apart from model methods, is there that much to test without shoulda? I test:</p>
<ul>
<li>Any model methods, extensively</li>
<li>Callbacks, extremely extensively</li>
<li>Some validations - but just to make sure I coded them right. See more of this perspective in <a href="http://www.christopherbloom.com/2011/07/12/testing-model-validations-in-rspec-the-short-and-sweet-way/">Testing model validations in rspec the short and sweet way</a></li>
</ul>
<p>&#8230; and for now, that&#8217;s about it.</p>
<h2>Regarding generating fake data</h2>
<p>Like I mentioned before, I do use FactoryGirl extensively. Maybe that means that <a href="http://blog.steveklabnik.com/posts/2012-07-14-why-i-don-t-like-factory_girl">my models are complicated</a>? I don&#8217;t know, but for now, I am sort of using good sense and stuff. Let&#8217;s see what happens. I do use <a href="http://faker.rubyforge.org">Faker</a> as well. Come to think about it, will do a post on that eventually.</p>
<h2>Random issues in testing models</h2>
<p>When everything seems to be absolutely correct in the models and in the tests and you are still getting unexplainable errors, do restart guard. I already spent several hours messing around with the tests because guard didn&#8217;t refresh the models. <a href="http://stackoverflow.com/questions/5855587/spork-is-really-great-but-how-can-i-get-it-to-refresh-validations-and-other-cod">There are automatic solutions</a>, but I didn&#8217;t feel like hacking away the spork/guard configurations again&#8230; yet.</p>
<h2>Random resources</h2>
<ul>
<li><p><a href="http://everydayrails.com/2012/03/19/testing-series-rspec-models-factory-girl.html">Everyday Rails: How I learned to test my Rails applications, Part 3: Model specs</a> - this has a very nice overview of the actual steps required to test models. Now I just cheat using shoulda, but it&#8217;s very nice and useful to get a</p></li>
<li><p><a href="http://www.christopherbloom.com/2011/07/12/testing-model-validations-in-rspec-the-short-and-sweet-way/">Testing model validations in rspec the short and sweet way</a> - it&#8217;s a bit outdated, but describes how to test validations in a short way.</p></li>
</ul>
<hr />
<p>Again, as I already mentioned, I am a beginner to rails and, consequently, in testing rails, so I might be doing/saying terribly wrong things. Any input is very much appreciated :-)</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Inspiring TED talk]]></title>
<link href="http://luisalima.github.com/blog/2012/12/18/inspiring-ted-talk/"/>
<updated>2012-12-18T11:06:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/18/inspiring-ted-talk</id>
<content type="html"><![CDATA[<p>For anyone who works in business (especially startups), this is most probably (or most definitely) the most important TED talk that you&#8217;ll ever get to watch. Or the most important talk/piece of advice that you&#8217;ll ever get, I believe.</p>
<p><a href="http://www.ted.com/talks/simon_sinek_how_great_leaders_inspire_action.html">How great leaders inspire action</a></p>
<p>The fact is that this is what attracts me (and many people, probably) to startups. It&#8217;s just easier to find this sharing of common beliefs &#8211; and if it&#8217;s not, it&#8217;s the wrong startup.</p>
<p><strong>People don&#8217;t buy what you do, they buy why you do it.</strong></p>
<p>People buy what you believe in. Somehow this makes me believe in mankind a bit more :-)</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Analytics js & a mash of interesting rails stuff]]></title>
<link href="http://luisalima.github.com/blog/2012/12/14/analytics-js/"/>
<updated>2012-12-14T13:34:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/14/analytics-js</id>
<content type="html"><![CDATA[<h2>Analytics.js</h2>
<p>I don&#8217;t know whether this library is very common, but it definitely shows a lot of promise:</p>
<p><a href="http://segmentio.github.com/analytics.js/">Segmentio&#8217;s Analytics.js</a></p>
<p>It provides provider-agnostic hooks to route to analytics services. They also have a hosted version where the analytics services can be changed without touching the code. Looks really clean and neat.</p>
<h2>Nice video: to_proc</h2>
<p><a href="http://www.youtube.com/watch?v=aISNtCAZlMg">This video by CooperPress</a> explains in a very clear fashion how to use the &#8220;to_proc&#8221; feature of Ruby (and understand some weird code you might come across). It is also well worth it to subscribe to <a href="http://www.youtube.com/user/CooperPress?feature=watch">their other videos</a>.</p>
<h2>Faster Rails partial rendering and caching</h2>
<p>I sure will try out <a href="http://ninjasandrobots.com/rails-faster-partial-rendering-and-caching/">this gem (multi_fetch_fragments)</a> to optimize Rails when I get to that point of my work&#8230;</p>
<h2>Indexes in Rails databases</h2>
<p><a href="http://tomafro.net/2009/08/using-indexes-in-rails-index-your-associations">Extremely good article by Tom Ward on using indexes in rails associations</a>. An excellent guide to determine what indexes your app should include (no more, no less).</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[How I test - Part I: Environment]]></title>
<link href="http://luisalima.github.com/blog/2012/12/14/how-i-test/"/>
<updated>2012-12-14T11:43:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/14/how-i-test</id>
<content type="html"><![CDATA[<p>Not that I am an authority in testing&#8230; this is just a compilation of the so-called &#8220;best practices&#8221; that I&#8217;ve been seeing around, as well as some extra tips from my (very limited) experience. I&#8217;d love to hear the feedback from more experienced people&#8230; I&#8217;m going to do several of these as I go along.</p>
<h2>Gems I use</h2>
<p>I test using <a href="http://rspec.info">rspec</a> and <a href="https://github.com/thoughtbot/shoulda">shoulda</a>, which dramatically reduces the size of the tests. But beware &#8211; rspec is a DSL, and I think that I only got a bit more intuition on what I was exactly testing after doing some tests in Test::Unit. I also use <a href="https://github.com/thoughtbot/factory_girl">FactoryGirl</a> for setting up the test data, instead of fixtures. Last but not least, the <a href="https://github.com/colszowka/simplecov">simplecov</a> gem is amazing, and although you shouldn&#8217;t rely on it to determine when to stop testing, it really is good to get a (very precise) sense of what&#8217;s covered and what&#8217;s not in their beautiful html reports.</p>
<h2>General tips</h2>
<p>When all your tests are red for no apparent reason, it&#8217;s because you were messing around with the db and then forgot to do</p>
<pre><code>rake db:test:clone</code></pre>
<p>Yup, the reason I am mentioning it here even though it seems completely obvious is because I am distracted and do that a lot&#8230; :-)</p>
<h2>Tips for running guard/spork in vagrant</h2>
<p>I use vagrant to keep my environment all neatly in one place. However, there are downsides. When running guard inside the guest OS, use</p>
<pre><code>bundle exec guard -p</code></pre>
<p>Otherwise, guard won&#8217;t detect changes in the guest filesystem.</p>
<h2>FactoryGirl tips</h2>
<p>You can keep all factories in one file, for me that is more intuitive (and also, I don&#8217;t have to keep opening files while I&#8217;m testing, it&#8217;s all in one place.)</p>
<p>To try FactoryGirl methods in the console, run:</p>
<pre><code>FactoryGirl.find_definitions</code></pre>
<p>At least in my case, I would get a <a href="http://stackoverflow.com/questions/8409787/factorygirl-factory-not-registered-user-argumenterror">factory not registered</a> error when I didn&#8217;t do that.</p>
<h2>Better Errors</h2>
<p>Not exactly related to testing, but <a href="https://github.com/charliesome/better_errors">this gem</a> has been a life changer! When there is an error, the standard error page gets replaced by a much better and useful error page, which has a full trace, the local and instance variables that are set at the time, and a terminal that you can use to inspect and make changes to the variables in the models and controllers in real time (or code whatever you want). I know I already mentioned it in another post, but I can&#8217;t stress enough how cool this gem is!</p>
<p>In the next posts, I&#8217;ll give an overview of how I test the models and controllers, which I only started testing this week!</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Rails tip #2 - less Rspec in more color]]></title>
<link href="http://luisalima.github.com/blog/2012/12/14/rails-tip-number-2-less-rspec-in-color/"/>
<updated>2012-12-14T11:04:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/14/rails-tip-number-2-less-rspec-in-color</id>
<content type="html"><![CDATA[<p>I usually have Guard running in the background with Spork, but when I&#8217;m writing tests I like to do it the old fashioned way and be able to do rspec some_test | less. The problem with that approach is that we get a monochrome version of our tests. In order to redirect the color in the pipe, edit spec_helper and add the following:</p>
<pre><code> # spec/spec_helper.rb
Rspec.configure do |config|
config.tty = true
config.color_enabled = true
# ... whatever configurations you might have here...
end
</code></pre>
<p>And enjoy a more colorful life ;-)</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Rails tip #1 - environment variables]]></title>
<link href="http://luisalima.github.com/blog/2012/12/14/rails-tip-number-1-environment-variables/"/>
<updated>2012-12-14T10:24:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/14/rails-tip-number-1-environment-variables</id>
<content type="html"><![CDATA[<p>This isn&#8217;t exactly my tip (well, since this is a learning / work in progress blog, none of them are), but when an article is already as comprehensive as this one, there&#8217;s nothing left to say except:</p>
<p><a href="http://railsapps.github.com/rails-environment-variables.html">Here&#8217;s a very nice article on the options for setting environment variables in Rails</a></p>
<p>Why would you want to set environment variables in rails? There are some examples in the article, but for instance, setting passwords to access services. They should not be in any file (nor tracked in git), so that other people cannot access them. One way is to set Unix environment variables, the other way &#8211; which actually sounds like a &#8220;cleaner way&#8221; of organizing things &#8211; is to set them from Rails itself by taking the values from a yaml file.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Controlling a Rapberry Pi via VNC without keyboard]]></title>
<link href="http://luisalima.github.com/blog/2012/12/14/controlling-a-rapberry-pi-via-vnc-without-keyboard/"/>
<updated>2012-12-14T09:45:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/14/controlling-a-rapberry-pi-via-vnc-without-keyboard</id>
<content type="html"><![CDATA[<p>I don&#8217;t have a USB keyboard, so my only option for controlling my Raspberry Pi is via SSH. That turned out to work quite well, since the customized image of Debian provided by Raspberry Pi (<a href="http://www.raspberrypi.org/downloads">2012-10-28-wheezy-raspbian.img</a>) already has ssh enabled by default. It suffices to discover the IP address that was assigned by the router, and connect :-)</p>
<p>(By the way, for those with Mac OS, the command line instructions <a href="http://elinux.org/RPi_Easy_SD_Card_Setup#Copying_an_image_to_the_SD_Card_in_Mac_OS_X_.28command_line.29">here</a>) are very nice and comprehensive.</p>
<p>So now on to the cool stuff&#8230; Initally I had installed TightVNC, but could not connect to the same session as being displayed via HDMI (which is console 0). I don&#8217;t know whether that&#8217;s possible with TightVNC, but I sort of got tired of trying. So <a href="http://www.raspberrypi.org/phpBB3/viewtopic.php?p=108862#p108862">here are the steps to make it work</a>, which basically consist of installing x11vnc instead of TightVNC and having your desktop manager autostart it:</p>
<pre><code>
sudo apt-get install x11vnc
11vnc -storepasswd
# to create the autostart entry, do:
cd .config
mkdir autostart
cd autostart
nano x11vnc.desktop
# paste following text:
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X11VNC
Comment=
Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer
StartupNotify=false
Terminal=false
Hidden=false
</code></pre>
<p>&#8230; aaand it works :-) For more details <a href="http://www.raspberrypi.org/phpBB3/viewtopic.php?p=108862#p108862">check the original link</a>.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Installable Web Apps]]></title>
<link href="http://luisalima.github.com/blog/2012/12/13/installable-web-apps/"/>
<updated>2012-12-13T17:08:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/13/installable-web-apps</id>
<content type="html"><![CDATA[<p><a href="http://www.technologyreview.com/view/508741/installable-web-apps-will-be-the-next-tech-battleground/">Very interesting remark from MIT Technology Review</a> on how installable web apps will be the next tech background. To be honest&#8230; Hope not. This should be the next big thing, especially for developers, who can make their apps ubiquitous with a little extra effort&#8230; It will be interesting to see Apple&#8217;s reaction, though.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Rack protection - another cool gem]]></title>
<link href="http://luisalima.github.com/blog/2012/12/13/rack-protection-another-cool-gem/"/>
<updated>2012-12-13T14:01:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/13/rack-protection-another-cool-gem</id>
<content type="html"><![CDATA[<p>This one I haven&#8217;t evaluated yet, but looks promising: <a href="http://rkh.github.com/rack-protection/">Rack Protection</a>, to prevent typical web attacks such as <a href="https://www.owasp.org/index.php/Cross-Site_Request_Forgery">cross site request forgery</a>, <a href="https://www.owasp.org/index.php/Cross_site_scripting">cross site scripting</a>, <a href="https://www.owasp.org/index.php/Clickjacking">clickjacking</a>, directory traversal, <a href="https://www.owasp.org/index.php/Session_hijacking_attack">session hijacking</a> and IP spoofing.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Grooveshark media center with raspberry pi]]></title>
<link href="http://luisalima.github.com/blog/2012/12/13/grooveshark-media-center-with-raspberry-pi/"/>
<updated>2012-12-13T12:09:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/13/grooveshark-media-center-with-raspberry-pi</id>
<content type="html"><![CDATA[<p>&#8230; and better yet: in the command line. No more messing around with slooow browsers in the Pi.</p>
<p>First, install mplayer if you don&#8217;t already have it:</p>
<pre><code> sudo apt-get install mplayer </code></pre>
<p>Then, open ~/.mplayer/config and <a href="http://martin.ankerl.com/2006/06/10/pimp-my-mplayer/">pimp your player</a> by adding the following settings:</p>
<pre><code> cache=8192
cache-min=4 </code></pre>
<p>Next, clone the <a href="https://github.com/drakedevel/gsclient">gsclient plugin</a> by <a href="https://github.com/drakedevel">drakedevel</a>:</p>
<pre><code>
git clone https://github.com/drakedevel/gsclient.git</code></pre>
<p>And now&#8230; RoCk and RoLL :-)</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Better errors gem]]></title>
<link href="http://luisalima.github.com/blog/2012/12/13/better-errors-gem/"/>
<updated>2012-12-13T11:29:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/13/better-errors-gem</id>
<content type="html"><![CDATA[<p>Yes, today I am in &#8220;documentation&#8221; mode, which means &#8220;bloggation&#8221; mode :-)</p>
<p>Just installed this gem &#8211; <a href="https://github.com/charliesome/better_errors">Better errors</a>. It is a gem meant to help you out in development mode that replaces the standard Rails error page with a wayyyy better and more useful error page, featuring full stack trace, source code inspection for all stack frames, local and instance variable inspection, etc.</p>
<p>I&#8217;m going to try it out today, but definitely beats the time spent looking at development logs (even if they are as clean and contained as mine after doing the changes described in <a href="http://luisalima.github.com/blog/2012/12/13/disabling-nagging-logs-in-rails">this post</a>).</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Adding automatic code reloading to rails console]]></title>
<link href="http://luisalima.github.com/blog/2012/12/13/adding-automatic-code-reloading-in-rails-console/"/>
<updated>2012-12-13T10:56:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/13/adding-automatic-code-reloading-in-rails-console</id>
<content type="html"><![CDATA[<p>So I have no idea why the rails console in development mode doesn&#8217;t already do this, since the whole idea of the console in development mode is for us to mess around and test random stuff in development mode, right? Anyway, I got inspired and helped by <a href="http://jkfill.com/">Jkfill</a> with his post on <a href="http://jkfill.com/2012/12/08/automatic-code-reloading-in-rails-console">Automatic Code Reloading in Rails Console</a>, so here goes, more for my records than yours since you should follow the instructions in his post. I am using Rails 3.2.9, so I had to copy the code from the <a href="https://github.com/rails/rails/blob/master/railties/lib/rails/console/app.rb#L25">reload! method in the rails console code</a>, which is not exactly the best practice, but it&#8217;s just for dev mode and it works :-)</p>
<pre><code> #this should be in config/initializers/irb_reloading.rb
if defined?(IRB::Context) && !defined?(Rails::Server) && Rails.env.development?
class IRB::Context
def evaluate_with_reloading(line, line_no)
ActionDispatch::Reloader.cleanup!
ActionDispatch::Reloader.prepare!
evaluate_without_reloading(line, line_no)
end
alias_method_chain :evaluate, :reloading
end
puts "=> IRB code reloading enabled"
end
</code></pre>
<p>In the meanwhile, shortly browsed the code at <a href="https://github.com/rails">the Rails gihub project</a> and it&#8217;s really a nice way to learn more about rails&#8230; must do it more often.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Silencing nagging logs in rails]]></title>
<link href="http://luisalima.github.com/blog/2012/12/13/disabling-nagging-logs-in-rails/"/>
<updated>2012-12-13T10:20:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/13/disabling-nagging-logs-in-rails</id>
<content type="html"><![CDATA[<p>Once upon a time, I was trying to do some meaningful debugging in rails with</p>
<pre><code> logger.debug </code></pre>
<p>and I was being particularly nagged by these annoying messages from Webrick:</p>
<pre><code> WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true [closed]
</code></pre>
<p>The way to solve this? I am using &#8216;thin&#8217; instead of Webrick as a development server (yeah, I know that there are <a href="https://bugs.ruby-lang.org/attachments/2300/204_304_keep_alive.patch">patches to solve this in Webrick</a> but I decided to go a bit aggressive instead).</p>
<p>And another thing that nagged me were the asset pipeline messages with the gets for the css, js, images, etc. So one way to shut Sprockets up is given <a href="http://stackoverflow.com/questions/6312448/how-to-disable-logging-of-asset-pipeline-sprockets-messages-in-rails-3-1">here</a>, and just for the record:</p>
<pre><code> # place this code in config/initializers/quiet_assets.rb
if Rails.env.development?
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/assets/}
call_without_quiet_assets(env)
ensure
Rails.logger.level = previous_level
end
alias_method_chain :call, :quiet_assets
end
end
</code></pre>
<p>Ahhhhh now I can actually see <strong>meaningful</strong> logs in my development log. <em>whew!</em></p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[New Octopress blog...]]></title>
<link href="http://luisalima.github.com/blog/2012/12/13/new-post/"/>
<updated>2012-12-13T09:56:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/13/new-post</id>
<content type="html"><![CDATA[<p>I created this blog specifically to jot down notes of interesting / useful / meaningful stuff I find during my adventures with development, which I hope are useful to others.</p>
<p>And to start with, here is a link to a post that really helped me out <a href="http://code.dblock.org/Octopress-setting-up-a-blog-and-contributing-to-an-existing-one">Octopress: Setting up a Blog and Contributing to an Existing One</a>. It wasn&#8217;t really clear to me from Octopress instructions that I had to run rake generate and rake deploy; I was just trying to make the git commits and push by hand (and becoming really frustrated by it). So, just for my own reference:</p>
<pre><code> # do stuff in your blog, like rake new_post
# then generate the blog
rake generate
# then save the source branch and push it to Github
git add .
git commit -m "whatever message"
git push origin source
# and now, this is where the magic happens! this takes care
# of pushing everything automagically onto the master branch!
rake deploy
</code></pre>
<p>(depending on your system, you might need to run bundle exec followed by the rake commands).</p>
<p>Oh, and also&#8230; to delete a post, delete it only from <pre><code>blog-root/source/_posts/post-title</code></pre> and then run the commands above again. The rake tasks from Octopress take care of everything.</p>
<p>This cool minimalistic theme is from <a href="http://zespia.tw">zespia.tw</a>, and it&#8217;s called <a href="http://zespia.tw/Octopress-Theme-Slash/">Slash</a>.</p>
<p>Ta-da!</p>
<p>So far I&#8217;m really enjoying Octopress &#8211; I chose it because I want to be able to do everything from the shell, and never leave my dev environment and my beloved ST2/emacs combination.</p>
]]></content>
</entry>
</feed>
Jump to Line
Something went wrong with that request. Please try again.