<?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; Code snippet</title>
	<atom:link href="http://julianapena.com/category/programming/code-snippet/feed/" rel="self" type="application/rss+xml" />
	<link>http://julianapena.com</link>
	<description></description>
	<lastBuildDate>Sun, 18 Sep 2011 09:34:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<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>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>
	</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! -->
