<?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>Expendable Words &#187; Play</title>
	<atom:link href="http://www.expendablewords.com/category/play/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.expendablewords.com</link>
	<description>about technology and software development</description>
	<lastBuildDate>Sat, 28 Jan 2012 10:24:05 +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>AppleTV + Flickr Interestingness</title>
		<link>http://www.expendablewords.com/2008/09/21/appletv-flickr-interestingness/</link>
		<comments>http://www.expendablewords.com/2008/09/21/appletv-flickr-interestingness/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 00:04:33 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
				<category><![CDATA[Play]]></category>
		<category><![CDATA[AppleTV]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[[amtap amazon:asin=B0057CVH6W]]]></category>
		<category><![CDATA[[amtap amazon:asin=B005JACJ50]]]></category>

		<guid isPermaLink="false">http://www.expendablewords.com/?p=86</guid>
		<description><![CDATA[UPDATE2: I no longer use my Apple TV, so this is no longer being updated. I have made the source code available on github for anyone who&#8217;s interested. UPDATE: One change from the original&#8230; It now only selects photos with a Creative Commons license. This means there are less than 250 new photos each day. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE2: I no longer use my Apple TV, so this is no longer being updated. I have made the source code available on <a href="https://github.com/dwburns/dailypool">github</a> for anyone who&#8217;s interested.</strong></p>
<p><strong>UPDATE: One change from the original&#8230; It now only selects photos with a Creative Commons license. This means there are less than 250 new photos each day. To maintain the 250 photo set, it adds all the new photos and drops the same number of the oldest photos. That way there are always approximately 250 photos. For example, if there are 30 new photos one day, they will be added and the 30 oldest will be removed.</strong></p>
<p>When at home, I listen to most of my music through AppleTV. This means the TV is on a lot, so I&#8217;d like an interesting screen saver. Unfortunately, AppleTV falls a little short in this area. It can rotate a set of photos as the screen saver, but you can only choose from a small group of Apple photos, your own iPhoto collection, or photos from a specific Flickr account. I like my photos, but don&#8217;t want to look at them all the time, and I had a hard time finding a Flickr user with a large enough album to keep things interesting.</p>
<p>What I really wanted was a way to display the Flickr <a href="http://www.flickr.com/explore/interesting/">interestingness</a> collection. Interestingness is a pool of, you guessed it&#8230; interesting photos, that changes all the time. Unfortunately, since AppleTV only provides the ability to link to specific Flickr accounts, you can&#8217;t access this dynamic collection.</p>
<p>After searching for a solution, and inspired by this <a href="http://blog.ifbydesign.com/2007/09/17/flickr-to-apple-tv-how-to-automatically-download-a-daily-dose-of-interesting-photos/">post</a>, I finally came up with workaround. It&#8217;s a script that queries photos from <em>interestingness</em> via the Flickr API, then adds them as favorites to a special Flickr account I created called <a href="http://www.flickr.com/photos/dailypool/favorites/">dailypool</a>. The script runs every night, so there are always fresh photos. Since this Flickr account can be viewed by anyone, you can easily link to it on your own AppleTV.</p>
<p>Here&#8217;s what you need to do to set it up. This assumes you&#8217;re using AppleTV v2.</p>
<p><strong>Add the dailypool Flickr account:</strong></p>
<ol>
<li>On your remote, press <em>Menu</em> to get to the main menu</li>
<li>Select <em>Photos</em> in the left menu, then <em>Flickr</em> in the right menu</li>
<li>Select <em>Add Flickr Contact</em>, then type <em>dailypool</em> using the onscreen keyboard</li>
</ol>
<p><strong>Set dailypool favorites as your screen saver</strong></p>
<ol>
<li>Press the <em>Menu</em> button on the remote until you get back to the main menu</li>
<li>Select <em>Settings</em> in the left menu, then <em>Screen Saver</em> in the right menu</li>
<li>On the <em>Screen Saver</em> screen, scroll down to and select the <em>Slideshow</em> menu</li>
<li>On the <em>Choose Photos</em> screen, select <em>Flickr</em>, then select <em>dailypool</em>, then <em>favorites</em></li>
<li>Press the Menu button on the remote until you get back to the main menu</li>
</ol>
<p>That&#8217;s it! Next time your AppleTV goes into screen saver mode it should display interestingness photos that will be refreshed every day. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.expendablewords.com/2008/09/21/appletv-flickr-interestingness/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Automatic My Coke Rewards Code Entry</title>
		<link>http://www.expendablewords.com/2008/09/01/automatic-my-coke-rewards-code-entry/</link>
		<comments>http://www.expendablewords.com/2008/09/01/automatic-my-coke-rewards-code-entry/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 23:00:07 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
				<category><![CDATA[Play]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.expendablewords.com/?p=47</guid>
		<description><![CDATA[Until recently I had a large backlog of My Coke Rewards points. In addition to all the codes I collected myself, I also received quite a few from my friends and family (Thanks!). The problem is that the site only allows you to redeem 10 codes per day, and I had a hard time remembering [...]]]></description>
			<content:encoded><![CDATA[<p>Until recently I had a large backlog of <em>My Coke Rewards</em> points. In addition to all the codes I collected myself, I also received quite a few from my friends and family (Thanks!). The problem is that the site only allows you to redeem 10 codes per day, and I had a hard time remembering to enter them every day.</p>
<p>To help, I created a Ruby script for automatically processing codes. Every day, it reads 10 codes from a text file, then submits them to mycokerewards.com and logs the result. That way, I could just add all my codes to a file and it would take care of the rest.</p>
<p>I&#8217;ve provided the script below, as well as instructions for configuring it on a Mac (should be similar  on Unix/Linux). If you&#8217;re using Windows, you can do the same thing by downloading Ruby and setting up a scheduled task. This isn&#8217;t the most user-friendly process, so a little development and/or command line experience would be helpful, but if you don&#8217;t have that you should be able to work it out by stepping through the instructions. Good luck and happy redeeming!</p>
<p><span id="more-47"></span><br />
<strong>Here&#8217;s the code</strong><br/></p>

<div class="wp_syntax"><table><tr><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
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'xmlrpc/client'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'logger'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> McrSender 
  @@SERVICE_URL = <span style="color:#996600;">&quot;https://secure.mycokerewards.com/xmlrpc&quot;</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>codeFile, logFile, readCount, username, password<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@codeFile</span> = codeFile
	<span style="color:#0066ff; font-weight:bold;">@logFile</span> = logFile
    <span style="color:#0066ff; font-weight:bold;">@readCount</span> = readCount
    <span style="color:#0066ff; font-weight:bold;">@username</span> = username
    <span style="color:#0066ff; font-weight:bold;">@password</span> = password
    <span style="color:#0066ff; font-weight:bold;">@logger</span> = <span style="color:#CC00FF; font-weight:bold;">Logger</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>@logFile<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> send_codes
    i = <span style="color:#006666;">1</span>
    <span style="color:#008000; font-style:italic;"># read file into an array</span>
    lines = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">readlines</span><span style="color:#006600; font-weight:bold;">&#40;</span>@codeFile<span style="color:#006600; font-weight:bold;">&#41;</span>
    lineCount = lines.<span style="color:#9900CC;">length</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>lineCount <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span> <span style="color:#9966CC; font-weight:bold;">and</span> lines<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">strip</span>.<span style="color:#9900CC;">length</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#008000; font-style:italic;"># login</span>
      <span style="color:#9966CC; font-weight:bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>login == <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#0066ff; font-weight:bold;">@logger</span>.<span style="color:#9900CC;">info</span> <span style="color:#996600;">&quot;Successfully logged in.&quot;</span>
&nbsp;
        <span style="color:#CC0066; font-weight:bold;">puts</span> lineCount
&nbsp;
        <span style="color:#008000; font-style:italic;"># process items and remove them from the array</span>
        i = <span style="color:#006666;">0</span>
        <span style="color:#9966CC; font-weight:bold;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span>i <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#0066ff; font-weight:bold;">@readCount</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> i <span style="color:#006600; font-weight:bold;">&lt;</span> lineCount<span style="color:#006600; font-weight:bold;">&#41;</span>
          code = lines<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#CC0066; font-weight:bold;">chomp</span>
          send_code<span style="color:#006600; font-weight:bold;">&#40;</span>code<span style="color:#006600; font-weight:bold;">&#41;</span>
          lines.<span style="color:#9900CC;">delete_at</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          i <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006666;">1</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        <span style="color:#008000; font-style:italic;"># write array back to file</span>
        <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>@codeFile, <span style="color:#996600;">&quot;w&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>file<span style="color:#006600; font-weight:bold;">|</span>
          file.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>lines.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">else</span>
        <span style="color:#0066ff; font-weight:bold;">@logger</span>.<span style="color:#9900CC;">error</span> <span style="color:#996600;">&quot;Could not login with username '#{@username}' and password '#{@password}'.&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#0066ff; font-weight:bold;">@logger</span>.<span style="color:#9900CC;">info</span> <span style="color:#996600;">&quot;No codes found in code file (or the first line is empty). Exiting.&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  private
    <span style="color:#9966CC; font-weight:bold;">def</span> send_code<span style="color:#006600; font-weight:bold;">&#40;</span>code<span style="color:#006600; font-weight:bold;">&#41;</span>
      args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">'emailAddress'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@username</span>, <span style="color:#996600;">'password'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@password</span>, <span style="color:#996600;">'screenName'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">' '</span>, <span style="color:#996600;">'capCode'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> code, <span style="color:#996600;">'VERSION'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'3.0'</span><span style="color:#006600; font-weight:bold;">&#125;</span>
      service = <span style="color:#6666ff; font-weight:bold;">XMLRPC::Client</span>.<span style="color:#9900CC;">new2</span><span style="color:#006600; font-weight:bold;">&#40;</span>@@SERVICE_URL<span style="color:#006600; font-weight:bold;">&#41;</span>
      result = service.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'points.enterCode'</span>, args<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>result<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'ENTER_CODE_RESULT'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#996600;">&quot;true&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        earned = result<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'POINTS_EARNED'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
        <span style="color:#0066ff; font-weight:bold;">@logger</span>.<span style="color:#9900CC;">info</span> <span style="color:#996600;">&quot;Successfully entered code '#{code}' Points earned '#{earned}'. &quot;</span>
      <span style="color:#9966CC; font-weight:bold;">else</span>
        message = result<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'MESSAGES'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
        <span style="color:#0066ff; font-weight:bold;">@logger</span>.<span style="color:#9900CC;">error</span> <span style="color:#996600;">&quot;Error entering code '#{code}'. Error message: '#{message}'.&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> login
      args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">'emailAddress'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@username</span>, <span style="color:#996600;">'password'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@password</span>, <span style="color:#996600;">'screenName'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">' '</span>, <span style="color:#996600;">'VERSION'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'3.0'</span><span style="color:#006600; font-weight:bold;">&#125;</span>
      service = <span style="color:#6666ff; font-weight:bold;">XMLRPC::Client</span>.<span style="color:#9900CC;">new2</span><span style="color:#006600; font-weight:bold;">&#40;</span>@@SERVICE_URL<span style="color:#006600; font-weight:bold;">&#41;</span>
      result = service.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'points.pointsBalance'</span>, args<span style="color:#006600; font-weight:bold;">&#41;</span>
      result<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'LOGIN_RESULT'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#996600;">&quot;true&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
sender = McrSender.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;codes.txt&quot;</span>, <span style="color:#996600;">&quot;log.txt&quot;</span>, <span style="color:#006666;">10</span>, <span style="color:#996600;">&quot;YOUR_EMAIL&quot;</span>, <span style="color:#996600;">&quot;YOUR_PASSWORD&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
sender.<span style="color:#9900CC;">send_codes</span></pre></td></tr></table></div>

<p><strong>How to install</strong><br/></p>
<ol>
<li>
Make sure Ruby is installed on your Mac. (It is by default in Leopard). You can open terminal and type the following to check. It will return the Ruby version if it&#8217;s installed.</p>
<pre>
ruby -v
</pre>
</li>
<li>
Download the <a href='http://www.expendablewords.com/wp-content/uploads/2008/09/mcrsender.zip'>zip file</a> containing the script, code file and log file.
</li>
<li>
Extract the archive, the move the McrSender folder to the desired location. I&#8217;ll use <em>/Users/doug</em> for the remaining instructions. Replace <em>/Users/doug</em> with your own path.
</li>
<li>
In the bottom two lines of McrSender.rb, change &#8220;codes.txt&#8221; to the full path to your codes.txt file, &#8220;log.txt&#8221; to the full path to your log.txt file, &#8220;YOUR_EMAIL&#8221; to the email address you use for My Coke Rewards, and &#8220;YOUR_PASSWORD&#8221; to the password you use for My Coke Rewards. (NOTE: All of these values should be surrounded in double quotes)
</li>
<li>
Add your My Coke Rewards Codes to the codes.txt file. There should be one code per line.
</li>
<li>
Open terminal then type the following commands to change permissions on the Ruby script to make it executable and on the codes.txt and log.txt files to make them readable and writable.</p>
<pre>
cd /Users/doug
chmod 755 McrSender.rb
chmod 666 codes.txt
chmod 666 log.txt
</pre>
</li>
<li>
Create a cron job to run the script every day. Again, in Terminal type:</p>
<pre>
EDITOR=nano
crontab -e
</pre>
<p>Your cron file will open up in the nano command line text editor. Add the following line to run the script at 6:00 am every morning:</p>
<pre>
0 6 * * * ruby /Users/dwburns/scripts/McrSender/McrSender.rb
</pre>
<p>(Again, change the path to your own path).
</li>
</ol>
<p>You can test it the first time by running (something like) the following in Terminal:</p>
<pre>
/Users/doug/McrSender/McrSender.rb
</pre>
<p><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.expendablewords.com/2008/09/01/automatic-my-coke-rewards-code-entry/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

