Monthly Archives: January 2014

Dealing with Whitespace in Sublime Text 2

Did you know that whitespace is a ‘bad thing’ in your code? As a non-developer, I didn’t…but it really annoyed the Coder Friend who was helping me.

Admittedly, the whitespace often made me have a lot of useless changes in my git diff, and it probably isn’t as neat as it should be. If we are going to be very accurate, the Ruby style guide does say you should never have trailing whitespace in your code.

My Coder friend’s lightening quick coding was also impeded by the random nature of the tab spaces in my editor: sometimes 2, sometimes 4! Surprise!

Finally he put his foot down and gave me these references to help me sort out my editor (Sublime Text 2) with regards to whitespace. They will take you less than 5 minutes, and make you a bit more of a legit Ruby coder.

  1. Stripping Whitespace on save 
  2. How to make Sublime Text 2 have 2 spaces per tab
  3. How to convert tabs to spaces on save 


Leave a reply

What is Rake Anyway? (For Non-Developer’s Eyes Only)

To make my Boots on Sale app work, I needed to be able to run the code daily to make the price check. I was hosting with Heroku, and Heroku told me I needed to have a rake file in place.

So, I ended up having the following files for my app;

  • Wombat.rb – my little ruby file with the code to do the scrape and send the email
  • Gemfile 
  • Sale.rake – a rake file which did one thing – ran the wombat ruby file
  • Rakefile – which iterated through each .rake file in the directory and ran it.

(I’m not exactly sure if I needed both those rake files, but there you have it).

Note that in my Gemfile I didn’t even have the Rake Gem – but it worked. According to my Coder Friend, this because you can use Rake if it is installed in any app anywhere on your machine.

I had used the term rake before in my rails apps, but I guess I was never taught (or I never learnt) what it actually meant or did. When I started trying to research this, I got a lot of “Is the equivalent of Make” – because a lot of online resources are written for developers of other languages.

Anyway, what I have determined, as a non-developer, is that

Rake is just a programme which lets you run tasks automatically

We have some set up in Rails already e.g. $ rake db:migrate, or you can write your own rake files to run tasks you write yourself.

Rake is written in Ruby but there are some conventions on how you have to write them to run your tasks. Here is a tutorial from one of the teachers off TreeHouse, however unfortunately it isn’t all dumbed down and simple like on Treehouse :(

When you want to run your rake files (to run certain tasks), then in your terminal you can just write

$rake task_name (not the file name, the individual task name).


$rake (Which runs all the rake tasks you have in your Rakefile)

So, for my app, if I wanted to check the price of those boots right now, I would just open up the appropriate directory in my terminal and type

$ rake sale (which would execute all the necessary code).

So writing this down here is how I’m going to remember to do that ;)

Leave a reply

New App: Tell Me When My Boots Go On Sale!

I’ve finished another little App!

I can’t share this one with you, because it doesn’t actually have a html interface (hmmm, then can it be considered an app? I guess not, so this is just a new ‘project’), but if you want to look at the code you can find it here on Github.

So – what does my thing do?

Well, it all started when I saw a pair of beautiful flat, leather ankle boots online. I wanted those boots, but I didn’t want to pay the price, which I thought was way steep. However, I thought I would like to get those boots if/when they went on sale.

When are my boots on sale?

So this is what I did:

1. I wrote a bit of Ruby code to scrape the page the boots were on, to be able to pull out the price. For this I used the Wombat Gem.

2. I made it so that it will email me when the price changes – for this I used the Mailer gem and the SendGrid addon from Heroku (since I am deploying through Heroku)

3. Then I made it run every day at the same time, using Scheduler (Another Heroku addon) and rake tasks.

In the future I would like to add more checks for different products, and maybe even upgrade it to a Rails App so that I can see on a web page all the products I am monitoring, and whether they are on sale yet.

I would love to be able to put all their prices – but of course, annoying stores are all coded up differently! Maybe when all stores implement this will be possible.

p.s. I know it has been months and months since my last post. A lot has happened since then –  I went to Rails Camp, and (less relevantly) the Middle East and India. I also still have this chronic shoulder injury, so I haven’t been able to code as much as I would like…excuses, excuses I know.

Leave a reply