<?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>Juliana Peña &#187; Programming</title>
	<atom:link href="http://julianapena.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://julianapena.com</link>
	<description></description>
	<lastBuildDate>Mon, 07 May 2012 20:01:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Gchat now available in the Marketplace!</title>
		<link>http://julianapena.com/2011/09/gchat/</link>
		<comments>http://julianapena.com/2011/09/gchat/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 23:36:31 +0000</pubDate>
		<dc:creator>Juliana Peña</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[windows phone]]></category>

		<guid isPermaLink="false">http://julianapena.com/?p=1018</guid>
		<description><![CDATA[   Gchat, the awesome Google Talk client Luis and I built for Windows Phone, is now available in the Marketplace! We’ve been working on it for a long time and we’d love to know what you think. Click the button below to go to the Marketplace now and download it! We hope you enjoy using <a href="http://julianapena.com/2011/09/gchat/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p align="center"><a href="http://julianapena.com/wp-content/uploads/2011/09/screen1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="screen1" src="http://julianapena.com/wp-content/uploads/2011/09/screen1_thumb.png" alt="screen1" width="180" height="300" border="0" /></a> <a href="http://julianapena.com/wp-content/uploads/2011/09/screen4.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="screen4" src="http://julianapena.com/wp-content/uploads/2011/09/screen4_thumb.png" alt="screen4" width="180" height="300" border="0" /></a> <a href="http://julianapena.com/wp-content/uploads/2011/09/screen5.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="screen5" src="http://julianapena.com/wp-content/uploads/2011/09/screen5_thumb.png" alt="screen5" width="180" height="300" border="0" /></a></p>
<p><a href="https://github.com/lhchavez/gtalkchat">Gchat</a>, the awesome Google Talk client <a href="http://lhchavez.com/">Luis</a> and I built for Windows Phone, is now available in the Marketplace! We’ve been working on it for a long time and we’d love to know what you think.</p>
<p>Click the button below to go to the Marketplace now and download it!</p>
<p align="center"><a href="http://www.microsoft.com/windowsphone/s?appid=f9da43e4-9bbb-4a6d-842d-629bd6bdc84b"><img title="Download Gchat" src="http://julianapena.com/wp-content/uploads/c76feed4bd9b_7F78/Download-EN-Med.png" alt="Download Gchat" width="165" height="54" border="0" /></a></p>
<p>We hope you enjoy using Gchat! If you find a bug or want to suggest a new feature, please <a href="https://github.com/lhchavez/gtalkchat/issues">report it</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://julianapena.com/2011/09/gchat/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Sierpinski&#8217;s Tetrahedron!</title>
		<link>http://julianapena.com/2011/08/sierpinskis-tetrahedron/</link>
		<comments>http://julianapena.com/2011/08/sierpinskis-tetrahedron/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 16:52:51 +0000</pubDate>
		<dc:creator>Juliana Peña</dc:creator>
				<category><![CDATA[Code snippet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[school]]></category>

		<guid isPermaLink="false">http://julianapena.com/2011/08/sierpinskis-tetrahedron/</guid>
		<description><![CDATA[For my Computer Graphics class we had to do Sierpinski’s Triangle in OpenGL. As optional extra credit, we could expand it to 3D. I took up the challenge, and this was the result. It’s not perfect, but it looks really cool! As always, grab the code at Gist. Comments, forks and improvements are appreciated. :)]]></description>
			<content:encoded><![CDATA[<p><a href="http://julianapena.com/wp-content/uploads/2011/08/pyr.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="pyr" border="0" alt="pyr" src="http://julianapena.com/wp-content/uploads/2011/08/pyr_thumb.png" width="396" height="409" /></a></p>
<p>For my Computer Graphics class we had to do Sierpinski’s Triangle in OpenGL. As optional extra credit, we could expand it to 3D. I took up the challenge, and this was the result. It’s not perfect, but it looks really cool!</p>
<p>As always, <a href="https://gist.github.com/1168494">grab the code at Gist</a>. Comments, forks and improvements are appreciated. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://julianapena.com/2011/08/sierpinskis-tetrahedron/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Lunar Landing Reactive Agent made with WPF</title>
		<link>http://julianapena.com/2011/02/lunar-landing-reactive-agent-made-with-wpf/</link>
		<comments>http://julianapena.com/2011/02/lunar-landing-reactive-agent-made-with-wpf/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 05:08:15 +0000</pubDate>
		<dc:creator>Juliana Peña</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://julianapena.com/?p=655</guid>
		<description><![CDATA[I’ve made a very simple reactive agent that simulates an (extremely simplified) Apollo lunar module landing. You can also land it manually in the program. It was built as a project for my Intelligent Systems class in February 2010. I may expand it if I have the time. It’s built in C# and WPF and requires <a href="http://julianapena.com/2011/02/lunar-landing-reactive-agent-made-with-wpf/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://julianapena.com/wp-content/uploads/914943eccb4a_14407/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="image" src="http://julianapena.com/wp-content/uploads/914943eccb4a_14407/image_thumb.png" border="0" alt="image" width="228" height="304" /></a></p>
<p>I’ve made a very simple reactive agent that simulates an (extremely simplified) Apollo lunar module landing. You can also land it manually in the program. It was built as a project for my Intelligent Systems class in February 2010. I may expand it if I have the time.</p>
<p>It’s built in C# and <a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation">WPF</a> and requires .Net 4.0. You can <a href="http://lunarlander.codeplex.com/">download it now at Codeplex</a> or <a href="http://lunarlander.codeplex.com/SourceControl/list/changesets">get the source</a>.</p>
<p>Here’s a short video of it working:</p>
<p><iframe title="YouTube video player" width="620" height="500" src="http://www.youtube.com/embed/m3Rqb5KDBeU" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://julianapena.com/2011/02/lunar-landing-reactive-agent-made-with-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MD5 Cracker using JavaScript and Web Workers</title>
		<link>http://julianapena.com/2010/11/md5-cracker-using-javascript-and-web-workers/</link>
		<comments>http://julianapena.com/2010/11/md5-cracker-using-javascript-and-web-workers/#comments</comments>
		<pubDate>Sun, 28 Nov 2010 06:10:43 +0000</pubDate>
		<dc:creator>Juliana Peña</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://julianapena.com/2010/11/md5-cracker-using-javascript-and-web-workers/</guid>
		<description><![CDATA[I’ve made an MD5 hash brute-force cracker implemented in JavaScript using HTML5 Web Workers. It was built as a project for my Distributed Applications class in October 2010. Try it out right now Get the code at GitHub (Free under the Microsoft Public License)]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://julianapena.com/wp-content/uploads/bfff8fc70de9_150AA/image.png"><img class="aligncenter" style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; padding-top: 0px; border-width: 0px;" title="image" src="http://julianapena.com/wp-content/uploads/bfff8fc70de9_150AA/image_thumb.png" border="0" alt="image" width="335" height="365" /></a></p>
<p>I’ve made an MD5 hash brute-force cracker implemented in JavaScript using <a href="http://en.wikipedia.org/wiki/Web_Workers">HTML5 Web Workers</a>. It was built as a project for my <a href="http://homepage.cem.itesm.mx/rogomez/aplic-dist.html">Distributed Applications class</a> in October 2010.</p>
<p><a href="http://julianapena.com/md5/">Try it out right now</a></p>
<p><a href="https://gist.github.com/718644">Get the code at GitHub</a> (Free under the <a href="http://www.microsoft.com/opensource/licenses.mspx#Ms-PL">Microsoft Public License</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://julianapena.com/2010/11/md5-cracker-using-javascript-and-web-workers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DreamSpark: Software de Microsoft para desarrollo y dise&#241;o gratis para estudiantes</title>
		<link>http://julianapena.com/2010/09/eres-estudiante-descarga-software-de-microsoft-para-desarrollo-y-diseo-gratis-desde-dreamspark/</link>
		<comments>http://julianapena.com/2010/09/eres-estudiante-descarga-software-de-microsoft-para-desarrollo-y-diseo-gratis-desde-dreamspark/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 22:52:56 +0000</pubDate>
		<dc:creator>Juliana Peña</dc:creator>
				<category><![CDATA[En Español]]></category>
		<category><![CDATA[HogarGeek]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://julianapena.com/2010/09/eres-estudiante-descarga-software-de-microsoft-para-desarrollo-y-diseo-gratis-desde-dreamspark/</guid>
		<description><![CDATA[Cross-posted con Hogar Geek. DreamSpark es un sitio web en donde Microsoft hace disponible una gran parte de su colección de herramientas de diseño y desarrollo de forma completamente gratuita para estudiantes. ¿Cómo funciona? Simplemente te registras con tu cuenta de Windows Live, seleccionas tu escuela, ingresas tu correo electrónico de tu escuela, y te <a href="http://julianapena.com/2010/09/eres-estudiante-descarga-software-de-microsoft-para-desarrollo-y-diseo-gratis-desde-dreamspark/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://julianapena.com/wp-content/uploads/EresestudianteDescargasoftwaredeMicrosof_D956/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://julianapena.com/wp-content/uploads/EresestudianteDescargasoftwaredeMicrosof_D956/image_thumb.png" width="585" height="350" /></a></p>
<p><em>Cross-posted con <a href="http://www.hogargeek.com/eres-estudiante-descarga-software-de-microsoft-para-desarrollo-y-diseo-gratis-desde-dreamspark/">Hogar Geek</a>.</em></p>
<p><a href="https://www.dreamspark.com">DreamSpark</a> es un sitio web en donde Microsoft hace disponible una gran parte de su colección de herramientas de diseño y desarrollo de forma completamente gratuita para estudiantes. ¿Cómo funciona? Simplemente te registras con tu cuenta de Windows Live, seleccionas tu escuela, ingresas tu correo electrónico de tu escuela, y te enviarán un código de confirmación a este correo. Ingresa el código en la página, y ya quedará asociada tu cuenta de Windows Live con tu cuenta de la escuela. Después de esto, podrás descargar todo el software disponible en la página.</p>
<p><a href="http://julianapena.com/wp-content/uploads/EresestudianteDescargasoftwaredeMicrosof_D956/image_3.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://julianapena.com/wp-content/uploads/EresestudianteDescargasoftwaredeMicrosof_D956/image_thumb_3.png" width="199" height="258" /></a></p>
<p>Algunos de los productos disponibles gratis en DreamSpark son:</p>
<ul>
<li>Visual Studio Professional, el suite completo de desarrollo para C, C++, C#, Visual Basic.Net, y F# </li>
<li>Windows Phone SDK, el suite para desarrollo de aplicaciones móviles para Windows Phone 7 </li>
<li>Expression Studio, el suite para diseño web y de aplicaciones </li>
<li>Windows Server y SQL Server </li>
<li>XNA Game Studio, para desarrollo de juegos </li>
</ul>
<p><a href="http://julianapena.com/wp-content/uploads/EresestudianteDescargasoftwaredeMicrosof_D956/image_4.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://julianapena.com/wp-content/uploads/EresestudianteDescargasoftwaredeMicrosof_D956/image_thumb_4.png" width="499" height="235" /></a></p>
<p>Además, DreamSpark te da acceso gratuito al Windows Phone 7 Marketplace, donde podrás crear y vender aplicaciones de Windows Phone 7, lo cual normalmente tiene un costo de 100 dólares anuales. También tendrás derecho a una licencia académica de XNA para que puedas correr los juegos que tú has creado en una Xbox 360.</p>
<p><a href="http://julianapena.com/wp-content/uploads/EresestudianteDescargasoftwaredeMicrosof_D956/image_5.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://julianapena.com/wp-content/uploads/EresestudianteDescargasoftwaredeMicrosof_D956/image_thumb_5.png" width="222" height="276" /></a></p>
<p>DreamSpark también tiene contenido de entrenamiento para que puedas aprender desde cero a desarrollar juegos y aplicaciones y a usar los suites disponibles para descargas.</p>
<p>Entonces, ¿qué esperas? ¡Empieza a desarrollar y diseñar cosas sorprendentes!</p>
<p>Sitio oficial | <a href="https://www.dreamspark.com">DreamSpark</a></p>
]]></content:encoded>
			<wfw:commentRss>http://julianapena.com/2010/09/eres-estudiante-descarga-software-de-microsoft-para-desarrollo-y-diseo-gratis-desde-dreamspark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Work in progress: Windows Phone 7 Remember the Milk app, codenamed Winmilk</title>
		<link>http://julianapena.com/2010/08/work-in-progress-windows-phone-7-remember-the-milk-app-codenamed-winmilk/</link>
		<comments>http://julianapena.com/2010/08/work-in-progress-windows-phone-7-remember-the-milk-app-codenamed-winmilk/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 00:53:40 +0000</pubDate>
		<dc:creator>Juliana Peña</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[windows phone]]></category>

		<guid isPermaLink="false">http://julianapena.com/2010/08/work-in-progress-windows-phone-7-remember-the-milk-app-codenamed-winmilk/</guid>
		<description><![CDATA[UPDATE: WinMilk as been published in the WP7 marketplace!! Find out more and download it The product of many hours of hacking during SuperHappyDevHouse Mexico City, I finally have a shareable prototype of the Windows Phone 7 app I started working on back in April: A Remember the Milk client. The source code is available <a href="http://julianapena.com/2010/08/work-in-progress-windows-phone-7-remember-the-milk-app-codenamed-winmilk/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: WinMilk as been published in the WP7 marketplace!! <a href="http://julianapena.com/projects/winmilk/">Find out more and download it</a></strong></p>
<p>The product of many hours of hacking during <a href="http://shdhmc.pbworks.com/">SuperHappyDevHouse Mexico City</a>, I finally have a shareable prototype of the <a href="http://www.windowsphone7.com/">Windows Phone 7</a> app I started working on back in April: A <a href="http://www.rememberthemilk.com">Remember the Milk</a> client.</p>
<p><a href="http://julianapena.com/wp-content/uploads/WorkinprogressWindowsPhone7RemembertheMi_115CB/winmilk.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px;" title="winmilk" src="http://julianapena.com/wp-content/uploads/WorkinprogressWindowsPhone7RemembertheMi_115CB/winmilk_thumb.png" border="0" alt="winmilk" width="272" height="461" /></a></p>
<p>The source code is <a href="http://winmilk.codeplex.com/SourceControl/list/changesets">available at Codeplex</a> under the <a href="http://www.microsoft.com/opensource/licenses.mspx#Ms-PL">Microsoft Public License</a>, so take a look at it, download it, try it out, and share it! If you have a Windows Phone 7 device, please try it out on the hardware itself and tell me how it works. It’s still a very early prototype and doesn’t have much functionality yet, so use at your own risk.</p>
]]></content:encoded>
			<wfw:commentRss>http://julianapena.com/2010/08/work-in-progress-windows-phone-7-remember-the-milk-app-codenamed-winmilk/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Code snippet: Get a weather condition using Python and Google Weather API</title>
		<link>http://julianapena.com/2010/02/code-snippet-get-a-weather-condition-using-python-and-google-weather-api/</link>
		<comments>http://julianapena.com/2010/02/code-snippet-get-a-weather-condition-using-python-and-google-weather-api/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 17:09:17 +0000</pubDate>
		<dc:creator>Juliana Peña</dc:creator>
				<category><![CDATA[Code snippet]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://julianapena.com/2010/02/code-snippet-get-a-weather-condition-using-python-and-google-weather-api/</guid>
		<description><![CDATA[Here’s a simple Python code snippet for finding the weather condition of any given city using Google’s Weather API. It’s also published on GitHub if you want to clone it. import urllib2 def getWeather(city): #create google weather api url url = "http://www.google.com/ig/api?weather=" + urllib2.quote(city) try: # open google weather api url f = urllib2.urlopen(url) except: <a href="http://julianapena.com/2010/02/code-snippet-get-a-weather-condition-using-python-and-google-weather-api/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here’s a simple Python code snippet for finding the weather condition of any given city using Google’s Weather API. It’s also <a href="http://gist.github.com/308912">published on GitHub</a> if you want to clone it.</p>
<div id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:8f6cfd24-50f5-4569-a63a-46d12fc1a212" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: python;">import urllib2

def getWeather(city):

    #create google weather api url
    url = "http://www.google.com/ig/api?weather=" + urllib2.quote(city)

    try:
        # open google weather api url
        f = urllib2.urlopen(url)
    except:
        # if there was an error opening the url, return
        return "Error opening url"

    # read contents to a string
    s = f.read()

    # extract weather condition data from xml string
    weather = s.split("&lt;current_conditions&gt;&lt;condition data=\"")[-1].split("\"")[0]

    # if there was an error getting the condition, the city is invalid
    if weather == "&lt;?xml version=":
        return "Invalid city"

    #return the weather condition
    return weather

def main():
    while True:
        city = raw_input("Give me a city: ")
        weather = getWeather(city)
        print(weather)

if __name__ == "__main__":
    main()</pre>
</div>
<p><strong>Update: </strong>GitHub is awesome because it allows very easy forking. <a href="http://gist.github.com/beaumartinez">Beau Martínez</a> has made a <a href="http://gist.github.com/309222">fork</a> of my script that includes Python 3 support, XML parsing instead of RegEx searching, and temperature reporting.</p>
]]></content:encoded>
			<wfw:commentRss>http://julianapena.com/2010/02/code-snippet-get-a-weather-condition-using-python-and-google-weather-api/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to build a Chrome extension, Part 4: Background pages and scheduling requests</title>
		<link>http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-4-background-pages-and-scheduling-requests/</link>
		<comments>http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-4-background-pages-and-scheduling-requests/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 03:45:24 +0000</pubDate>
		<dc:creator>Juliana Peña</dc:creator>
				<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[extension]]></category>

		<guid isPermaLink="false">http://julianapena.com/?p=409</guid>
		<description><![CDATA[One of the most common uses for an extension is as a notifier. For example, the Google Gmail Checker, an official Google extension and the most popular one in the gallery, constantly checks your Gmail inbox for new unread mail. This functionality is easy to add into your own extension. You need to add a <a href="http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-4-background-pages-and-scheduling-requests/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the most common uses for an extension is as a notifier. For example, the <a href="https://chrome.google.com/extensions/detail/mihcahmgecmbnbcchbopgniflfhgnkff">Google Gmail Checker</a>, an official Google extension and the most popular one in the gallery, constantly checks your Gmail inbox for new unread mail.</p>
<p>This functionality is easy to add into your own extension. You need to add a background page, which is easily added by adding the background_page option to your manifest.json:</p>
<div id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:08cde715-f4bd-49b2-a7d2-ad7ff4ca5738" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: javascript;">{
	"name": "My Extension",
	...
	"background_page": "background.html",
	...
}</pre>
</div>
<p>Like almost every other component in a Chrome extension, background.html is a standard HTML file. However, it can also do things most web pages cannot, such as <a href="http://code.google.com/chrome/extensions/xhr.html">cross-origin requests</a> if permissions are correctly added to the manifest. For example, if your extension is a Gmail checker, it would need permissions to <a href="http://www.google.com">http://www.google.com</a> and <a href="https://www.google.com">https://www.google.com</a>. To add these permissions, the manifest.json would be edited to:</p>
<div id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:babaf12b-186f-4c66-a12c-a6ae946caef4" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: javascript;">{
	"name": "My Extension",
	...
	"background_page": "background.html",
	"permissions": ["http://www.google.com/", "https://www.google.com/"],
	...
}</pre>
</div>
<p>A background page runs at all times when the extension is enabled. You cannot see it, but it can modify other aspects of the extension, like setting the browser action badge. For example, the following example would set the icon badge to the number of unread items in a hypothetical service:</p>
<div id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:44a4f7d6-b513-4ff9-9f16-df573150bdc6" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: javascript;">function getUnreadItems(callback) {
	$.ajax(..., function(data) {
		process(data);
		callback(data);
	});
}

function updateBadge() {
	getUnreadItems(function(data) {
		chrome.browserAction.setBadgeText({text:data.unreadItems});
	});
}</pre>
</div>
<p>So now you can make a request, but how can you schedule it so the data is retrieved and processed regularly? Luckily, JavaScript has a method called window.setTimeout to do just that:</p>
<div id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:1b5ebf9b-6c9c-428e-96ef-deb92b76b987" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: javascript;">var pollInterval = 1000 * 60; // 1 minute, in milliseconds

function startRequest() {
	updateBadge();
	window.setTimeout(startRequest, pollInterval);
}</pre>
</div>
<p>That was easy! Now just slap a</p>
<pre class="brush: html">onload='startRequest()'</pre>
<p>on the background page’s body tag and that should do it!</p>
<p>But what if you want to stop the request? That can easily be done as well, by chaging the startRequest function a little and adding a stopRequest function:</p>
<div id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:b44225b5-3eb1-438d-a29f-0c02c893b8c7" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: javascript;">var pollInterval = 1000 * 60; // 1 minute, in milliseconds
var timerId;

function startRequest() {
	updateBadge();
	timerId = window.setTimeout(startRequest, pollInterval);
}

function stopRequest() {
	window.clearTimeout(timerId);
}</pre>
</div>
<p>And that’s about it on building background pages that can schedule requests. Now go! Make an awesome notifier! You can even make things like a timer with this (Facebook addiction control, anyone?). Just remember to leave a comment telling everyone of your awesomeness.</p>
]]></content:encoded>
			<wfw:commentRss>http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-4-background-pages-and-scheduling-requests/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>How to build a Chrome extension, Part 3: Loading any web page in a popup</title>
		<link>http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-3-loading-any-web-page-in-a-popup/</link>
		<comments>http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-3-loading-any-web-page-in-a-popup/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 03:40:18 +0000</pubDate>
		<dc:creator>Juliana Peña</dc:creator>
				<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[extension]]></category>

		<guid isPermaLink="false">http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-3-loading-any-web-page-in-a-popup/</guid>
		<description><![CDATA[Chrome allows extensions that use its page action or browser action API to show popups when clicked. To add this popup, you’d add a popup.html file to your extension and the following to the manifest.json for browser actions: { "name": "My Extension", ... "browser_action": { "default_icon": "myicon.png", "popup": "popup.html" } ... } Or for page <a href="http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-3-loading-any-web-page-in-a-popup/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Chrome allows extensions that use its <a href="http://code.google.com/chrome/extensions/pageAction.html">page action</a> or <a href="http://code.google.com/chrome/extensions/browserAction.html">browser action</a> API to show popups when clicked. To add this popup, you’d add a popup.html file to your extension and the following to the manifest.json for browser actions:</p>
<pre class="brush: js">{
	"name": "My Extension",
	...
	"browser_action": {
		"default_icon": "myicon.png",
		"popup": "popup.html"
	}
	...
}</pre>
<p>Or for page actions:</p>
<pre class="brush: js">{
	"name": "My Extension",
	...
	"page_action": {
		"default_icon": "myicon.png",
		"popup": "popup.html"
	}
	...
}</pre>
<p>However, the popup page is static and cannot be changed while the extension is running. Also, only a local extension page can be put into a popup; you can’t load an external page.</p>
<p>So how can you fix this? Using a relatively old web technique called an iframe. Inline frame, or iframe, is an HTML element that can load any web page inside another in a type of box. So, even though you can’t load an external web page as your popup, you can load it <em>within</em> it.</p>
<p>A simple example for a Bing search extension would be:</p>
<div id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:a5285258-32cb-435a-8157-9dbedd4ca7ff" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: xml;">&lt;html&gt;
&lt;head&gt;
	&lt;style type="text/css"&gt;
	body {width:200; height:300;}
	&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;iframe src="http://m.bing.com" width="100%" height="100%" frameborder="0"&gt;
	&lt;/iframe&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</div>
<p>As you can see, I have loaded the mobile version of Bing, <a title="http://m.bing.com" href="http://m.bing.com">http://m.bing.com</a>. Because of the small amount of screen real estate available on the popups, loading mobile versions of a page is a good idea as they are minimalistic and require less space.</p>
<p>I’ve also explicitly declared the size of the page (200 by 300) and the iframe (100% of the page). You can change this to what fits your extension best.</p>
<p>(Yeah, I know it is ironic to build a Chrome extension centered on Bing, but I couldn’t get <a href="http://www.google.com/m">Google’s mobile search</a> to load correctly in an iframe.)</p>
<p>On Chrome, the Bing search extension would look like this:</p>
<p><a href="http://julianapena.com/wp-content/uploads/HowtobuildaChromeextensionPart3Loadingan_13EA3/image.png"><img style="margin: 0px auto 5px; display: block; float: none; border-width: 0px;" title="image" src="http://julianapena.com/wp-content/uploads/HowtobuildaChromeextensionPart3Loadingan_13EA3/image_thumb.png" border="0" alt="image" width="390" height="367" /></a></p>
<p>You can download the completed Bing extension from the <a href="https://chrome.google.com/extensions/detail/dkjkkandkknagonejgliebkekfkkofad">Chrome Extensions Gallery</a> and the source code (under the <a href="http://creativecommons.org/licenses/GPL/2.0/">GPLv2</a>) from <a href="http://mfi.re/?imwxngtdkhg">Mediafire</a>.</p>
<p>Now, what if you want to load a different page depending on an <a href="http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-2-options-and-localstorage/">extension option</a>? You can easily do this by constructing the iframe element dynamically when the page loads, like this code excerpt from <a href="http://julianapena.com/projects/chrome-rtm/">ChromeMilk</a>:</p>
<div id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:dc0221eb-6196-4a17-96b4-eb1d29d48b94" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: javascript;">$(document).ready(function() {
	var popup = localStorage.popup || 'igoogle';

	var frame = document.createElement('iframe');

	frame.setAttribute('width', '100%');
	frame.setAttribute('height', '100%');
	frame.setAttribute('frameborder', '0');
	frame.setAttribute('id', 'rtmframe');

	if (popup == 'gmail') {
		// open gmail gadget
		$('body').height(300).width(200);
		frame.setAttribute('src', 'http://www.rememberthemilk.com/services/modules/gmail/');
	}
	else if (popup == 'iphone') {
		// open iphone web app
		$('body').height(480).width(320);
		frame.setAttribute('src', 'http://i.rememberthemilk.com/');
	}
	else if (popup == 'mobile') {
		// open mobile web app
		$('body').height(300).width(200);
		frame.setAttribute('src', 'http://m.rememberthemilk.com/');
	}
	else {
		// igoogle and default
		$('body').height(400).width(400);
		frame.setAttribute('src', 'http://www.rememberthemilk.com/services/modules/googleig/');
	}

	document.body.appendChild(frame);
});</pre>
</div>
<p>This way, the extension sets the popup size and the iframe location based on a setting saved by the user.</p>
<p>There are a few limitations of this method. Most importantly, you can’t manipulate the iframe once it is loaded, as this is <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">cross-side scripting</a> and is prevented by the browser for security reasons.</p>
<p>That’s about it on loading external web sites in popups. You can use this for a number of things. I’ve mentioned mobile sites, but things like iGoogle widgets also work well.</p>
<p>Do you have any tips on building Chrome extensions based on popups? Or are you having trouble building your extension? Leave a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-3-loading-any-web-page-in-a-popup/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>How to build a Chrome extension, Part 2: Options and localStorage</title>
		<link>http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-2-options-and-localstorage/</link>
		<comments>http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-2-options-and-localstorage/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 20:57:39 +0000</pubDate>
		<dc:creator>Juliana Peña</dc:creator>
				<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[extension]]></category>

		<guid isPermaLink="false">http://julianapena.com/?p=399</guid>
		<description><![CDATA[An important aspect of almost all extensions is being able to save user settings. This can be achieved in Chrome easily by using the localStorage object and Chrome’s extension API options page. Adding an options page To add an options page to your extension, make an options.html file in your extension’s folder and add the <a href="http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-2-options-and-localstorage/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>An important aspect of almost all extensions is being able to save user settings. This can be achieved in Chrome easily by using the localStorage object and Chrome’s extension API options page.</p>
<h3>Adding an options page</h3>
<p>To add an options page to your extension, make an options.html file in your extension’s folder and add the “options_page” line to your manifest.json like so:</p>
<pre class="brush: js">{
  "name": "My Extension",
  ...
  "options_page": "options.html"
  ...
}</pre>
<h3>localStorage</h3>
<p>localStorage is an HTML5 object used for storing web page data locally using JavaScript. Chrome gives extensions the option of using localStorage to save options and data.</p>
<h3>Saving options</h3>
<p>To save a string to localStorage, use the following code, replacing mysetting and myvalue with your own:</p>
<pre class="brush: js">localStorage["mysetting"] = "myvalue";</pre>
<p>Or, equivalently:</p>
<pre class="brush: js">localStorage.mysetting = "myvalue";</pre>
<h3>Loading options</h3>
<p>To load an option, just access the setting member in the localstorage object:</p>
<pre class="brush: js">myvar = localStorage["mysetting"];</pre>
<p>Or, equivalently:</p>
<pre class="brush: js">myvar = localStorage.mysetting;</pre>
<p>It’s always a good idea to make sure you’ve loaded a valid setting. For example, the following code loads a favorite color, but if the current color is not valid, it loads the default value:</p>
<pre class="brush: js">var defaultColor = "blue";

function loadFavColor() {
	var favColor = localStorage["favColor"];

	// valid colors are red, blue, green and yellow
	if (favColor == undefined || (favColor != "red" &amp;&amp; favColor != "blue" &amp;&amp; favColor != "green" &amp;&amp; favColor != "yellow")) {
		favColor = defaultColor;
	}

	return favColor;
}</pre>
<h3>Erasing options</h3>
<p>You can erase an option by removing it from the localstorage object, like so:</p>
<pre class="brush: js">localStorage.removeItem("mysetting");</pre>
<h3>Building an options page</h3>
<p>Continuing with the favorite color example, lets now build a complete options page for our color-choosing extension. The options.html page would look like this:</p>
<pre class="brush: xml;">&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;Options for Color Chooser&lt;/title&gt;
	&lt;script type="text/javascript" src="options.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="loadOptions()"&gt;
	&lt;h1&gt;Favorite Color&lt;/h1&gt;
	&lt;select id="color"&gt;
		&lt;option value="blue"&gt;Blue&lt;/option&gt;
		&lt;option value="red"&gt;Red&lt;/option&gt;
		&lt;option value="green"&gt;Green&lt;/option&gt;
		&lt;option value="yellow"&gt;Yellow&lt;/option&gt;
	&lt;/select&gt;
	&lt;br /&gt;
	&lt;button onclick="saveOptions()"&gt;Save&lt;/button&gt;
	&lt;br /&gt;
	&lt;button onclick="eraseOptions()"&gt;Restore default&lt;/button&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>For the behavior of the page, options.js would look like this:</p>
<pre class="brush: javascript;">var defaultColor = "blue";

function loadOptions() {
	var favColor = localStorage["favColor"];

	// valid colors are red, blue, green and yellow
	if (favColor == undefined || (favColor != "red" &amp;&amp; favColor != "blue" &amp;&amp; favColor != "green" &amp;&amp; favColor != "yellow")) {
		favColor = defaultColor;
	}

	var select = document.getElementById("color");
	for (var i = 0; i &lt; select.children.length; i++) {
		var child = select.children[i];
			if (child.value == favColor) {
			child.selected = "true";
			break;
		}
	}
}

function saveOptions() {
	var select = document.getElementById("color");
	var color = select.children[select.selectedIndex].value;
	localStorage["favColor"] = color;
}

function eraseOptions() {
	localStorage.removeItem("favColor");
	location.reload();
}</pre>
<p>And that’s about it! You can also save and load localStorage data elsewhere in your extension, as the data is shared between all your extension’s files.</p>
<p>Any question, remark, or addition? Please leave a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://julianapena.com/2010/01/how-to-build-a-chrome-extension-part-2-options-and-localstorage/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
