Mostrando entradas con la etiqueta Sports. Mostrar todas las entradas
Mostrando entradas con la etiqueta Sports. Mostrar todas las entradas

domingo, 7 de octubre de 2012

Keeping track of my calories the R way

So...I'm back with Your Shape: Fitness Evolved 2012 for XBox Kinect. Why? Because I want to loose some weight and get back in shape of course -;)

The reason I stop playing the game is simple...I'm lazy...but this time, I have come back with a goal...burn calories!

While I'm using the Your Shape IPhone Application which is really good...I wanted to do something with R and more precisely with Rook...

What I wanted, was a way to keep track of the days and calories burned and generate a nice graphic, but allowing me to choose a range of dates...

This is the code I came up with yesterday night...

Blag_Fitness.R
require("Rook")
library("lubridate")
setwd("C:/Blag/R_Scripts")

Blag_Fitness = read.csv(file="Blag_Fitness.csv",header=TRUE)
Blag_Fitness$Date<-strptime(Blag_Fitness$Date,"%d/%m/%Y")
Rows<-nrow(Blag_Fitness)
Rows
Default_Day<-day(Blag_Fitness$Date[1])
Default_Month<-month(Blag_Fitness$Date[1])
Default_Last_Day<-day(Blag_Fitness$Date[Rows])
Default_Last_Day
Default_Last_Month<-month(Blag_Fitness$Date[Rows])

fill_zeros<-function(param,mode=0){
    count<-nchar(param)
    zeros<-rep(0,1)
    if(mode==0){
      if(count==1){
        r_param<-c(zeros,param)
      }else{
        r_param<-c(param)
      }
    }else{
      if(count==7){
        r_param<-c(zeros,param)
      }else{
        r_param<-c(param)
      }      
    }
    r_param<-paste(r_param,collapse="")
    return(r_param)      
}

newapp<-function(env){
  req<-Rook::Request$new(env)
  res<-Rook::Response$new()
  
  res$write('<form method="POST">\n')
  res$write('<div align="center"><table><tr>') 
  res$write('<td><select name=DAYFROM>')
  for(i in 1:31) {
    if(i==Default_Day){
      res$write(sprintf('<OPTION VALUE=%s SELECTED=%s>%s</OPTION>',
                        i,Default_Day,i))
    }else{
      res$write(sprintf('<OPTION VALUE=%s>%s</OPTION>',i,i))
    }
  }
  res$write('</select></td><td>')
  res$write('<select name=MONTHFROM>')
  for(i in 1:12) {
    if(i==Default_Month){
      res$write(sprintf('<OPTION VALUE=%s SELECTED=%s>%s</OPTION>',
                        i,Default_Month,i))
    }else{
      res$write(sprintf('<OPTION VALUE=%s>%s</OPTION>',i,i))
    }
  }
  res$write('</select></td>')
  res$write('</select></td><td>')
  res$write('<select name=YEARFROM>')
  for(i in 2012:2020) {
    res$write(sprintf('<OPTION VALUE=%s>%s</OPTION>',i,i))
  }
  
  res$write('</select></td>')
  res$write('<td>To</td>')

  res$write('<td><select name=DAYTO>')
  for(i in 1:31) {
    if(i==Default_Last_Day){
      res$write(sprintf('<OPTION VALUE=%s SELECTED=%s>%s</OPTION>',
                        i,Default_Last_Day,i))
    }else{
      res$write(sprintf('<OPTION VALUE=%s>%s</OPTION>',i,i))
    }
  }
  res$write('</select></td><td>')
  res$write('<select name=MONTHTO>')
  for(i in 1:12) {
    if(i==Default_Last_Month){
      res$write(sprintf('<OPTION VALUE=%s SELECTED=%s>%s</OPTION>',
                        i,Default_Last_Month,i))
    }else{
      res$write(sprintf('<OPTION VALUE=%s>%s</OPTION>',i,i))
    }
  }
  res$write('</select></td>')
  res$write('</select></td><td>')
  res$write('<select name=YEARTO>')
  for(i in 2012:2020) {
    res$write(sprintf('<OPTION VALUE=%s>%s</OPTION>',i,i))
  }
  res$write('</select></td>')  
  
  res$write('<td><input type="submit" value="Get Stats"></td>')
  res$write('</tr></table></div>')
  res$write('</form>')
  
  if (!is.null(req$POST())) {
    p_dayfrom = req$POST()[["DAYFROM"]]
    p_monthfrom = req$POST()[["MONTHFROM"]]
    p_yearfrom = req$POST()[["YEARFROM"]]
    p_dayto = req$POST()[["DAYTO"]]
    p_monthto = req$POST()[["MONTHTO"]]
    p_yearto = req$POST()[["YEARTO"]]
    p_dayfrom<-fill_zeros(p_dayfrom)
    p_monthfrom<-fill_zeros(p_monthfrom)
    date_from<-c(p_dayfrom,'/',p_monthfrom,'/',p_yearfrom)
    date_from<-paste(date_from,collapse="")
    date_from_n<-strptime(date_from,"%d/%m/%Y")
    date_from_n<-as.numeric(format(date_from_n,"%d%m%Y"))
    p_dayto<-fill_zeros(p_dayto)
    p_monthto<-fill_zeros(p_monthto)
    date_to<-c(p_dayto,'/',p_monthto,'/',p_yearto)
    date_to<-paste(date_to,collapse="")
    date_to_n<-strptime(date_to,"%d/%m/%Y")
    date_to_n<-as.numeric(format(date_to_n,"%d%m%Y"))
    
    Blag_Fitness$Date<-as.numeric(format(Blag_Fitness$Date,"%d%m%Y"))
    
    Selected_Data<-subset(Blag_Fitness, Date >= date_from_n & Date <= date_to_n)
    Selected_Data$Date<-as.character(Selected_Data$Date)
    fixer<-fill_zeros
    Selected_Data$Date<-sapply(Selected_Data$Date,fixer,mode=1)
    Selected_Data$Date<-strptime(Selected_Data$Date,"%d%m%Y")

    res$write(sprintf('<div align="center"><h3>From %s to %s</h3></div>',
                      date_from,date_to))
    
    png("Blag_Fitness.png",width=800,height=500)
    plot(Selected_Data,type="n")
    lines(Selected_Data,col="blue",ann=FALSE)
    points(Selected_Data, pch=21, bg="lightcyan", cex=1.25)
    dev.off()
    res$write("<div align='center'>")
    res$write(paste("<img src='", server$full_url("pic"), "/", 
                    "Blag_Fitness.png'", "/>", sep = ""))
    
    res$write("</div>")    
  }else{
    res$write("<p>No data to select...</p>")
  }
  res$finish()
}

server = Rhttpd$new()
server$add(app = newapp, name = "Blag_Fitness")
server$add(app = File$new("C:/Blag/R_Scripts"), name = "pic")
server$start()
server$browse("Blag_Fitness")

When we executed, the application is going to read the first and the last line of our .CSV file and set the default values for the comboboxes...making it easy to select the date range...

Here comes the screenshot -;)


So...you can see that I'm making big progress...I started 3 days ago and burning more calories each day...

Greetings,

Blag.

jueves, 29 de diciembre de 2011

Your Shape: Fitness Evolved 2012


This is not the first time I blog about a fitness game...last time was Again...trying to loose some weight -:P and first time was This post sucks...I know that... but this time is different for two simple reasons...this time I'm talking about an XBox 360 Kinect Game and this time...it really works -;) Or at least it seems so -:P


I got the game for Christmas so I haven't play it to much, but let me tell you...it really makes you sweat...10 ten times more than Wii Fit Plus...also, using no controls more than your body is a must -;)




Of course I haven't count them (I'm too busy exercising myself), but I assume there's about 300 exercises...covering all needed exercises...meaning that this game...is hell of an exercise -:P

But...nothing is perfect you will say -:) What I really miss (And assume not everything is possible):

* Should warn after 30 minutes of training (Like the Wii Fit Plus)
* Should calculate your body mass or something (Like the Wii Fit Plus)
* Should show some chart of how many calories your burned on each day...you're supposed to log into Your Shape Center but it fails when you try to reach the Dashboard

Anyway...the game is really awesome and you should buy it if your into going to the gym...without actually going to the gym -:P

Greetings,

Blag.

jueves, 19 de agosto de 2010

Again...trying to loose some weight -:P


I you follow and read my blog...I really hope you do...you might remember this blog This post sucks I know that where I stated that I was trying to loose some weight by using Wii Sports on a regular basis...well...as supposed...it was a mayor fail -:(

So...a couple of days ago, I bought myself Wii Fit Plus! in an attempt to of course loose weight and to be able to run a little experiment...just like last time...but...this time is for real -;) While I must admit that Wii Sports made me sweat...nothing can be compared to Wii Fit Plus...it's really a killer! -:D So many exercises for so many types of goals...loose weight, correct your posture, get a better balance...


So...my goal is to loose 8 kilos in 3 months...later on I will post my statistics, so you know how good I'm doing...

Of course, I could post a before and after picture of myself...so you might notice the difference...is there's any LOL but I'm sure it will be hell of difference -;)

The trick is to do the training for at least 30 minutes per day and only eat salads at night...because let's face it...by eating 5 or 6 quesadillas or two cheese sandwiches I wasn't going to loose a single gram...

Greetings,

Blag.

sábado, 1 de agosto de 2009

This post sucks...I know that...


Sure, this post sucks...but I don't really care -:)

I been playing Wii Sports today...and after 1 hour and a lot of sweat I come to a wonderful idea...if this had been done before...don't tell coz I don't care, I'm going to do this anyway...


So...what I'm going to do? Easy fellas...this are my stats to today

1/08/2009 --> Wii Age: 61 --> Weight: 89,9 Kilos (196.211 lb).

So I'm going to keep playing everyday (In the morning before I go to work) and keep track of my progress. Of course I'm not planning to post everyday...next month...September 1st I'm going to post my results...and I'm going to loose some weight? gain more muscles? get more handsome? Let's find out in a month -:)

BTW...Nintendo is not paying me a dime for making this kind of promotion to Wii Sports...I really thing they should...so they are free to mail me so we can get a marketing deal...some free Wii games maybe?

Greetings,

Blag.

martes, 10 de marzo de 2009

Geeks and Sports


Last Sunday, Milly and I get back to our Tennis lessons...I took us almost a year...But we're back on the field -;)

Now...You may asking yourselves...So, how this is supposed to be related with Geeks? Easy answer...Take a look at this...


Still not Geek enough for you? Then look at this...


You know how much I love SAP...And I try to show it every time -:)
Finally...I wanted to show you how I end before the 1 hour class...BTW, Milly played a lot way better than me -:(



Greetings,
Blag.