# Focus

It’s amazing how much of a difference focus can make to your code. If you have a lot on your mind it can really mess up your clarity of thought. That’s why coding forces you to sort out other aspects of your life and it can show you pretty quickly when you don’t.

Something that helps me gain this is exercise and spending time with friends. Both of these are pretty quick endorphin fixes, which is probably why they do the job. A few minutes thinking about what you need to do at the beginning of the day and assessing how this went at the end of the day is a good way to measure how you’re doing and is something I’m going to start doing again, plus a little yoga!

This week, Ced and I will carry on with the Path to Mastery App. It needs to have some proportional spacing between the timeline events, which we were overcomplicating before.

It’s a relatively simple calculation, the start date minus the end date divided by the end date minus the start date, divided by 100 should give us the number of pixels that need to be given to a particular date.

Here is the code:

`pixelsForAchievement: function(list, achievement) {       var dayCalculation = (1000*60*60*24);       var firstDate = Date.parse(list[0].date)/dayCalculation;       var lastDate = Date.parse(list[list.length -1].date)/dayCalculation;       var achievementDate = Date.parse(achievement.date)/dayCalculation;    var pixels = ((achievementDate - firstDate)/ (lastDate - firstDate)) * 1000      return pixels;  }};`

The dayCalculation converts the milliseconds returned from a parsed date to a number of days since January 1st 1970. Now we just have to hook it up to the view.

So hopefully, with a bit more rest and focus this week, we’ll get this done and start on the persistence using Active Record. I’m looking forward to deploying my first web app!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.