<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>KodeGeek &#187; programación</title>
	<atom:link href="http://kodegeek.com/blog/category/programacion/feed/" rel="self" type="application/rss+xml" />
	<link>http://kodegeek.com/blog</link>
	<description>Programación, fitness, interés geek</description>
	<lastBuildDate>Sun, 05 Feb 2012 19:12:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Mi primer 10K: Joe Kleinerman 10K</title>
		<link>http://kodegeek.com/blog/2012/01/07/mi-primer-10k-joe-kleinerman-10k/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mi-primer-10k-joe-kleinerman-10k</link>
		<comments>http://kodegeek.com/blog/2012/01/07/mi-primer-10k-joe-kleinerman-10k/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 20:38:49 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[10K]]></category>
		<category><![CDATA[carrera]]></category>
		<category><![CDATA[Joe Kleinerman 10K]]></category>
		<category><![CDATA[run]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=3257</guid>
		<description><![CDATA[Mi primer 10K, no estuvo nada mal Hoy corrí mi primer 10K; Decidí probar una estrategia dado que la distancia a batir es el doble de lo que yo estoy acostumbrado a correr; Comencé lento las 2 primeras millas, un poco más rápido las 2 siguiente y las 2 últimas con todo. Recorrido alrededor de [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Before the race by josevnz, on Flickr" href="http://www.flickr.com/photos/josevnz/6653375041/"><img src="http://farm8.staticflickr.com/7022/6653375041_f4ae6fc2c1_z.jpg" alt="Before the race" width="480" height="640" /><br />
Mi primer 10K, no estuvo nada mal</a></p>
<p>Hoy corrí <a href="http://www.flickr.com/photos/josevnz/sets/72157628734241761/">mi primer 10K</a>; Decidí probar una estrategia dado que la distancia a batir es el doble de lo que yo estoy acostumbrado a correr; Comencé lento las 2 primeras millas, un poco más rápido las 2 siguiente y las 2 últimas con todo.</p>
<p><a href="http://www.flickr.com/photos/josevnz/6659507703/" title="Central Park 6.2 mile loop by josevnz, on Flickr"><img src="http://farm8.staticflickr.com/7163/6659507703_eace8a42ab_z.jpg" width="640" height="425" alt="Central Park 6.2 mile loop"/><br />
Recorrido alrededor de Central Park, 6.2 millas</a></p>
<p>Sin contar con una ida obligatoria al baño en la cual gaste por lo menos 40 segundos (el baño estaba ocupado) creo que salió bien <img src='http://kodegeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Los resultados <a href="http://web2.nyrrc.org/cgi-bin/htmlos.cgi/46150.1.4126623148517322302">oficiales</a>:</p>
<table width="700" border="1" cellspacing="0">
<tbody>
<tr bgcolor="EEEEEE">
<td nowrap="nowrap">
<p><a href="http://web2.nyrrc.org/cgi-bin/htmlos.cgi/87235.3.581221553714250724">Last Name</a></td>
<td nowrap="nowrap">
<p><a href="http://web2.nyrrc.org/cgi-bin/htmlos.cgi/87235.3.653769998914250724">First Name</a></td>
<td nowrap="nowrap">
Sex/<br />
Age</td>
<td nowrap="nowrap">
<p>Bib</td>
<td nowrap="nowrap">
<p>Team</td>
<td nowrap="nowrap">
<p>City</td>
<td nowrap="nowrap">
<p>State</td>
<td nowrap="nowrap">
<p>Country</td>
<td nowrap="nowrap">
<a href="http://web2.nyrrc.org/cgi-bin/htmlos.cgi/87235.3.739626665914250724">Overall<br />
Place</a></td>
<td nowrap="nowrap">
<a href="http://web2.nyrrc.org/cgi-bin/htmlos.cgi/87235.3.876538861614250724">Gender<br />
Place</a></td>
<td nowrap="nowrap">
Age<br />
Place</td>
<td nowrap="nowrap">
Net<br />
Time</td>
<td nowrap="nowrap">
Pace/<br />
Mile</td>
<td nowrap="nowrap">
AG<br />
Time</td>
<td nowrap="nowrap">AG<br />
Gender<br />
Place</td>
<td nowrap="nowrap">
<p>AG %</td>
</tr>
<tr>
<td nowrap="nowrap">Nunez Zuleta</td>
<td nowrap="nowrap">Jose V</td>
<td>M38</td>
<td>5735</td>
<td>0</td>
<td nowrap="nowrap">DARIEN</td>
<td>CT</td>
<td nowrap="nowrap">USA</td>
<td>2416</td>
<td>1701</td>
<td>316</td>
<td>0:55:05</td>
<td>08:54</td>
<td>0:52:51</td>
<td>1843</td>
<td nowrap="nowrap">50.82</td>
</tr>
</tbody>
</table>
<table width="750" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr valign="top">
<td> Resultados oficiales</td>
</tr>
</tbody>
</table>
<p>Esta es una de las carreras del <a href="http://www.ingnycmarathon.org/about/9_1_guaranteed_entry.htm">9+1</a> para tener una entrada garantizada el maratón de NYC, sólo me faltan 8 más <img src='http://kodegeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2012/01/07/mi-primer-10k-joe-kleinerman-10k/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>¿Cuanto esfuerzo poner al correr? Usando un monitor de pulsaciones</title>
		<link>http://kodegeek.com/blog/2011/12/25/cuanto-esfuerzo-poner-al-correr-usando-un-monitor-de-pulsaciones/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cuanto-esfuerzo-poner-al-correr-usando-un-monitor-de-pulsaciones</link>
		<comments>http://kodegeek.com/blog/2011/12/25/cuanto-esfuerzo-poner-al-correr-usando-un-monitor-de-pulsaciones/#comments</comments>
		<pubDate>Mon, 26 Dec 2011 00:15:46 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[kodegeek]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[vida sana]]></category>
		<category><![CDATA[correr pulsaciones pulso fitness running heartrate]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=3222</guid>
		<description><![CDATA[Primero que todo, ¡Feliz navidad!. Hoy me dieron de regalo un monitor de pulsaciones (Polar Link, compatible con Nike GPS awatch), la idea es mantener mis niveles de esfuerzo constantes y en niveles seguros. Así que hoy me decidí a probarlo con una carrera corta de sólo dos millas, ni tan rápido ni tan lento; [...]]]></description>
			<content:encoded><![CDATA[<p>Primero que todo, ¡Feliz navidad!. Hoy me dieron de regalo un monitor de pulsaciones (Polar Link, compatible con Nike GPS awatch), la idea es mantener mis niveles de esfuerzo constantes y en niveles seguros.</p>
<p>Así que hoy me decidí a probarlo con una carrera corta de sólo dos millas, ni tan rápido ni tan lento; La configuración del dispositivo fué trivial y aunque se sintió raro tener una cinta en el pecho durante los primeros 5 minutos luego la sensación se disipó y pude olvidarme por completo que el aparato estaba allí.</p>
<p>La teoría sobre cuales rangos son seguros la pueden encontrar en <a href="http://www.livestrong.com/article/179970-a-healthy-heart-rate-while-running/">este enlace</a>, pero si usted es un corcho como yo ya seguro tiene un script para hacer las conversiones:</p>

<div class="wp_codebox"><table><tr id="p32223"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p3222code3"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #808080; font-style: italic;"># Heart rate range calculator, for both aerobic and anaerobic ranges</span>
<span style="color: #808080; font-style: italic;"># http://kodegeek.com/blog</span>
<span style="color: #808080; font-style: italic;"># http://www.livestrong.com/article/179970-a-healthy-heart-rate-while-running/</span>
<span style="color: #ff7700;font-weight:bold;">def</span> heartRate<span style="color: black;">&#40;</span>age, anaerobic=<span style="color: #008000;">False</span><span style="color: black;">&#41;</span>:
        maxHearthRate = <span style="color: #ff4500;">220</span> - age
        bound = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> anaerobic:
                bound.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.50</span> <span style="color: #66cc66;">*</span> maxHearthRate<span style="color: black;">&#41;</span>
                bound.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.85</span> <span style="color: #66cc66;">*</span> maxHearthRate<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">else</span>:
                bound.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.80</span> <span style="color: #66cc66;">*</span> maxHearthRate<span style="color: black;">&#41;</span>
                bound.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.90</span> <span style="color: #66cc66;">*</span> maxHearthRate<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> bound
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
        <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
        args = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#41;</span> == <span style="color: #ff4500;">2</span>:
                res = heartRate<span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#123;</span><span style="color: #483d8b;">'true'</span>: <span style="color: #008000;">True</span>, <span style="color: #483d8b;">'false'</span>: <span style="color: #008000;">False</span><span style="color: black;">&#125;</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s,  %s &quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>res<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, res<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Por ejemplo, para alguien de mi edad estos deberian ser los rangos aeróbicos y anaeróbicos:</p>

<div class="wp_codebox"><table><tr id="p32224"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p3222code4"><pre class="bash" style="font-family:monospace;">&nbsp;
Macintosh:python josevnz$ python com<span style="color: #000000; font-weight: bold;">/</span>kodegeek<span style="color: #000000; font-weight: bold;">/</span>fitness<span style="color: #000000; font-weight: bold;">/</span>heartrate.py <span style="color: #000000;">38</span> <span style="color: #c20cb9; font-weight: bold;">false</span>
<span style="color: #000000;">91.0</span>,  <span style="color: #000000;">154.7</span> 
Macintosh:python josevnz$ python com<span style="color: #000000; font-weight: bold;">/</span>kodegeek<span style="color: #000000; font-weight: bold;">/</span>fitness<span style="color: #000000; font-weight: bold;">/</span>heartrate.py <span style="color: #000000;">38</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
<span style="color: #000000;">145.6</span>,  <span style="color: #000000;">163.8</span> 
Macintosh:python josevnz$</pre></td></tr></table></div>

<p>Según el monitor, en promedio mis pulsaciones promedio estuvieron en 165, solamente estuve un %38 del tiempo dentro de mi rango aeróbico. Muy alto, al menos que este leyendo algo mal. <a href="http://www.livestrong.com/article/130246-average-heart-rate-running/">Ahora me sale hacer mi tarea</a> <img src='http://kodegeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2011/12/25/cuanto-esfuerzo-poner-al-correr-usando-un-monitor-de-pulsaciones/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>¿Como configurar Netbeans 7.10 beta y JavaFX 2.0 beta en OSX?</title>
		<link>http://kodegeek.com/blog/2011/10/15/%c2%bfcomo-configurar-netbeans-7-10-beta-y-javafx-2-0-beta-en-osx/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25c2%25bfcomo-configurar-netbeans-7-10-beta-y-javafx-2-0-beta-en-osx</link>
		<comments>http://kodegeek.com/blog/2011/10/15/%c2%bfcomo-configurar-netbeans-7-10-beta-y-javafx-2-0-beta-en-osx/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 23:07:13 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[javafx]]></category>
		<category><![CDATA[netbeans javafx osx]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=3140</guid>
		<description><![CDATA[Es un poco fastidioso, pero una vez que se bajen los binarios y siguiendo las instrucciones (no muy precisas de Oracle) terminé haciendo esto: Netbeans 1.7.1 (beta) + JavaFX 2.0 (beta) ¡Ahora a jugar!]]></description>
			<content:encoded><![CDATA[<p>Es un poco fastidioso, pero una vez que se bajen los binarios y <a href="http://netbeans.org/kb/docs/java/javafx-setup.html">siguiendo las instrucciones</a> (no muy precisas de Oracle) terminé haciendo esto:</p>
<p><a href="http://kodegeek.com/blog/wp-content/uploads/2011/10/Screen-Shot-2011-10-15-at-7.00.50-PM.png"><img src="http://kodegeek.com/blog/wp-content/uploads/2011/10/Screen-Shot-2011-10-15-at-7.00.50-PM.png" alt="" title="Netbeans 1.7.1 (beta) + JavaFX 2.0 (beta)" width="883" height="547" class="alignnone size-full wp-image-3141" />Netbeans 1.7.1 (beta) + JavaFX 2.0 (beta)</a></p>
<p>¡Ahora a jugar! <img src='http://kodegeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2011/10/15/%c2%bfcomo-configurar-netbeans-7-10-beta-y-javafx-2-0-beta-en-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hackeando mis datos en NikeRunning.com</title>
		<link>http://kodegeek.com/blog/2011/10/12/hackeando-mis-datos-en-nikerunning-com/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hackeando-mis-datos-en-nikerunning-com</link>
		<comments>http://kodegeek.com/blog/2011/10/12/hackeando-mis-datos-en-nikerunning-com/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 02:30:19 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[internet]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javafx]]></category>
		<category><![CDATA[kodegeek]]></category>
		<category><![CDATA[vida sana]]></category>
		<category><![CDATA[nikerunning xml webservices hacking javafx java]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=3123</guid>
		<description><![CDATA[Tipos de terreno para todas mis carreras, desde NikeRunning, mostrado con JavaFX Desde que comencé a correr he utilizado a NikeRunning.com de una u otra manera; Primero comencé con mi Itouch y ahora lo utilizó con el NikeWatch. Sin embargo, el sitio de Nike es un poco fastidioso; El sitio web está escrito en Flash [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://kodegeek.com/blog/wp-content/uploads/2011/10/Screen-Shot-2011-10-12-at-10.22.43-PM.png"><img src="http://kodegeek.com/blog/wp-content/uploads/2011/10/Screen-Shot-2011-10-12-at-10.22.43-PM.png" alt="" title="KodeGeek - Tipos de terreno para todas mis carreras, desde NikeRunning" width="502" height="500" class="alignnone size-full wp-image-3132" /><br />
Tipos de terreno para todas mis carreras, desde NikeRunning, mostrado con JavaFX</a></p>
<p>Desde que comencé a correr he utilizado a NikeRunning.com de una u otra manera; Primero comencé con mi Itouch y ahora lo utilizó con el NikeWatch.</p>
<p>Sin embargo, el sitio de Nike es un poco fastidioso; El sitio web está escrito en Flash (lo cual lo hace pesado), tiene gráficos limitados pero lo mas inconveniente es que mis datos están cautivos en el sitio web. Según ellos ya llevan tiempo trabajando en una migración que eliminará Flash:</p>
<blockquote><p>Hello Everyone,</p>
<p>Thank you all for your feedback.</p>
<p>To let everyone know, we are in the process of revamping our website. We are in transition to move away from flash to HTML. The goal is to be faster and more efficient.</p>
<p>We thank you for your patience as we update our sites. There is not an estimated time of when the transition will be fixed, but I can assure you that I&#8217;ve seen parts of the site and it&#8217;s looks and feels amazing.</p>
<p>Stay tuned! </p></blockquote>
<p>Buscando un poco en Google me conseguí conque se puede obtener toda la información de las carreras (siempre y cuando estas esten marcadas como públicas) usando el siguiente URL:</p>

<div class="wp_codebox"><table><tr id="p312310"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p3123code10"><pre class="bash" style="font-family:monospace;">http:<span style="color: #000000; font-weight: bold;">//</span>nikerunning.nike.com<span style="color: #000000; font-weight: bold;">/</span>nikeplus<span style="color: #000000; font-weight: bold;">/</span>v1<span style="color: #000000; font-weight: bold;">/</span>services<span style="color: #000000; font-weight: bold;">/</span>widget<span style="color: #000000; font-weight: bold;">/</span>get_public_run_list.jsp?<span style="color: #007800;">userID</span>=IDENTIFICADOR_DE_USUARIO</pre></td></tr></table></div>

<p>El archivo resultante está en formato XML.</p>
<p>Pero, ¿y de donde obtenemos el identificador del usuario? Es sencillo, simplemente vaya a nikerunning.nike.com y una vez que entre con su usuario y clave al sitio web haga click sobre una de sus corridas. El URL resultante se verá como esto:</p>

<div class="wp_codebox"><table><tr id="p312311"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p3123code11"><pre class="bash" style="font-family:monospace;">http:<span style="color: #000000; font-weight: bold;">//</span>nikerunning.nike.com<span style="color: #000000; font-weight: bold;">/</span>nikeos<span style="color: #000000; font-weight: bold;">/</span>p<span style="color: #000000; font-weight: bold;">/</span>nikeplus<span style="color: #000000; font-weight: bold;">/</span>en_US<span style="color: #000000; font-weight: bold;">/</span>plus<span style="color: #000000; font-weight: bold;">/</span><span style="color: #666666; font-style: italic;">#//runs/gps/IDENTIFICADOR_DE_USUARIO/299193444/</span></pre></td></tr></table></div>

<p>En donde IDENTIFICADOR_DE_USUARIO es el número mágico que queremos usar.</p>
<p>Se me ocurrió por ejemplo escribir un pequeño programa en Jython y JavaFX el cual muestra la distribución de tipos de terreno encontrados mientras corrí:</p>

<div class="wp_codebox"><table><tr id="p312312"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code" id="p3123code12"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env jython</span>
<span style="color: #808080; font-style: italic;"># Author: Jose Vicente Nunez Zuleta, josevnz@kodegeek.com</span>
<span style="color: #808080; font-style: italic;"># This script parses the user run data and creates a simple distribtion by terrain types</span>
<span style="color: #808080; font-style: italic;"># See: http://nikerunning.nike.com/nikeos/p/nikeplus/en_EMEA/plus/#//dashboard/</span>
<span style="color: #808080; font-style: italic;"># Nike and Nikeplus/Nike+ are trademarks owned by Nike.</span>
<span style="color: #808080; font-style: italic;"># License: BSD</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: black;">application</span> <span style="color: #ff7700;font-weight:bold;">import</span> Application
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: #dc143c;">collections</span> <span style="color: #ff7700;font-weight:bold;">import</span> FXCollections
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: #dc143c;">collections</span> <span style="color: #ff7700;font-weight:bold;">import</span> ObservableList
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: black;">scene</span> <span style="color: #ff7700;font-weight:bold;">import</span> Scene
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: black;">stage</span> <span style="color: #ff7700;font-weight:bold;">import</span> Stage
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: black;">scene</span>.<span style="color: black;">chart</span> <span style="color: #ff7700;font-weight:bold;">import</span> PieChart
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: black;">scene</span> <span style="color: #ff7700;font-weight:bold;">import</span> Group
<span style="color: #ff7700;font-weight:bold;">from</span> com.<span style="color: black;">kodegeek</span>.<span style="color: black;">fitness</span>.<span style="color: black;">nikerun</span>.<span style="color: black;">query</span> <span style="color: #ff7700;font-weight:bold;">import</span> CannedQuery
<span style="color: #ff7700;font-weight:bold;">from</span> com.<span style="color: black;">kodegeek</span>.<span style="color: black;">fitness</span>.<span style="color: black;">nikerun</span>.<span style="color: black;">public</span> <span style="color: #ff7700;font-weight:bold;">import</span> PlusPublicService
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> TerrainTypesChart<span style="color: black;">&#40;</span>Application<span style="color: black;">&#41;</span>:
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> __getData__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        args = <span style="color: #008000;">self</span>.<span style="color: black;">getParameters</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">getRaw</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        pServ = PlusPublicService<span style="color: black;">&#40;</span>args<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        data = pServ.<span style="color: black;">getUserData</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        dp = CannedQuery<span style="color: black;">&#40;</span><span style="color: #483d8b;">'string'</span>, data<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> dp.<span style="color: black;">getTypesOfTerrain</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> start<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, stage<span style="color: black;">&#41;</span>:
        scene = Scene<span style="color: black;">&#40;</span>Group<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        stage.<span style="color: black;">setTitle</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Terrain types found in all races&quot;</span><span style="color: black;">&#41;</span>
        stage.<span style="color: black;">setWidth</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">500</span><span style="color: black;">&#41;</span>
        stage.<span style="color: black;">setHeight</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">500</span><span style="color: black;">&#41;</span>
&nbsp;
        count = <span style="color: #008000;">self</span>.__getData__<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        data = <span style="color: black;">&#91;</span>PieChart.<span style="color: black;">Data</span><span style="color: black;">&#40;</span>key, value<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: black;">&#40;</span>key, value<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">in</span> count.<span style="color: black;">iteritems</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>
        pieChartData = FXCollections.<span style="color: black;">observableArrayList</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#41;</span>
        chart = PieChart<span style="color: black;">&#40;</span>pieChartData<span style="color: black;">&#41;</span>
        chart.<span style="color: black;">setTitle</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Terrain types found&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        scene.<span style="color: black;">getRoot</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">getChildren</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">add</span><span style="color: black;">&#40;</span>chart<span style="color: black;">&#41;</span>
        stage.<span style="color: black;">setScene</span><span style="color: black;">&#40;</span>scene<span style="color: black;">&#41;</span>
        stage.<span style="color: black;">show</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
        Application.<span style="color: black;">launch</span><span style="color: black;">&#40;</span>TerrainTypesChart<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: #ff7700;font-weight:bold;">class</span>, <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>La clase &#8216;PlusPublicService&#8217; no es más que un simple cliente GET el cual se baja los datos del sitio de Nike:</p>

<div class="wp_codebox"><table><tr id="p312313"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code" id="p3123code13"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">!</span>/usr/bin/env jython
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Author: Jose Vicente Nunez Zuleta, josevnz@kodegeek.com</span>
<span style="color: #808080; font-style: italic;"># See: http://nikerunning.nike.com/nikeos/p/nikeplus/en_EMEA/plus/#//dashboard/</span>
<span style="color: #808080; font-style: italic;"># Nike and Nikeplus/Nike+ are trademarks owned by Nike.</span>
<span style="color: #808080; font-style: italic;"># License: BSD</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">httplib</span> <span style="color: #ff7700;font-weight:bold;">import</span> HTTPConnection, HTTP_PORT
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
__URL__ = <span style="color: #483d8b;">'nikerunning.nike.com'</span>
__SERVICE__ = <span style="color: #483d8b;">'/nikeplus/v1/services/widget/get_public_run_list.jsp?userID='</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> PlusPublicService:
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, userId, port = HTTP_PORT<span style="color: black;">&#41;</span>:
                <span style="color: #008000;">self</span>.<span style="color: black;">service</span> = __SERVICE__ + userId
                <span style="color: #008000;">self</span>.<span style="color: black;">userId</span> = userId
                <span style="color: #008000;">self</span>.<span style="color: black;">port</span> = port
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> getUserData<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, debug=<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>:
                data = <span style="color: #008000;">None</span>
                con = HTTPConnection<span style="color: black;">&#40;</span>__URL__, <span style="color: #008000;">self</span>.<span style="color: black;">port</span><span style="color: black;">&#41;</span>
                con.<span style="color: black;">set_debuglevel</span><span style="color: black;">&#40;</span>debug<span style="color: black;">&#41;</span>
                con.<span style="color: black;">request</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'GET'</span>, <span style="color: #008000;">self</span>.<span style="color: black;">service</span><span style="color: black;">&#41;</span>
                response = con.<span style="color: black;">getresponse</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">if</span> response.<span style="color: black;">status</span> == <span style="color: #ff4500;">200</span>:
                        data = response.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">else</span>:
                        <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #008000;">Exception</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Error. Status = %s, reason = %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>response.<span style="color: black;">status</span>, response.<span style="color: black;">reason</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
                con.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">return</span> data
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
        argv = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>argv<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
                pServ = PlusPublicService<span style="color: black;">&#40;</span>argv<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s&quot;</span> <span style="color: #66cc66;">%</span> pServ.<span style="color: black;">getUserData</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">8</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
                <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;NikeRunning user id is required!&quot;</span>
                <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">192</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Y para procesar mis datos utilizo un poco de XPATH en la clase &#8216;CannedQuery&#8217; la cual tiene un método el cual se encarga de crear la distribución para los distintos tipos de terreno:</p>

<div class="wp_codebox"><table><tr id="p312314"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code" id="p3123code14"><pre class="python" style="font-family:monospace;">/usr/bin/env jython
<span style="color: #808080; font-style: italic;"># Author: Jose Vicente Nunez Zuleta, josevnz@kodegeek.com</span>
<span style="color: #808080; font-style: italic;"># See: http://nikerunning.nike.com/nikeos/p/nikeplus/en_EMEA/plus/#//dashboard/</span>
<span style="color: #808080; font-style: italic;"># Nike and Nikeplus/Nike+ are trademarks owned by Nike.</span>
<span style="color: #808080; font-style: italic;"># License: BSD</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">xml</span>.<span style="color: black;">dom</span>.<span style="color: black;">minidom</span> <span style="color: #ff7700;font-weight:bold;">import</span> parse, parseString
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">xml</span>.<span style="color: black;">etree</span> <span style="color: #ff7700;font-weight:bold;">import</span> ElementTree
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> DataParser<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">type</span>=<span style="color: #483d8b;">'string'</span><span style="color: black;">&#41;</span>:
                <span style="color: #008000;">self</span>.<span style="color: #008000;">type</span> = <span style="color: #008000;">type</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> __parseDomFile__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">file</span><span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">return</span> parse<span style="color: black;">&#40;</span><span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #008000;">file</span>, <span style="color: #483d8b;">'r'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> __parseDomString__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #dc143c;">string</span><span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">return</span> parseString<span style="color: black;">&#40;</span><span style="color: #dc143c;">string</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> __parseXpathFile__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">file</span><span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">return</span> ElementTree.<span style="color: black;">parse</span><span style="color: black;">&#40;</span><span style="color: #008000;">file</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> __parseXpathString__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #dc143c;">string</span><span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">return</span> ElementTree.<span style="color: black;">fromstring</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">string</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> __getDom__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, source<span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>.<span style="color: #008000;">type</span> == <span style="color: #483d8b;">'string'</span>:
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__parseDomString__<span style="color: black;">&#40;</span>source<span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">else</span>:
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__parseDomFile__<span style="color: black;">&#40;</span>source<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> __getTree__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, source<span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>.<span style="color: #008000;">type</span> == <span style="color: #483d8b;">'string'</span>:
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__parseXpathString__<span style="color: black;">&#40;</span>source<span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">else</span>:
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__parseXpathFile__<span style="color: black;">&#40;</span>source<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> CannedQuery<span style="color: black;">&#40;</span>DataParser<span style="color: black;">&#41;</span>:
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #008000;">type</span>, source<span style="color: black;">&#41;</span>:
                <span style="color: #008000;">super</span><span style="color: black;">&#40;</span>CannedQuery, <span style="color: #008000;">self</span><span style="color: black;">&#41;</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">type</span><span style="color: black;">&#41;</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">source</span> = source
                <span style="color: #008000;">self</span>.<span style="color: black;">terrainMap</span> = <span style="color: black;">&#123;</span> <span style="color: #483d8b;">'0'</span>: <span style="color: #483d8b;">'Not defined'</span>, <span style="color: #483d8b;">'1'</span>: <span style="color: #483d8b;">'Road'</span>, <span style="color: #483d8b;">'2'</span>: <span style="color: #483d8b;">'Trail'</span>, <span style="color: #483d8b;">'3'</span>: <span style="color: #483d8b;">'Treadmill'</span>, <span style="color: #483d8b;">'4'</span>: <span style="color: #483d8b;">'Track'</span> <span style="color: black;">&#125;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> getTypesOfTerrain<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
                tree = <span style="color: #008000;">self</span>.__getTree__<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">source</span><span style="color: black;">&#41;</span>
                count = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
                <span style="color: #ff7700;font-weight:bold;">for</span> elem <span style="color: #ff7700;font-weight:bold;">in</span> tree.<span style="color: black;">findall</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;.//terrain&quot;</span><span style="color: black;">&#41;</span>:
                        key = <span style="color: #483d8b;">'Never collected'</span>
                        <span style="color: #ff7700;font-weight:bold;">if</span> elem.<span style="color: black;">text</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">terrainMap</span>:
                                key = <span style="color: #008000;">self</span>.<span style="color: black;">terrainMap</span><span style="color: black;">&#91;</span>elem.<span style="color: black;">text</span><span style="color: black;">&#93;</span>
                        <span style="color: #ff7700;font-weight:bold;">if</span> key <span style="color: #ff7700;font-weight:bold;">in</span> count:
                                count<span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span> += <span style="color: #ff4500;">1</span>
                        <span style="color: #ff7700;font-weight:bold;">else</span>:
                                count<span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span> = <span style="color: #ff4500;">1</span>
                <span style="color: #ff7700;font-weight:bold;">return</span> count
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
        argv = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>argv<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
                dp = CannedQuery<span style="color: black;">&#40;</span><span style="color: #483d8b;">'file'</span>, argv<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
                count = dp.<span style="color: black;">getTypesOfTerrain</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s&quot;</span> <span style="color: #66cc66;">%</span> count</pre></td></tr></table></div>

<p>Pienso abrir un proyecto con todas estas clases de Python (Jython) en unos pocos días. Quiero agregarle un par de cosas más antes de soltarlas al aire libre <img src='http://kodegeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2011/10/12/hackeando-mis-datos-en-nikerunning-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jython + JavaFX: Comienzo duro</title>
		<link>http://kodegeek.com/blog/2011/10/09/jython-javafx-comienzo-duro/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jython-javafx-comienzo-duro</link>
		<comments>http://kodegeek.com/blog/2011/10/09/jython-javafx-comienzo-duro/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 01:32:20 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[javafx]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[javafx java jython]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=3109</guid>
		<description><![CDATA[Al fin Oracle liberó su versión final de JavFX en JavaOne 2011; También hay una versión beta para OSX la cual me baje de una vez. Jugando con los ejemplos me dediqué a experimentar con el ejemplo de un gráfico de torta el cual se ve sencillo: 1 2 3 4 5 6 7 8 [...]]]></description>
			<content:encoded><![CDATA[<p>Al fin Oracle liberó su versión final de JavFX en JavaOne 2011; También hay una versión beta para OSX la cual me baje de una vez.</p>
<p>Jugando con los ejemplos me dediqué a experimentar con <a title="Gráfico de Torta con JavaFX" href="http://download.oracle.com/javafx/2.0/charts/pie-chart.htm#CIHFDADD" target="_blank">el ejemplo de un gráfico de torta</a> el cual se ve sencillo:</p>

<div class="wp_codebox"><table><tr id="p310924"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code" id="p3109code24"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.application.Application</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.collections.FXCollections</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.collections.ObservableList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Scene</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.stage.Stage</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.chart.PieChart</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Group</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PieChartSample <span style="color: #000000; font-weight: bold;">extends</span> Application <span style="color: #009900;">&#123;</span>
&nbsp;
    @Override <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> start<span style="color: #009900;">&#40;</span>Stage stage<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Scene scene <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Scene<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agroup+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Group</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        stage.<span style="color: #006633;">setTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Imported Fruits&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        stage.<span style="color: #006633;">setWidth</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        stage.<span style="color: #006633;">setHeight</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        ObservableList pieChartData <span style="color: #339933;">=</span>
                FXCollections.<span style="color: #006633;">observableArrayList</span><span style="color: #009900;">&#40;</span>
                <span style="color: #000000; font-weight: bold;">new</span> PieChart.<span style="color: #006633;">Data</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Grapefruit&quot;</span>, <span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span>,
                <span style="color: #000000; font-weight: bold;">new</span> PieChart.<span style="color: #006633;">Data</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Oranges&quot;</span>, <span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span>,
                <span style="color: #000000; font-weight: bold;">new</span> PieChart.<span style="color: #006633;">Data</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Plums&quot;</span>, <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>,
                <span style="color: #000000; font-weight: bold;">new</span> PieChart.<span style="color: #006633;">Data</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Pears&quot;</span>, <span style="color: #cc66cc;">22</span><span style="color: #009900;">&#41;</span>,
                <span style="color: #000000; font-weight: bold;">new</span> PieChart.<span style="color: #006633;">Data</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Apples&quot;</span>, <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> PieChart chart <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PieChart<span style="color: #009900;">&#40;</span>pieChartData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        chart.<span style="color: #006633;">setTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Imported Fruits&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agroup+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Group</span></a><span style="color: #009900;">&#41;</span> scene.<span style="color: #006633;">getRoot</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>chart<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        stage.<span style="color: #006633;">setScene</span><span style="color: #009900;">&#40;</span>scene<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        stage.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        launch<span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Lo compilamos y corremos:</p>

<div class="wp_codebox"><table><tr id="p310925"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p3109code25"><pre class="bash" style="font-family:monospace;">Macintosh:javafx josevnz$ <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">CLASSPATH</span>=<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>Shared<span style="color: #000000; font-weight: bold;">/</span>javafx-sdk2.0.2-beta<span style="color: #000000; font-weight: bold;">//</span>rt<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>jfxrt.jar:.
Macintosh:javafx josevnz$ javac PieChartSample.java <span style="color: #660033;">-d</span> .
Macintosh:javafx josevnz$ java PieChartSample</pre></td></tr></table></div>

<p><a href="http://kodegeek.com/blog/wp-content/uploads/2011/10/Screen-Shot-2011-10-09-at-9.19.06-PM.png"><img src="http://kodegeek.com/blog/wp-content/uploads/2011/10/Screen-Shot-2011-10-09-at-9.19.06-PM.png" alt="JavaFX Pie chart" title="JavaFX Pie chart" width="612" height="604" class="alignnone size-full wp-image-3114" />JavaFX gráfico de torta en acción<br />
</a></p>
<p>Así que traté de convertir este sencillo código a Jython:</p>

<div class="wp_codebox"><table><tr id="p310926"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code" id="p3109code26"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env jython</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: black;">application</span> <span style="color: #ff7700;font-weight:bold;">import</span> Application
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: #dc143c;">collections</span> <span style="color: #ff7700;font-weight:bold;">import</span> FXCollections
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: #dc143c;">collections</span> <span style="color: #ff7700;font-weight:bold;">import</span> ObservableList
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: black;">scene</span> <span style="color: #ff7700;font-weight:bold;">import</span> Scene
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: black;">stage</span> <span style="color: #ff7700;font-weight:bold;">import</span> Stage
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: black;">scene</span>.<span style="color: black;">chart</span> <span style="color: #ff7700;font-weight:bold;">import</span> PieChart
<span style="color: #ff7700;font-weight:bold;">from</span> javafx.<span style="color: black;">scene</span> <span style="color: #ff7700;font-weight:bold;">import</span> Group
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> PieChartSample<span style="color: black;">&#40;</span>Application<span style="color: black;">&#41;</span>:
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> start<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, stage<span style="color: black;">&#41;</span>:
        scene = Scene<span style="color: black;">&#40;</span>Group<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        stage.<span style="color: black;">setTitle</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Imported Fruits&quot;</span><span style="color: black;">&#41;</span>
        stage.<span style="color: black;">setWidth</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">500</span><span style="color: black;">&#41;</span>
        stage.<span style="color: black;">setHeight</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">500</span><span style="color: black;">&#41;</span>
&nbsp;
        pieChartData = FXCollections.<span style="color: black;">observableArrayList</span><span style="color: black;">&#40;</span>
                PieChart.<span style="color: black;">Data</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Grapefruit&quot;</span>, <span style="color: #ff4500;">13</span><span style="color: black;">&#41;</span>,
                PieChart.<span style="color: black;">Data</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Oranges&quot;</span>, <span style="color: #ff4500;">25</span><span style="color: black;">&#41;</span>,
                PieChart.<span style="color: black;">Data</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Plums&quot;</span>, <span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span>,
                PieChart.<span style="color: black;">Data</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Pears&quot;</span>, <span style="color: #ff4500;">22</span><span style="color: black;">&#41;</span>,
                PieChart.<span style="color: black;">Data</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Apples&quot;</span>, <span style="color: #ff4500;">30</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        chart = PieChart<span style="color: black;">&#40;</span>pieChartData<span style="color: black;">&#41;</span>
        chart.<span style="color: black;">setTitle</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Imported Fruits&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        scene.<span style="color: black;">getRoot</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">getChildren</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">add</span><span style="color: black;">&#40;</span>chart<span style="color: black;">&#41;</span>
        stage.<span style="color: black;">setScene</span><span style="color: black;">&#40;</span>scene<span style="color: black;">&#41;</span>
        stage.<span style="color: black;">show</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
        PieChartSample<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">launch</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Pero al correrlo me se queja que no estoy extendiendo bien la clase &#8216;Aplication&#8217; y por eso falla:</p>

<div class="wp_codebox"><table><tr id="p310927"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p3109code27"><pre class="bash" style="font-family:monospace;">Macintosh:javafx josevnz$ .<span style="color: #000000; font-weight: bold;">/</span>piechart.py 
<span style="color: #000000; font-weight: bold;">*</span>sys-package-mgr<span style="color: #000000; font-weight: bold;">*</span>: can<span style="color: #ff0000;">'t create package cache dir, '</span><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>Shared<span style="color: #000000; font-weight: bold;">/</span>jython2.5.2<span style="color: #000000; font-weight: bold;">/</span>cachedir<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #ff0000;">'
Traceback (most recent call last):
  File &quot;./piechart.py&quot;, line 36, in &lt;module&gt;
    PieChartSample().launch(sys.argv[1:])
	at javafx.application.Application.launch(Application.java:186)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
&nbsp;
java.lang.RuntimeException: java.lang.RuntimeException: Error: class sun.reflect.NativeMethodAccessorImpl is not a subclass of javafx.application.Application
&nbsp;
&lt;/module&gt;</span></pre></td></tr></table></div>

<p>No tengo ni idea en donde esta el error, ¿alguno de ustedes tiene una pista? De verdad me muero de ganas por usar JavaFX con Jython, ya otros han tenido éxito similar con <a href="http://download.oracle.com/javafx/2.0/jruby/jfxpub-jruby.htm">JRuby</a> y <a href="http://groovy.codehaus.org/GroovyFX">Groovy</a>.</p>
<p>Amanecerá y veremos.</p>
<p><strong>Actualización</strong>: De la lista de Jython me llegaron muchas sugerencias, al final Weiqi Gao encontró cual era el verdadero problema y esta es la solución:</p>

<div class="wp_codebox"><table><tr id="p310928"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p3109code28"><pre class="java" style="font-family:monospace;"># The key to happiness in JavaFX <span style="color: #339933;">+</span> Jython is <span style="color: #000000; font-weight: bold;">this</span><span style="color: #339933;">:</span>
<span style="color: #000000; font-weight: bold;">if</span> __name__ <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;__main__&quot;</span><span style="color: #339933;">:</span>
    Application.<span style="color: #006633;">launch</span><span style="color: #009900;">&#40;</span>PieChartSample<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000000; font-weight: bold;">class</span>, sys.<span style="color: #006633;">argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>La explicación detallada a continuación:</p>
<blockquote><p>
The trick is with the last line of code that launches the application, which is accomplished with the javafx.application.Application.launch() method.  There are two overloaded versions of this method:</p>

<div class="wp_codebox"><table><tr id="p310929"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p3109code29"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> launch<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>and</p>

<div class="wp_codebox"><table><tr id="p310930"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p3109code30"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> launch<span style="color: #009900;">&#40;</span>Class<span style="color: #339933;">&lt;</span> <span style="color: #339933;">?</span> <span style="color: #000000; font-weight: bold;">extends</span> Application<span style="color: #339933;">&gt;</span> appClass, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The first version must be called from a method in a class that extends Application, which is not the case in the above python code.  So we have to use the second version.</p>
<p>The idiom for using the first version of launch() in Java is the following:</p>

<div class="wp_codebox"><table><tr id="p310931"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p3109code31"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Foo <span style="color: #000000; font-weight: bold;">extends</span> Application <span style="color: #009900;">&#123;</span>
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> start<span style="color: #009900;">&#40;</span>Stage stage<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// build the scene graph and show it</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      Application.<span style="color: #006633;">launch</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The idiom for using the second version of launch() in Java is the following:</p>

<div class="wp_codebox"><table><tr id="p310932"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p3109code32"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Foo <span style="color: #000000; font-weight: bold;">extends</span> Application <span style="color: #009900;">&#123;</span>
  @Override
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> start<span style="color: #009900;">&#40;</span>Stage stage<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// build the scene graph and show it</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Launcher <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Application.<span style="color: #006633;">launch</span><span style="color: #009900;">&#40;</span>Foo.<span style="color: #000000; font-weight: bold;">class</span>, args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>There is an inefficiency in my python code in that I instantiated PieChartSample once only to get its class.  I think there is a better way of doing it but can&#8217;t think of how at the moment.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2011/10/09/jython-javafx-comienzo-duro/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Es el tiempo de recuperación, idiota</title>
		<link>http://kodegeek.com/blog/2011/09/29/es-el-tiempo-de-recuperacion-idiota/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=es-el-tiempo-de-recuperacion-idiota</link>
		<comments>http://kodegeek.com/blog/2011/09/29/es-el-tiempo-de-recuperacion-idiota/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 10:32:51 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[kodegeek]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[vida sana]]></category>
		<category><![CDATA[correr carera 5k recuperacion recovery race]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=3072</guid>
		<description><![CDATA[O algo así es como dice el articulo que apareció en la revista del mes de Octubre del 2011 &#8216;Running Times&#8217;, del atleta y escritor Peter Magil;. Allí el nos muestra como calcular cuanto descansar después de un entrenamiento usando las tablas creadas por el científico Tom Schwarts. Mi implementación en Python a continuación: 1 [...]]]></description>
			<content:encoded><![CDATA[<p>O algo así es como dice el articulo que apareció en la revista del mes de Octubre del 2011 &#8216;Running Times&#8217;, del atleta y escritor Peter Magil;. Allí el nos muestra como calcular cuanto descansar después de un entrenamiento usando las tablas creadas por el científico Tom Schwarts.</p>
<p>Mi implementación en Python a continuación:</p>

<div class="wp_codebox"><table><tr id="p307236"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
</pre></td><td class="code" id="p3072code36"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #808080; font-style: italic;"># Calculate days of recovery after a race. Based on the article appeared on the Running times magazine </span>
<span style="color: #808080; font-style: italic;"># &quot;It's the Recovery Stupid&quot; by Pete Magill, using Tom Schwartz tables</span>
<span style="color: #808080; font-style: italic;"># author: josevnz@kodegeek.com</span>
<span style="color: #808080; font-style: italic;"># http://kodegeek.com/blog</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Recovery:
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
                <span style="color: #008000;">self</span>.__ages = <span style="color: black;">&#123;</span> <span style="color: #483d8b;">'20'</span>:<span style="color: #ff4500;">0</span>, <span style="color: #483d8b;">'30'</span>:<span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'40'</span>:<span style="color: #ff4500;">2</span>, <span style="color: #483d8b;">'50'</span>:<span style="color: #ff4500;">3</span>, <span style="color: #483d8b;">'60'</span>:<span style="color: #ff4500;">4</span>, <span style="color: #483d8b;">'70'</span>:<span style="color: #ff4500;">5</span>, <span style="color: #483d8b;">'80'</span>:<span style="color: #ff4500;">6</span> <span style="color: black;">&#125;</span>
                <span style="color: #008000;">self</span>.__fitnessLevel = <span style="color: black;">&#123;</span> <span style="color: #483d8b;">'LOW'</span>:<span style="color: #ff4500;">0</span>, <span style="color: #483d8b;">'MEDIUM'</span>:<span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'HIGH'</span>:<span style="color: #ff4500;">2</span> <span style="color: black;">&#125;</span>
                <span style="color: #008000;">self</span>.__daysBetweenWorkouts = <span style="color: black;">&#91;</span>
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">4.0</span>, <span style="color: #ff4500;">3.0</span>, <span style="color: #ff4500;">2.5</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">5.0</span>, <span style="color: #ff4500;">4.0</span>, <span style="color: #ff4500;">3.0</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">6.0</span>, <span style="color: #ff4500;">4.5</span>, <span style="color: #ff4500;">3.5</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">7.0</span>, <span style="color: #ff4500;">5.0</span>, <span style="color: #ff4500;">4.0</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">7.5</span>, <span style="color: #ff4500;">6.0</span>, <span style="color: #ff4500;">4.5</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">8.0</span>, <span style="color: #ff4500;">6.5</span>, <span style="color: #ff4500;">5.0</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">9.0</span>, <span style="color: #ff4500;">7.0</span>, <span style="color: #ff4500;">5.5</span> <span style="color: black;">&#93;</span>
                <span style="color: black;">&#93;</span>
                <span style="color: #008000;">self</span>.__races = <span style="color: black;">&#123;</span> <span style="color: #483d8b;">'5K'</span>:<span style="color: #ff4500;">0</span>, <span style="color: #483d8b;">'8K'</span>:<span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'10K'</span>:<span style="color: #ff4500;">2</span>, <span style="color: #483d8b;">'15K'</span>:<span style="color: #ff4500;">3</span>, <span style="color: #483d8b;">'1/2 Mar'</span>:<span style="color: #ff4500;">4</span>, <span style="color: #483d8b;">'Mar'</span>:<span style="color: #ff4500;">5</span> <span style="color: black;">&#125;</span>
                <span style="color: #008000;">self</span>.__intensityWorkout = <span style="color: black;">&#123;</span> <span style="color: #483d8b;">'EASY'</span>:<span style="color: #ff4500;">0</span>, <span style="color: #483d8b;">'MEDIUM'</span>:<span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'HARD'</span>:<span style="color: #ff4500;">2</span> <span style="color: black;">&#125;</span>
                <span style="color: #008000;">self</span>.__recoveryDaysAfterRace = <span style="color: black;">&#91;</span>
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">2</span>, <span style="color: #ff4500;">3</span>, <span style="color: #ff4500;">5</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">3</span>, <span style="color: #ff4500;">5</span>, <span style="color: #ff4500;">8</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">3.5</span>, <span style="color: #ff4500;">6</span>, <span style="color: #ff4500;">9</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">4</span>, <span style="color: #ff4500;">7</span>, <span style="color: #ff4500;">11</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">5.5</span>, <span style="color: #ff4500;">9</span>, <span style="color: #ff4500;">14</span> <span style="color: black;">&#93;</span>,
                        <span style="color: black;">&#91;</span> <span style="color: #ff4500;">9</span>, <span style="color: #ff4500;">17</span>, <span style="color: #ff4500;">26</span> <span style="color: black;">&#93;</span>
                <span style="color: black;">&#93;</span>
                <span style="color: #008000;">self</span>.__adjustment = <span style="color: black;">&#123;</span> <span style="color: #483d8b;">'20'</span>:<span style="color: #ff4500;">1.0</span>, <span style="color: #483d8b;">'30'</span>:<span style="color: #ff4500;">1.1</span>, <span style="color: #483d8b;">'40'</span>:<span style="color: #ff4500;">1.2</span> , <span style="color: #483d8b;">'50'</span>:<span style="color: #ff4500;">1.3</span>, <span style="color: #483d8b;">'60'</span>:<span style="color: #ff4500;">1.4</span>, <span style="color: #483d8b;">'70'</span>:<span style="color: #ff4500;">1.5</span>, <span style="color: #483d8b;">'80'</span>:<span style="color: #ff4500;">1.6</span> <span style="color: black;">&#125;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> getAgeBracket<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, age<span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">try</span>:
                        dAge = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>age<span style="color: black;">&#41;</span>
                        <span style="color: #ff7700;font-weight:bold;">if</span> dAge <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">0</span>:
                                <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #008000;">Exception</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Invalid age value: %s&quot;</span> <span style="color: #66cc66;">%</span> age<span style="color: black;">&#41;</span>
                        <span style="color: #ff7700;font-weight:bold;">for</span> bracket <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#91;</span> <span style="color: #ff4500;">20</span>, <span style="color: #ff4500;">30</span>, <span style="color: #ff4500;">40</span>, <span style="color: #ff4500;">40</span>, <span style="color: #ff4500;">50</span>, <span style="color: #ff4500;">70</span>, <span style="color: #ff4500;">80</span> <span style="color: black;">&#93;</span>:
                                <span style="color: #ff7700;font-weight:bold;">if</span> dAge <span style="color: #66cc66;">&gt;</span>= bracket <span style="color: #ff7700;font-weight:bold;">and</span> dAge <span style="color: #66cc66;">&lt;</span> = <span style="color: black;">&#40;</span>bracket + <span style="color: #ff4500;">9</span><span style="color: black;">&#41;</span>:
                                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>bracket<span style="color: black;">&#41;</span>
                        <span style="color: #808080; font-style: italic;"># &gt; 80 years</span>
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">80</span>
                <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: black;">&#40;</span><span style="color: #008000;">Exception</span><span style="color: black;">&#41;</span>, exp:
                        <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #008000;">Exception</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Invalid age: %s&quot;</span> <span style="color: #66cc66;">%</span> age<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> getDaysBetweenWorkouts<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, age, level<span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">try</span>:
                        bracket = <span style="color: #008000;">self</span>.<span style="color: black;">getAgeBracket</span><span style="color: black;">&#40;</span>age<span style="color: black;">&#41;</span>
                        dBracket = <span style="color: #008000;">self</span>.__ages<span style="color: black;">&#91;</span>bracket<span style="color: black;">&#93;</span>
                        intensity = <span style="color: #008000;">self</span>.__fitnessLevel<span style="color: black;">&#91;</span>level<span style="color: black;">&#93;</span>
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__daysBetweenWorkouts<span style="color: black;">&#91;</span>dBracket<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>intensity<span style="color: black;">&#93;</span> <span style="color: #66cc66;">*</span> <span style="color: #008000;">self</span>.__adjustment<span style="color: black;">&#91;</span>bracket<span style="color: black;">&#93;</span>
                <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: black;">&#40;</span><span style="color: #008000;">Exception</span><span style="color: black;">&#41;</span>, exp:
                        <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #008000;">Exception</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Invalid age or level: age=%s, level=%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>age, level<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> getDaysAfterRace<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, age, race, level<span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">try</span>:
                        bracket = <span style="color: #008000;">self</span>.<span style="color: black;">getAgeBracket</span><span style="color: black;">&#40;</span>age<span style="color: black;">&#41;</span>
                        dBracket = <span style="color: #008000;">self</span>.__races<span style="color: black;">&#91;</span>race<span style="color: black;">&#93;</span>
                        intensity = <span style="color: #008000;">self</span>.__intensityWorkout<span style="color: black;">&#91;</span>level<span style="color: black;">&#93;</span>
                        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__recoveryDaysAfterRace<span style="color: black;">&#91;</span>dBracket<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>intensity<span style="color: black;">&#93;</span> <span style="color: #66cc66;">*</span> <span style="color: #008000;">self</span>.__adjustment<span style="color: black;">&#91;</span>bracket<span style="color: black;">&#93;</span>
                <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: black;">&#40;</span><span style="color: #008000;">Exception</span><span style="color: black;">&#41;</span>, exp:
                        <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #008000;">Exception</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Invalid age race type or level: age=%s, race=%s, level=%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>age, race, level<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
        recovery = Recovery<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        arg = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>
        days = <span style="color: #ff4500;">0</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>arg<span style="color: black;">&#41;</span> == <span style="color: #ff4500;">2</span>:
                days = recovery.<span style="color: black;">getDaysBetweenWorkouts</span><span style="color: black;">&#40;</span>arg<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, arg<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Days: %2.2f, for age: '%s' and level: '%s'&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>days, arg<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, arg<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>arg<span style="color: black;">&#41;</span> == <span style="color: #ff4500;">3</span>:
                days = recovery.<span style="color: black;">getDaysAfterRace</span><span style="color: black;">&#40;</span>arg<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, arg<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, arg<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Days: %2.2f, for age: '%s' and level: '%s', race=%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>days, arg<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, arg<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>, arg<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
                <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">192</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># &quot;com/kodegeek/fitness/recoveryrun.py&quot; 76L, 2539C written</span></pre></td></tr></table></div>

<p>Así que por ejemplo, si corremos una carrera de 5K con todo y tenemos 35 años de edad:</p>

<div class="wp_codebox"><table><tr id="p307237"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p3072code37"><pre class="bash" style="font-family:monospace;">Macintosh:python josevnz$ .<span style="color: #000000; font-weight: bold;">/</span>com<span style="color: #000000; font-weight: bold;">/</span>kodegeek<span style="color: #000000; font-weight: bold;">/</span>fitness<span style="color: #000000; font-weight: bold;">/</span>recoveryrun.py <span style="color: #000000;">35</span> 5K HARD
Days: <span style="color: #000000;">5.50</span>, <span style="color: #000000; font-weight: bold;">for</span> age: <span style="color: #ff0000;">'35'</span> and level: <span style="color: #ff0000;">'HARD'</span>, <span style="color: #007800;">race</span>=5K
Macintosh:python josevnz$</pre></td></tr></table></div>

<p>¿Y si no es una carrera, pero un entrenamiento fuerte y soy medianamente resistente?</p>

<div class="wp_codebox"><table><tr id="p307238"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p3072code38"><pre class="bash" style="font-family:monospace;">Macintosh:python josevnz$ .<span style="color: #000000; font-weight: bold;">/</span>com<span style="color: #000000; font-weight: bold;">/</span>kodegeek<span style="color: #000000; font-weight: bold;">/</span>fitness<span style="color: #000000; font-weight: bold;">/</span>recoveryrun.py <span style="color: #000000;">35</span> MEDIUM
Days: <span style="color: #000000;">4.40</span>, <span style="color: #000000; font-weight: bold;">for</span> age: <span style="color: #ff0000;">'35'</span> and level: <span style="color: #ff0000;">'MEDIUM'</span>
Macintosh:python josevnz$</pre></td></tr></table></div>

<p>Por cierto, hoy es mi día de descanso entre entrenamientos. Así que es hora de ejercitar el lado Geek un poquito. Estoy pensando en abrir un nuevo proyecto de código abierto para ir dejando estos pedazos de código relacionados con correr y ejercicios de resistencia. ¿Les suena buena idea?</p>
<p>Bueno, hasta la próxima entrega.</p>
<p>&#8211;José</p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2011/09/29/es-el-tiempo-de-recuperacion-idiota/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2011 Komen Greater NYC Race for The Cure</title>
		<link>http://kodegeek.com/blog/2011/09/07/2011-komen-greater-nyc-race-for-the-cure/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=2011-komen-greater-nyc-race-for-the-cure</link>
		<comments>http://kodegeek.com/blog/2011/09/07/2011-komen-greater-nyc-race-for-the-cure/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 01:31:14 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=3044</guid>
		<description><![CDATA[Bueno, ya dejando atrás la carrera del Yankee Stadium ahora me lanzo con quizas la última carrera de 5 kilómetros de este año para mi. El recorrido está aquí, es una carrera sin tiempo oficial y por diversión. La idea es colaborar contra el cáncer de seno. Me estoy recuperando aún de la lesión de [...]]]></description>
			<content:encoded><![CDATA[<p>Bueno, ya dejando atrás la carrera del <a href="http://kodegeek.com/blog/2011/08/07/segunda-carrera-de-5k-esta-vez-en-el-yankee-stadium/">Yankee Stadium</a> ahora me lanzo con quizas la última <a href="http://www.komennyc.org">carrera de 5 kilómetros de este año para mi</a>.</p>
<p>El recorrido está <a href="http://www.komennyc.org/site/PageServer?pagename=TR2011_race_map">aquí</a>, es una carrera sin tiempo oficial y por diversión. La idea es colaborar contra el cáncer de seno.</p>
<p>Me estoy recuperando aún de la lesión de la carrera anterior. Sin embargo las medicinas y el calzado han hecho una gran diferencia. No creo que mejore los tiempos (poco tiempo para entrenar, más recuperación), pero al menos espero mantener lo que hice la última carrera.</p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2011/09/07/2011-komen-greater-nyc-race-for-the-cure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>¿Corriendo muy rápido al principio de una carrera? No necesariamente</title>
		<link>http://kodegeek.com/blog/2011/07/12/%c2%bfcorriendo-muy-rapido-al-principio-de-una-carrera-no-necesariamente/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25c2%25bfcorriendo-muy-rapido-al-principio-de-una-carrera-no-necesariamente</link>
		<comments>http://kodegeek.com/blog/2011/07/12/%c2%bfcorriendo-muy-rapido-al-principio-de-una-carrera-no-necesariamente/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 08:56:48 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[programación]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[vida sana]]></category>
		<category><![CDATA[5k python running correr]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=2972</guid>
		<description><![CDATA[En plena Copa America, y yo ahora corriendo luciendo los colores de la Vino Tinto. En preparación para mi carrera en el Yankee Stadium, me conseguí un excelente articulo en el sitio web de RunnersWorld, el cual explica que tan rápido hay que ir en la primera milla para tener una ventaja más que decente, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/josevnz/5925345789/" title="Franela Vino Tinto 2011 - Edición Copa America by josevnz, on Flickr"><img src="http://farm7.static.flickr.com/6125/5925345789_10538bfcfd.jpg" width="375" height="500" alt="Franela Vino Tinto 2011 - Edición Copa America"/><br />
En plena Copa America, y yo ahora corriendo luciendo los colores de la Vino Tinto.</a></p>
<p>En preparación <a href="http://kodegeek.com/blog/2011/06/12/nueva-carrera-de-5-kilometros-%c2%a1esta-vez-en-el-yankee-stadium/">para mi carrera en el Yankee Stadium</a>, me conseguí un excelente articulo en el sitio web de <a href="http://www.runnersworld.com/article/0,7120,s6-238-244--11404-2-1-2,00.html" title="RunnersWorld">RunnersWorld</a>, el cual explica que tan rápido hay que ir en la primera milla para tener una ventaja más que decente, sin quemarse después en el resto de la carrera. Esto se aplica para carreras de 5 kilómetros, el código es muy fácil de seguir:</p>

<div class="wp_codebox"><table><tr id="p297240"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="code" id="p2972code40"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #808080; font-style: italic;"># author: josevnz@kodegeek.com</span>
<span style="color: #808080; font-style: italic;"># http://kodegeek.com/blog</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #483d8b;">''</span><span style="color: #483d8b;">'
Formula taken from:
http://www.runnersworld.com/article/0,7120,s6-238-244--11404-2-1-2,00.html&quot;To
figure your 6 percent faster first mile: First convert your best 5-K
time to all seconds by multiplying the minutes by 60 and adding the
seconds. Say, you'</span>ve run <span style="color: #ff4500;">24</span>:<span style="color: #ff4500;">19</span>. <span style="color: black;">That</span> would be <span style="color: #ff4500;">24</span> x <span style="color: #ff4500;">60</span>, + <span style="color: #ff4500;">19</span> = <span style="color: #ff4500;">1459</span>.
<span style="color: black;">Now</span> divide this total by <span style="color: #ff4500;">3.1</span> <span style="color: black;">&#40;</span>miles <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #ff4500;">5</span>-K<span style="color: black;">&#41;</span> to get your average mile
<span style="color: #dc143c;">time</span> <span style="color: #ff7700;font-weight:bold;">in</span> seconds <span style="color: black;">&#40;</span><span style="color: #ff4500;">1459</span>/<span style="color: #ff4500;">3.1</span> = <span style="color: #ff4500;">470.6</span>, <span style="color: #ff7700;font-weight:bold;">or</span> about <span style="color: #ff4500;">7</span>:<span style="color: #ff4500;">51</span> pace<span style="color: black;">&#41;</span>. <span style="color: black;">Next</span> multiply
this figure by .94 to get a figure that<span style="color: #483d8b;">'s 6 percent faster (470.6 x
.94 = 4
42.36). Now divide by 60 to return the figure to minutes:seconds
(442.36/60 = 7:22). So you should aim to run your first mile in 7:22.
Good l
uck!&quot;
'</span><span style="color: #483d8b;">''</span>
<span style="color: #ff7700;font-weight:bold;">def</span> calc_time<span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span><span style="color: black;">&#41;</span>:
       <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span><span style="color: black;">&#41;</span> == <span style="color: #ff4500;">0</span>:
           <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span>
       <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">time</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
               m = <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'(<span style="color: #000099; font-weight: bold;">\d</span>+):(<span style="color: #000099; font-weight: bold;">\d</span>+)'</span>, <span style="color: #dc143c;">time</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
               <span style="color: #008000;">min</span> = m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
               sec = m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
               <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">min</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>sec<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
                       secs = <span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #008000;">min</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">60.0</span><span style="color: black;">&#41;</span> + <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>sec<span style="color: black;">&#41;</span>
                       secs /= <span style="color: #ff4500;">3.1</span>
                       secs <span style="color: #66cc66;">*</span>= <span style="color: #ff4500;">0.94</span>
                       mins = secs / <span style="color: #ff4500;">60.0</span>
                       n = <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'(<span style="color: #000099; font-weight: bold;">\d</span>+)<span style="color: #000099; font-weight: bold;">\.</span>(<span style="color: #000099; font-weight: bold;">\d</span>+)'</span>, <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>mins<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
                       realsecs = <span style="color: #483d8b;">&quot;0.&quot;</span> + n.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
                       realsecs = <span style="color: #008000;">round</span><span style="color: black;">&#40;</span><span style="color: #008000;">float</span><span style="color: black;">&#40;</span>realsecs<span style="color: black;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">60</span><span style="color: black;">&#41;</span>
                       <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">str</span><span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>mins<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;:&quot;</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>realsecs<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
       <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
       secs = calc_time<span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
       <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Pace for first mile in 5K: %s&quot;</span> <span style="color: #66cc66;">%</span> secs</pre></td></tr></table></div>

<p>Por ejemplo, si usted hizo 22:30 en su última carrera (Bueno, eso lo hice yo <img src='http://kodegeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ):</p>
<pre languaje="Bash">
Macintosh:python josevnz$ ./fastmile5k.py 22:30
Pace for first mile in 5K: 6:49
Macintosh:python josevnz$
</pre>
<p>¿Qué piensa usted, correr rápido al principio o ir lento y explotar gradualmente?</p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2011/07/12/%c2%bfcorriendo-muy-rapido-al-principio-de-una-carrera-no-necesariamente/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nueva carrera de 5 kilómetros, ¡esta vez en el Yankee Stadium!</title>
		<link>http://kodegeek.com/blog/2011/06/12/nueva-carrera-de-5-kilometros-%c2%a1esta-vez-en-el-yankee-stadium/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nueva-carrera-de-5-kilometros-%25c2%25a1esta-vez-en-el-yankee-stadium</link>
		<comments>http://kodegeek.com/blog/2011/06/12/nueva-carrera-de-5-kilometros-%c2%a1esta-vez-en-el-yankee-stadium/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 13:01:02 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[5 kilómetros]]></category>
		<category><![CDATA[5k]]></category>
		<category><![CDATA[cancer research]]></category>
		<category><![CDATA[carrera]]></category>
		<category><![CDATA[correr]]></category>
		<category><![CDATA[fitness]]></category>
		<category><![CDATA[kodegeek]]></category>
		<category><![CDATA[yankee stadium]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=2951</guid>
		<description><![CDATA[Amigos y lectores del blog, este 7 de Agosto voy a correr la carrera de 5K en el Yankee Stadium en el estado de New York; Los fondos recolectados van a ser utilizados para estudios de cura contra el Cancer. Yo estoy recaudando fondos como parte de la carrera, los invito a que donen cualquier [...]]]></description>
			<content:encoded><![CDATA[<p><iframe width="853" height="510" src="http://www.youtube.com/embed/804ZxSf3WvM?hd=1" frameborder="0" allowfullscreen></iframe></p>
<p>Amigos y lectores del blog, este 7 de Agosto <a href="http://www.damonrunyon.org/yankeestadium">voy a correr la carrera de 5K en el Yankee Stadium en el estado de New York</a>; Los fondos recolectados van a ser utilizados para estudios de cura contra el Cancer.</p>
<p>Yo estoy recaudando fondos como parte de la carrera,<a href="http://Runyon5K.kintera.org/josevnz"> los invito a que donen cualquier cantidad</a> ya que es para una buena causa.</p>
<p>Un abrazo y gracias de antemano,</p>
<p>&#8211;José</p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2011/06/12/nueva-carrera-de-5-kilometros-%c2%a1esta-vez-en-el-yankee-stadium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>¿Como calcular cuantas calorias al día se deben consumir, usando Python?</title>
		<link>http://kodegeek.com/blog/2011/05/30/%c2%bfcomo-calcular-cuantas-calorias-al-dia-se-deben-consumir-usando-python/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25c2%25bfcomo-calcular-cuantas-calorias-al-dia-se-deben-consumir-usando-python</link>
		<comments>http://kodegeek.com/blog/2011/05/30/%c2%bfcomo-calcular-cuantas-calorias-al-dia-se-deben-consumir-usando-python/#comments</comments>
		<pubDate>Mon, 30 May 2011 17:30:58 +0000</pubDate>
		<dc:creator>josevnz</dc:creator>
				<category><![CDATA[kodegeek]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[vida sana]]></category>
		<category><![CDATA[calorias proteinas grasa fat carbs protein calories]]></category>

		<guid isPermaLink="false">http://kodegeek.com/blog/?p=2926</guid>
		<description><![CDATA[Está bien, es una excusa barata para usar Python para calcular una formula trivial . Sin embargo la idea es útil: Usted quiere saber cuantas calorías debe consumir al día para mantener un peso saludable Sigue la proporción 40/ 30 / 30: %40 de proteínas, %30 de hidratos de carbono y %30 de grasas Usted [...]]]></description>
			<content:encoded><![CDATA[<p>Está bien, es una excusa barata para usar Python para calcular una formula trivial <img src='http://kodegeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Sin embargo la idea es útil:</p>
<ul>
<li>Usted quiere saber cuantas calorías debe consumir al día para mantener un peso saludable</li>
<li>Sigue la proporción 40/ 30 / 30: %40 de proteínas, %30 de hidratos de carbono y %30 de grasas</li>
<li>Usted come 6 veces al día, para mantener su metabolismo activo</li>
</ul>
<p>Por ejemplo, la salida del programa para una persona que pesa 196 libras:</p>

<div class="wp_codebox"><table><tr id="p292644"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p2926code44"><pre class="bash" style="font-family:monospace;">Macintosh:python josevnz$ .<span style="color: #000000; font-weight: bold;">/</span>calories.py 
Please provide your weight <span style="color: #000000; font-weight: bold;">in</span> LB:
<span style="color: #000000;">196</span>
Daily calories <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #000000;">196</span> lb: <span style="color: #000000;">2640</span>. Grams of Protein: <span style="color: #000000;">44</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">264</span>, Grams of Carbs: <span style="color: #000000;">33</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">198</span>, Grams of Fat: <span style="color: #000000;">14</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">88</span>
Macintosh:python josevnz$</pre></td></tr></table></div>

<p>programa que llama a la clase en Python:</p>

<div class="wp_codebox"><table><tr id="p292645"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p2926code45"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #808080; font-style: italic;"># Author: josevnz at kodegeek dot com</span>
<span style="color: #808080; font-style: italic;"># http://kodegeek.com/blog</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">sys</span> <span style="color: #ff7700;font-weight:bold;">import</span> stdin
<span style="color: #ff7700;font-weight:bold;">from</span> com.<span style="color: black;">kodegeek</span>.<span style="color: black;">fitness</span>.<span style="color: black;">nutrition</span> <span style="color: #ff7700;font-weight:bold;">import</span> CalorieNeeds
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Please provide your weight in LB:&quot;</span>
        weight = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>stdin.<span style="color: #dc143c;">readline</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        c = CalorieNeeds<span style="color: black;">&#40;</span>weight<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s&quot;</span> <span style="color: #66cc66;">%</span> c</pre></td></tr></table></div>

<p>Y la clase en Python que hace el trabajo &#8216;pesado&#8217;:</p>

<div class="wp_codebox"><table><tr id="p292646"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code" id="p2926code46"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #ff7700;font-weight:bold;">class</span> CalorieNeeds:
        <span style="color: #483d8b;">&quot;&quot;&quot;Simple class to determine the daily calorie intake. josevnz at kodegeek dot com&quot;&quot;&quot;</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, weight<span style="color: black;">&#41;</span>:
&nbsp;
                <span style="color: #008000;">self</span>.<span style="color: black;">weight</span> = weight
&nbsp;
                <span style="color: #808080; font-style: italic;"># Calculate daily calorie needs</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">calorieIntake</span> = <span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">weight</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">15</span><span style="color: black;">&#41;</span> - <span style="color: #ff4500;">300</span>
&nbsp;
                <span style="color: #808080; font-style: italic;"># Calculate the 40/30/30 macronutriend breakdown</span>
                <span style="color: #808080; font-style: italic;"># Proteins</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">proteinsGramsDay</span> = <span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">calorieIntake</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">0.40</span><span style="color: black;">&#41;</span> / <span style="color: #ff4500;">4</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">proteinsGramsPerMeal</span> = <span style="color: #008000;">self</span>.<span style="color: black;">proteinsGramsDay</span> / <span style="color: #ff4500;">6</span>
&nbsp;
                <span style="color: #808080; font-style: italic;"># Carbs</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">carbGramsDay</span> = <span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">calorieIntake</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">0.30</span><span style="color: black;">&#41;</span> / <span style="color: #ff4500;">4</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">carbGramsPerMeal</span> = <span style="color: #008000;">self</span>.<span style="color: black;">carbGramsDay</span> / <span style="color: #ff4500;">6</span>
&nbsp;
                <span style="color: #808080; font-style: italic;"># Fat</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">fatGramsDay</span> = <span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">calorieIntake</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">0.30</span><span style="color: black;">&#41;</span> / <span style="color: #ff4500;">9</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">fatGramsPerMeal</span> = <span style="color: #008000;">self</span>.<span style="color: black;">fatGramsDay</span> / <span style="color: #ff4500;">6</span>
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__str__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;Daily calories for %s lb: %d. Grams of Protein: %d/%d, Grams of Carbs: %d/%d, Grams of Fat: %d/%d&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">weight</span>, <span style="color: #008000;">self</span>.<span style="color: black;">calorieIntake</span>, <span style="color: #008000;">self</span>.<span style="color: black;">proteinsGramsPerMeal</span>, <span style="color: #008000;">self</span>.<span style="color: black;">proteinsGramsDay</span>, <span style="color: #008000;">self</span>.<span style="color: black;">carbGramsPerMeal</span>, <span style="color: #008000;">self</span>.<span style="color: black;">carbGramsDay</span>, <span style="color: #008000;">self</span>.<span style="color: black;">fatGramsPerMeal</span>, <span style="color: #008000;">self</span>.<span style="color: black;">fatGramsDay</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
        <span style="color: #483d8b;">&quot;&quot;&quot;Self test code&quot;&quot;&quot;</span>
        c = CalorieNeeds<span style="color: black;">&#40;</span><span style="color: #ff4500;">158</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s&quot;</span> <span style="color: #66cc66;">%</span> c</pre></td></tr></table></div>

<p>Les dejo como ejercicio como convertir estos resultados a kilogramos, hoy tengo algo de pereza (<a href="http://sourceforge.net/projects/elangelnegro/files/Python/calories.tar.gz/download">el enlace para bajarse el código está aquí</a>) <img src='http://kodegeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>&#8211;José</p>
]]></content:encoded>
			<wfw:commentRss>http://kodegeek.com/blog/2011/05/30/%c2%bfcomo-calcular-cuantas-calorias-al-dia-se-deben-consumir-usando-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

