<?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>Luke Loeffler &#187; code</title>
	<atom:link href="http://lukeloeffler.com/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://lukeloeffler.com</link>
	<description></description>
	<lastBuildDate>Mon, 30 Jan 2012 19:47:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Kittenator bookmarklet</title>
		<link>http://lukeloeffler.com/2011/kittenator-bookmarklet/</link>
		<comments>http://lukeloeffler.com/2011/kittenator-bookmarklet/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 06:33:41 +0000</pubDate>
		<dc:creator>luke</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://lukeloeffler.com/?p=873</guid>
		<description><![CDATA[placekitten.com, a website by Mark James, was recently created to generate arbitrarily-sized placeholder images&#8230; of kittens. To make it available to a wider audience I created the Kittenate! bookmarklet, a small script that replaces the images of virtually any website you&#8217;re viewing with images of kittens at the click of a button. Kittenate! &#60;&#8211; Drag [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://placekitten.com">placekitten.com</a>, a website by <a href="http://mark.james.name/">Mark James</a>, was recently created to generate arbitrarily-sized placeholder images&#8230; of kittens. To make it available to a wider audience I created the Kittenate! bookmarklet, a small script that replaces the images of virtually any website you&#8217;re viewing with images of kittens at the click of a button.</p>
<p><a href="javascript:(function(){_jqscript=document.createElement('script');_jqscript.type='text/javascript';_jqscript.src='https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js';document.documentElement.appendChild(_jqscript);$('img').each(function(i){_w=$(this).attr('width');_h=$(this).attr('height');$(this).attr('src','http://placekitten.com/'+_w+'/'+_h+'/');});})();">Kittenate!</a> &lt;&#8211; Drag this link to your bookmarks toolbar. Clicking it will replace all the images on the webpage you&#8217;re viewing with kittens. (Or you may have to right click and select &#8216;add bookmark&#8217;)</p>
<div id="attachment_890" class="wp-caption alignnone" style="width: 370px"><a href="http://www.flickr.com/photos/ukle/5489571376/"><img src="http://lukeloeffler.com/wordpress/wp-content/uploads/2011/03/Screen-shot-2011-03-01-at-12.45.51-PM-360x342.png" alt="" title="Ouch, the Daily Puppy got KITTENATED" width="360" height="342" class="size-medium wp-image-890" /></a><p class="wp-caption-text">The Daily Puppy just got KITTENATED</p></div>
]]></content:encoded>
			<wfw:commentRss>http://lukeloeffler.com/2011/kittenator-bookmarklet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Cam Heart Rate Monitor</title>
		<link>http://lukeloeffler.com/2009/web-cam-heart-rate-monitor/</link>
		<comments>http://lukeloeffler.com/2009/web-cam-heart-rate-monitor/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 02:34:18 +0000</pubDate>
		<dc:creator>luke</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[experiment]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://lukeloeffler.com/?p=463</guid>
		<description><![CDATA[How to measure your heart rate with a webcam and some Processing code.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been experimenting with methods to determine my heart rate in order to add bio-feedback to software. This Processing sketch uses the same principle as the devices in the doctor&#8217;s office that clip on to your finger. When your heart beats, more blood is pumped through the capillaries in your fingertip, thus absorbing more light and causing a slight darkening of your fingertip.</p>
<p>To use the code you&#8217;ll need a copy of <a href="http://processing.org">Processing</a>. Shine a bright flashlight against your thumbnail (I used a bright LED flashlight) and place your thumb over the webcam lens so it completely blocks it. Try to hold as still as possible.  The brightness of the red channel is measured each frame and a running average is kept. If the brightness drops below the recent average, a small circle is drawn representing a contracting heart.</p>
<p>If it is unreliable, you may need to tweak the navg parameter and/or find a way to stabilize the light source, finger, and camera, as small shifts will cause a change in the amount of light detected by the camera.</p>
<p><a href='http://lukeloeffler.com/wordpress/wp-content/uploads/2009/11/heartrate_monitor_camera.pde'>Download the Code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lukeloeffler.com/2009/web-cam-heart-rate-monitor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Text on a Curve</title>
		<link>http://lukeloeffler.com/2009/text-on-a-curve/</link>
		<comments>http://lukeloeffler.com/2009/text-on-a-curve/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 22:57:03 +0000</pubDate>
		<dc:creator>luke</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[typography]]></category>

		<guid isPermaLink="false">http://lukeloeffler.com/?p=383</guid>
		<description><![CDATA[I&#8217;m researching methods to render text along a path, like you can easily do in Illustrator. Unfortunately, it&#8217;s not so simple in Processing (unless someone knows of a library that does this). You can find a demo and the source here. Click four times to set the curve points and handles. Move the mouse left [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m researching methods to render text along a path, like you can easily do in Illustrator. Unfortunately, it&#8217;s not so simple in Processing (unless someone knows of a library that does this).</p>
<p><a href="http://lukeloeffler.com/wordpress/wp-content/uploads/2009/09/Screen-shot-2009-09-01-at-5.57.37-PM.png"><img class="alignnone size-medium wp-image-392" title="Screen shot 2009-09-01 at 5.57.37 PM" src="http://lukeloeffler.com/wordpress/wp-content/uploads/2009/09/Screen-shot-2009-09-01-at-5.57.37-PM-360x157.png" alt="Screen shot 2009-09-01 at 5.57.37 PM" width="360" height="157" /></a></p>
<p>You can find a demo and the source <a href="http://lukeloeffler.com/wordpress/wp-content/uploads/2009/09/growing_text_tree.html">here</a>. Click four times to set the curve points and handles. Move the mouse left and right to alter the curve tightness.</p>
<p>In a nutshell, the algorithm computes the approximate length of the line segment by chopping it into smaller segments and computing the linear distance between points.  Once the length of the segment is known in pixels, <em>textWidth()</em> is called to obtain the width in pixels of each character. This width divided by the length of the curve determines the percentage of the curve the character occupies. Once this is know, the amount to increment the variable <em>t</em> in the parametric <em>curvePoint(&#8230;)</em> function is known. From here, we can find the starting point, determine the tangent, and draw the letter.</p>
<p>All straightforward, right? For whatever reason, though, the kerning is severely off under certain conditions. When there is a slight curve in the line segment, it seems to be balanced. When the curve tightness is altered and becomes very flat, or very curved, the letters become overly spaced out at one end, and overly compressed at the other.  Does anyone have any suggestions as to why this is happening?</p>
]]></content:encoded>
			<wfw:commentRss>http://lukeloeffler.com/2009/text-on-a-curve/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Making a Stacked Area Chart With Processing</title>
		<link>http://lukeloeffler.com/2009/stacked_area_chart/</link>
		<comments>http://lukeloeffler.com/2009/stacked_area_chart/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 06:37:25 +0000</pubDate>
		<dc:creator>luke</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://lukeloeffler.com/?p=370</guid>
		<description><![CDATA[In order to visualize multiple variables in a single time series, a stacked area (sometimes called a &#8220;stream&#8221;) chart is often useful. I am currently doing research for an upcoming visualization that will trace the development of ideas through a conversation. Unable to find processing code to create an area chart, I decided to write [...]]]></description>
			<content:encoded><![CDATA[<p>In order to visualize multiple variables in a single time series, a stacked area (sometimes called a &#8220;stream&#8221;) chart is often useful. I am currently doing research for an upcoming visualization that will trace the development of ideas through a conversation. Unable to find <a href="http://processing.org">processing</a> code to create an area chart, I decided to write my own. I imagine if I looked, there is something out there, but I also wanted something I could completely control to change the appearance of. Hopefully you will find <a href="http://lukeloeffler.com/wordpress/wp-content/uploads/2009/08/river.pde">the source</a> useful in a project of your own.  The image below is an example of the output from the code.</p>
<p><a href="http://lukeloeffler.com/wordpress/wp-content/uploads/2009/08/river1.png"><img style="border: 0px initial initial;" title="river1" src="http://lukeloeffler.com/wordpress/wp-content/uploads/2009/08/river1-360x155.png" alt="river1" width="360" height="155" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://lukeloeffler.com/2009/stacked_area_chart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Natural Language Processing</title>
		<link>http://lukeloeffler.com/2009/natural-language-processing/</link>
		<comments>http://lukeloeffler.com/2009/natural-language-processing/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 05:07:08 +0000</pubDate>
		<dc:creator>luke</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://lukeloeffler.com/?p=314</guid>
		<description><![CDATA[I have become increasingly interested in tools to perform natural language processing. So much of how we approach and see problems is tied up in the words we find to describe them. I am currently exploring ways to use language to help define and understand problems as well as get out of creative blocks. Below [...]]]></description>
			<content:encoded><![CDATA[<p>I have become increasingly interested in tools to perform natural language processing. So much of how we approach and see problems is tied up in the words we find to describe them. I am currently exploring ways to use language to help define and understand problems as well as get out of creative blocks.</p>
<p>Below are a few useful tools:</p>
<p>Princeton&#8217;s <a href="http://wordnet.princeton.edu/">Wordnet</a> is a massive linguistic database containing not just definitions, but how words are related to each other.</p>
<p>The Python <a href="http://www.nltk.org/">Natural Language Toolkit</a>, which provides tools for parsing and understanding natural language semantics.</p>
<p>The Carnegie Mellon <a href="http://www.speech.cs.cmu.edu/cgi-bin/cmudict">Pronouncing Dictionary</a>, which breaks words down into their phonemes, providing information regarding pronouncing, rhyming, and syllable counts.</p>
<p>Having found no simple resource to provide syllable counts for common words, I want to share a quick solution I wrote in Python, which uses the CMU dictionary. Simply download the dictionary to the same directory as this script, naming it cmu_pron.txt.</p>
<pre>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">f = open("cmu_pron.txt")</div>

f = open("cmu_pron.txt")
lines = f.readlines()
f.close()
words = {}

for line in lines:
	pieces = line.split()
	if pieces[0] == ";;;":
		continue
	words[pieces[0]] = pieces[1:]

def num_syllables(word):
	global words
	key = word.upper()
	plist = words[key]
	return len(filter(lambda c: c in ("0","1","2"),"".join(plist)))

print "alphabet: %s" % num_syllables("alphabet")</pre>
<p>The result for alphabet is indeed 3. There are probably more efficient ways to do this, but it gets the job done.</p>
]]></content:encoded>
			<wfw:commentRss>http://lukeloeffler.com/2009/natural-language-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

