<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>hi, it&#39;s mike</title>
    <link>https://mike.puddingtime.org/tags/appscript/</link>
    <description>Recent content on hi, it&#39;s mike</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>mike@puddingtime.org (mike)</managingEditor>
    <webMaster>mike@puddingtime.org (mike)</webMaster>
    <copyright>© 2026, mike</copyright>
    <lastBuildDate>Tue, 13 Jul 2010 00:51:29 +0000</lastBuildDate>
    <atom:link href="https://mike.puddingtime.org/tags/appscript/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Make a Things Todo Out of the Current &#39;Net Radio Track in iTunes</title>
      <link>https://mike.puddingtime.org/posts/2010-07-13-make-a-things-todo-out-of-the-current-net-radio/</link>
      <pubDate>Tue, 13 Jul 2010 00:51:29 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2010-07-13-make-a-things-todo-out-of-the-current-net-radio/</guid>
      
      <description>![](https://media.puddingtime.org/archive/mph.puddingbowl.org/wordpress/wp-content/uploads/2010/07/things_itunes.jpg) I’ve taken to listening to KCRW’s Eclectic 24 during the day, which is exposing me to a lot of new music I’d like to look up later (and definitely do not want to spend a lot of time …</description>
      <content:encoded><![CDATA[<div style="text-align:center;margin:1em;">![](https://media.puddingtime.org/archive/mph.puddingbowl.org/wordpress/wp-content/uploads/2010/07/things_itunes.jpg)</div>
<p>I&rsquo;ve taken to listening to KCRW&rsquo;s <a href="http://www.kcrw.com/music/eclectic24">Eclectic 24</a> during the day, which is exposing me to a lot of new music I&rsquo;d like to look up later (and definitely do not want to spend a lot of time looking up when I should be doing other things). Hence this quick snippet to grab the current track information and source station of whatever&rsquo;s playing in iTunes and capture it in my &ldquo;Things to Look Up&rdquo; list in Things. After I posted the snippet it occurred to me to add a time stamp to the note as well, since some stations <a href="http://newmedia.kcrw.com/tracklists/index.php?channel=Music">publish their playlists</a>, and there&rsquo;s no error checking in case the station doesn&rsquo;t provide good track information.</p>
<p>I&rsquo;ve hooked it up to a keyboard shortcut in <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a> so I don&rsquo;t have to break context to grab the current track and keep doing whatever I&rsquo;m doing.</p>
<div id="snipplr_embed_37176" class="snipplr_embed"><a href="http://snipplr.com/view/37176/make-a-things-todo-out-of-the-current-itunes-net-radio-track/">Code snippet - Make a Things Todo Out of the Current iTunes Net Radio Track</a> on Snipplr</div><script type="text/javascript" src="http://snipplr.com/js/embed.js"></script><script type="text/javascript" src="http://snipplr.com/json/37176"></script>
<p>#appscript #itunes #music #ruby #things</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Make%20a%20Things%20Todo%20Out%20of%20the%20Current%20%27Net%20Radio%20Track%20in%20iTunes">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Creating Links in the Body of a Note in Things</title>
      <link>https://mike.puddingtime.org/posts/2010-07-06-creating-links-in-the-body-of-a-note-in-things/</link>
      <pubDate>Tue, 06 Jul 2010 01:15:43 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2010-07-06-creating-links-in-the-body-of-a-note-in-things/</guid>
      
      <description>The whole “panopticon won’t be able to create a link in the notes of a Things todo” thing really bugged me. This morning over coffee I found an AppleScript by Moszi that creates links to mail messages in a Things note, and that taught me that Things uses a bbcode-style markup convention to create …</description>
      <content:encoded><![CDATA[<p>The whole &ldquo;panopticon won&rsquo;t be able to create a link in the notes of a Things todo&rdquo; thing really bugged me. This morning over coffee I found an <a href="http://culturedcode.com/things/wiki/index.php/AppleMailToThings">AppleScript by Moszi that creates links to mail messages in a Things note</a>, and that taught me that Things uses a <a href="http://en.wikipedia.org/wiki/BBCode">bbcode</a>-style markup convention to create links in todos, like this:</p>
<p><code>[url=http://en.wikipedia.org/wiki/BBCode]Wikipedia on BBCode[/url]</code></p>
<p>So now panopticon can make links to URLs and directly to e-mail messages in Mail.app when the todo-creating function is fed a link:</p>
<div id="snipplr_embed_36721" class="snipplr_embed"><a href="http://snipplr.com/view/36721/create-a-todo-in-things/">Code snippet - Create a Todo in Things</a> on Snipplr</div><script type="text/javascript" src="http://snipplr.com/js/embed.js"></script><script type="text/javascript" src="http://snipplr.com/json/36721"></script>
<p>I had briefly switched to using <a href="http://www.hogbaysoftware.com/products/taskpaper">TaskPaper</a> to store my panopticon todos,  because it provides a live link to Web URLs in the desktop version. That was still only a 50 percent solution, because there was no linking to Mail.app messages, and because Taskpaper on iPhone and iPad treat URLs like any other text: No live links.</p>
<p>With live links working in Things, I&rsquo;m at about 95 percent of what I&rsquo;d like: Links to messages don&rsquo;t work in the iPhone and iPad versions of Things, and I&rsquo;m still not sure how to handle Instapaper items. For the moment, the Instapaper feed provides a link to the original source, not the Instapaperized item. For Instapaper items, I just create a link to the item as fed through the <a href="http://www.instapaper.com/m">Instapaper Mobilizer service</a> on the assumption that if I saved it in Instapaper to begin with, it must be amenable to reformatting.</p>
<p>The other thing that came out of all this poking around for live links was a discovery that  I like TaskPaper a lot, but like Things better. With a little scripting, TaskPaper can accomplish an awful lot, but very little that Things doesn&rsquo;t &ldquo;just do&rdquo; without the need to shoehorn stuff into TaskPaper&rsquo;s plain-text conventions. I also ran into some odd issues with TaskPaper&rsquo;s syncing. It uses the <a href="http://www.simpletext.ws/">SimpleText</a> service, and I had some problems with a complex list that suggested TaskPaper&rsquo;s <a href="http://blog.hogbaysoftware.com/post/714987484/plaintext-synced-text-files-for-ios-preview">move to Dropbox as its syncing engine</a> is probably a pretty good idea.</p>
<p>At the same time, TaskPaper is a really, really nice way to manage simple shopping lists, because you don&rsquo;t have to count on someone else in the household having a copy of it when you can quickly print the list. I also like having TaskPaper around for quick lists that I don&rsquo;t want to turn into full todos. For instance, it&rsquo;s a nice way to identify a bunch of requirements in list format and tick them off as they&rsquo;re met during the early draft stage of a project.</p>
<p>#appscript #panopticon #ruby #things</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Creating%20Links%20in%20the%20Body%20of%20a%20Note%20in%20Things">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Set Your Adium Status With rb-appscript</title>
      <link>https://mike.puddingtime.org/posts/2010-07-04-set-your-adium-status-with-rb-appscript/</link>
      <pubDate>Sun, 04 Jul 2010 01:32:06 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2010-07-04-set-your-adium-status-with-rb-appscript/</guid>
      
      <description>Code snippet - adium_status on Snipplr I’ve been fiddling with Snippets and noticed it supported posting to Snipplr. I’m not sure if I really need Snippets, but I like that Snipplr has a WordPress plugin and a TextMate bundle.
Anyone in the sound of my voice used Snipplr and have anything good or …</description>
      <content:encoded><![CDATA[<div id="snipplr_embed_36662" class="snipplr_embed"><a href="http://snipplr.com/view/36662/adiumstatus/">Code snippet - adium_status</a> on Snipplr</div><script type="text/javascript" src="http://snipplr.com/js/embed.js"></script><script type="text/javascript" src="http://snipplr.com/json/36662"></script>
<p>I&rsquo;ve been fiddling with <a href="http://www.snippetsapp.com/">Snippets</a> and noticed it supported posting to <a href="http://snipplr.com">Snipplr</a>.  I&rsquo;m not sure if I really <em>need</em> Snippets, but I like that Snipplr has a WordPress plugin and a TextMate bundle.</p>
<p>Anyone in the sound of my voice used Snipplr and have anything good or bad to say about it?</p>
<p>#adium #appscript #futz #im #ruby</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Set%20Your%20Adium%20Status%20With%20rb-appscript">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Panopticon 0.1</title>
      <link>https://mike.puddingtime.org/posts/2010-06-30-panopticon-0-1/</link>
      <pubDate>Wed, 30 Jun 2010 03:15:02 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2010-06-30-panopticon-0-1/</guid>
      
      <description>So, panopticon 0.1 is very simple and it handles:
recently flagged e-mail in several accounts recently flagged/starred items in my RSS reader (NetNewsWire, in sync with Google Reader) recently created notes in my Evernote account recently added Instapaper items It executes in a few seconds and adds …</description>
      <content:encoded><![CDATA[<p>So, panopticon 0.1 is very simple and it handles:</p>
<ul>
<li>recently flagged e-mail in several accounts</li>
<li>recently flagged/starred items in my RSS reader (NetNewsWire, in sync with Google Reader)</li>
<li>recently created notes in my Evernote account</li>
<li>recently added Instapaper items</li>
</ul>
<p>It executes in a few seconds and adds everything it finds from each of those inboxes to my &ldquo;Today&rdquo; list, tagged with &ldquo;panopticon&rdquo; and the name of the source, with a due date of 5 p.m.</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-gdscript3" data-lang="gdscript3"><span class="line"><span class="cl"><span class="o">&lt;</span><span class="n">div</span> <span class="n">style</span><span class="o">=</span><span class="s2">&#34;text\-align:center;margin:1em;&#34;</span><span class="o">&gt;!</span><span class="p">[](</span><span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">media</span><span class="o">.</span><span class="n">puddingtime</span><span class="o">.</span><span class="n">org</span><span class="o">/</span><span class="n">archive</span><span class="o">/</span><span class="n">mph</span><span class="o">.</span><span class="n">puddingbowl</span><span class="o">.</span><span class="n">org</span><span class="o">/</span><span class="n">wordpress</span><span class="o">/</span><span class="n">wp</span><span class="o">-</span><span class="n">content</span><span class="o">/</span><span class="n">uploads</span><span class="o">/</span><span class="mi">2010</span><span class="o">/</span><span class="mi">06</span><span class="o">/</span><span class="n">things_list_s</span><span class="o">.</span><span class="n">jpg</span><span class="p">)</span><span class="o">&lt;/</span><span class="n">div</span><span class="o">&gt;</span></span></span></code></pre></div>
<p>I described the point <a href="http://mph.puddingbowl.org/2010/06/feedback-loop/">yesterday</a>. Restated:</p>
<p>If you&rsquo;re one of those people who needs to stop at the end of the day and turn out your pockets, making sure you put your keys in the key place, and your change in a little bowl, and loose receipts wherever you put those, that&rsquo;s what panopticon is doing for me: Helping me put everything I&rsquo;ve accumulated from the &rsquo;net over the past day in a little glass bowl. That way it won&rsquo;t get run through the wash or carelessly emptied into the trash.</p>
<p>It&rsquo;s really not done at all, but I&rsquo;ve learned that it&rsquo;s best for me to do the bare minimum to make a thing work before I lose interest in a project. I can always fiddle with it later. So some things I&rsquo;ve left out for now:</p>
<ul>
<li>passing e-mail and RSS items through the summarize service (<a href="http://mph.puddingbowl.org/2009/02/inbox-glue/">described here last February</a>) to populate the to-do body</li>
<li>Things adding the ability to create live links to web pages and messages using the <code>message://</code> URL handler built into OS X in to-do bodies, but that&rsquo;s on them.</li>
<li>Checking the Things Logbook list to make sure there&rsquo;s not a recent item of the same title and source that&rsquo;s been completed and so is not on the list.</li>
<li>exception handling. I mean, why not create a to-do out of &ldquo;something&rsquo;s going wrong with this script&rdquo; when something goes wrong with the script?</li>
</ul>
<p>To change:</p>
<ul>
<li>The whole &ldquo;what&rsquo;s been seen, what&rsquo;s been completed?&rdquo; thing is due for some more thought, really.</li>
<li>Figuring out how I can do more of this outside of rb-appscript. The big advantage of using appscript instead of consuming a bunch of services and feeds is that you don&rsquo;t have to go around either finding gems that talk to assorted APIs or parsing the JSON, etc. that they send back on their own, ask for API keys, etc. You just talk to the apps you use to consume those services. The problem with that approach is that it only works on a Mac.  If the giant Mac-eating space robots turn up and enslave us all, ushering in an era where no computer more robust than an Ubuntu netbook is permitted to function on the surface of the planet, I&rsquo;m screwed.</li>
</ul>
<p>I&rsquo;d file it under &ldquo;secret software,&rdquo; but it&rsquo;s not because it&rsquo;s posted here. But it&rsquo;s at about that level: Won&rsquo;t blow anything up, even when it doesn&rsquo;t work it will help me a lot more than if it weren&rsquo;t running at all.</p>
<p>What continues to be awesome to me about it all: 81 lines of code. The magic is all in the eight &lsquo;require&rsquo; lines at the top, where much more talented people provide me with the tools I need to say things in such a simple, forgiving way.  I mean ...</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">notes = @evernote\.notebooks\[&#34;Inbox&#34;\]\.notes\[its\.creation\_date\.gt\(Time\.now \- 2\.days\)\]\.get</span></span></code></pre></div>
<p>That&rsquo;s just neat.</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;div id=&#34;snipplr\_embed\_36663&#34; class=&#34;snipplr\_embed&#34;&gt;&lt;a href=&#34;http://snipplr\.com/view/36663/panopticon/&#34;&gt;Code snippet \- Panopticon&lt;/a&gt; on Snipplr&lt;/div&gt;&lt;script type=&#34;text/javascript&#34; src=&#34;http://snipplr\.com/js/embed\.js&#34;&gt;&lt;/script&gt;&lt;script type=&#34;text/javascript&#34; src=&#34;http://snipplr\.com/json/36663&#34;&gt;&lt;/script&gt;</span></span></code></pre></div>
<p>#adhd #appscript #attention #panopticon #ruby</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Panopticon%200.1">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Feedback Loop</title>
      <link>https://mike.puddingtime.org/posts/2010-06-29-feedback-loop/</link>
      <pubDate>Tue, 29 Jun 2010 05:53:39 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2010-06-29-feedback-loop/</guid>
      
      <description>&lt;div style=&#34;text\-align:center;margin:1em;&#34;&gt;![](https://media.puddingtime.org/archive/mph.puddingbowl.org/wordpress/wp-content/uploads/2010/06/panopticon.jpg)&lt;/div&gt; I remember an article from eleven or so years ago that explained how to use Perl to spider the Web and collect links to new pages from …</description>
      <content:encoded><![CDATA[





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-gdscript3" data-lang="gdscript3"><span class="line"><span class="cl"><span class="o">&lt;</span><span class="n">div</span> <span class="n">style</span><span class="o">=</span><span class="s2">&#34;text\-align:center;margin:1em;&#34;</span><span class="o">&gt;!</span><span class="p">[](</span><span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">media</span><span class="o">.</span><span class="n">puddingtime</span><span class="o">.</span><span class="n">org</span><span class="o">/</span><span class="n">archive</span><span class="o">/</span><span class="n">mph</span><span class="o">.</span><span class="n">puddingbowl</span><span class="o">.</span><span class="n">org</span><span class="o">/</span><span class="n">wordpress</span><span class="o">/</span><span class="n">wp</span><span class="o">-</span><span class="n">content</span><span class="o">/</span><span class="n">uploads</span><span class="o">/</span><span class="mi">2010</span><span class="o">/</span><span class="mi">06</span><span class="o">/</span><span class="n">panopticon</span><span class="o">.</span><span class="n">jpg</span><span class="p">)</span><span class="o">&lt;/</span><span class="n">div</span><span class="o">&gt;</span></span></span></code></pre></div>
<p>I remember an article from eleven or so years ago that explained how to use Perl to spider the Web and collect links to new pages from my favorite sites. I don&rsquo;t remember all the details, except that it was written from a perspective that seems very alien now, because there are just so many ways to have things delivered now. I&rsquo;m sure some folks still find some benefit automating the retrieval of some things in that fashion, but for general-purpose &ldquo;keeping up with daily stuff,&rdquo; you can get an awful lot done with a custom section on your favorite news site and a healthy collection of RSS feeds to the right aggregator sites.</p>
<p>I&rsquo;m thinking about the problems that lump of Perl solved right now because it&rsquo;s become so easy to have so much just arrive on my computer&rsquo;s doorstep that the volume of information I might receive and want or need to deal with over the Web or wider &rsquo;net is beginning to feel like a deluge in its own right.</p>
<p>Here&rsquo;s a list of electronic inboxes I put things in each day:</p>
<ul>
<li>flagged/starred items in my mail</li>
<li>delicious bookmarks</li>
<li>Evernote notes</li>
<li>flagged/starred RSS articles</li>
<li>Instapaper items</li>
<li>Things todos</li>
</ul>
<p>A list of collection points:</p>
<ul>
<li>iPhone</li>
<li>iPad</li>
<li>Mac</li>
<li>MacBook (targeted for removal from the inventory, but still here for now, even if it isn&rsquo;t seeing a lot of use)</li>
</ul>
<p>I gather a lot of information in a lot of apps or services, and I usually pick the apps or services based on how frictionless it is to capture something into it along with how portable it is.  I love Evernote&rsquo;s Web clipper, for instance, because it&rsquo;s just sitting there waiting to be used and it takes very little effort to clip a new note and go on with what I&rsquo;m doing, and I can then get at that note from anywhere I&rsquo;m connected to the &rsquo;net. In fact, the collection process is so frictionless with a lot of these tools that the real challenge is keeping track of all the things that I come across and can&rsquo;t do something with ​<em>right now</em>​.</p>
<p>When I think about what I&rsquo;m doing with each of those tools I use to gather collections of things, I&rsquo;ve made the mistake of thinking of those things very narrowly: &ldquo;This is a bookmark,&rdquo; &ldquo;this is an interesting article,&rdquo; &ldquo;this is an e-mail message with an article I need to edit.&rdquo;  But that&rsquo;s way too narrow, because what they all really are is things I need to do, whether the &ldquo;doing&rdquo; is reading them, passing them along to someone else.</p>
<p>While I&rsquo;ve got a nice todo program that runs on every computer or device I own (<a href="http://culturedcode.com/">Things</a>), it&rsquo;s not easy or practical to turn all those things I gather into todos at the time they&rsquo;re created—that&rsquo;s a second step— and it&rsquo;s not really easy to circle back and sweep all those things up because they live a bunch of places. Even though Things runs on everything I own, it&rsquo;s sort of uneven in terms of what it can capture where. On an iPhone or iPad, for instance, Things requires a whole context switch to get something saved to it. It&rsquo;s more fluid and adaptable on my desktop or laptop.</p>
<p>Because the central point of my computing life is my desktop computer (an iMac), and because all the apps I use to deal with all these inboxes offer an AppleScript dictionary of some kind, the act of gathering up all the stuff in each of those inboxes  can be automated based on finding items based on their creation date (the last couple of days) and their uniqueness (don&rsquo;t already have a to-do with identical title, comments and source service).</p>
<p>Some sample gathering queries from two that I knocked off this morning, just to show how easy it is to find stuff using [rb language=&quot;-appscript&quot;]<a href="http://appscript.sourceforge.net/rb-appscript/index.html">/rb</a>:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">en = app\(&#34;Evernote&#34;\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">notes = en\.notebooks\[&#34;Inbox&#34;\]\.notes\[its\.creation\_date\.gt\(Time\.now \- 2\.days\)\]\.get</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">nnw = app\(&#34;NetNewsWire&#34;\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">flagged\_rss = nnw\.subscriptions\[its\.display\_name\.eq\(&#39;Flagged Items&#39;\)\]\.first\.get</span></span></code></pre></div>
<p>And all the code you need to make a new todo in Things:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">things = app\(&#34;Things&#34;\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">task = things\.make\(:at =&gt; app\.lists\[&#34;Today&#34;\]\.beginning,</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>```
</code></pre>
<p>:new =&gt; :to_do,</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl"> </span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">    ```
</span></span><span class="line"><span class="cl">:with\_properties =&gt; \{:name =&gt; my\_title,</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code>```
</code></pre>
<p>:tag_names =&gt; &ldquo;panopticon&rdquo;, :notes =&gt; my_note,</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl"> </span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">    ```
</span></span><span class="line"><span class="cl">:due\_date =&gt; Time\.now \+ 8\.hours</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">\}\)</span></span></code></pre></div>
<p>I&rsquo;ve got a skeleton of something I&rsquo;m tagging as &ldquo;panopticon&rdquo;  that uses those two basic ideas as a script I can run now and then (though always first thing in the morning) to sweep up all those inboxes into the one inbox best equipped to get me to act on them: Things&rsquo; &ldquo;Today&rdquo; list.</p>
<p>Once everything is gathered up  and turned into todos, Things provides a nice interface for going down through them and either adding them to a project, doing something with them on the spot, deferring action on them, remembering to refile them, or deciding they weren&rsquo;t that important after all.  It&rsquo;s only one thing to remember (&ldquo;look in Things each morning&rdquo;), and I don&rsquo;t have to go visit each service each day to make sure there&rsquo;s not something in there I need to be doing.</p>
<p>I also get to keep using each service for what it&rsquo;s good for. I&rsquo;m not so much transmuting a bit of information into a bundle of potential action as I am cloning it into a bundle of potential action while the original runs around wherever it&rsquo;s happiest, in a format where it&rsquo;s most useful as a form of long-term recall.</p>
<p>#adhd #appscript #attention #information overload #panopticon #ruby #todos</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Feedback%20Loop">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>New Transmit - Use It With rb-appscript</title>
      <link>https://mike.puddingtime.org/posts/2010-04-28-new-transmit-use-it-with-rb-appscript/</link>
      <pubDate>Wed, 28 Apr 2010 02:47:55 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2010-04-28-new-transmit-use-it-with-rb-appscript/</guid>
      
      <description>Hey … there’s a new version of Transmit out. They added some neat stuff (like being able to mount remote volumes on your Desktop) and changed the AppleScript dictionary a little.
I use Transmit and appscript to update a pair of files on an ftp server each day. I used to use Ruby’s built-in ftp …</description>
      <content:encoded><![CDATA[<p>Hey &hellip; there&rsquo;s a <a href="http://www.panic.com/blog/2010/04/transmit-4-0/">new version of Transmit</a> out.  They added some neat stuff (like being able to mount remote volumes on your Desktop) and changed the AppleScript dictionary a little.</p>
<p>I use Transmit and appscript to update a pair of files on an ftp server each day.  I used to use Ruby&rsquo;s built-in ftp library, but I ran into a few cases where I&rsquo;d make a mistake during editing and only realize it  once I&rsquo;d uploaded the files. It was helpful to have a regular ftp app open so I could go back and make quick corrections.</p>
<p>As always, <a href="http://appscript.sourceforge.net/tools.html">AS Translate</a> is really handy.  You can use it to paste native AppleScript into a window and get a translation to rb-appscript. That makes translating Panic&rsquo;s sample AppleScript into usable Ruby a five minute process.</p>
<p>I use <a href="http://www.chungwasoft.com/Shimo/">Shimo</a> to manage my VPN connection, so my script checks to see if Shimo is active and connected. This is a little crude, because I only have one VPN connection to worry about, so I don&rsquo;t check to make sure it&rsquo;s the right one:</p>
<pre><code>require &quot;rubygems&quot;

require &quot;appscript&quot;

include Appscript

transmit = app(&quot;Transmit&quot;)

shimo = app(&quot;Shimo&quot;)

status = shimo.controller.connected.get

unless status == true

	puts &quot;Connecting with VPN ...&quot;

	shimo.connect(:with_profile =&gt; &quot;colo&quot;)

	was_up = false

else

	puts &quot;Already connected to the VPN ...&quot;

	was_up = true

end
</code></pre>
<p>Then I set up a few variables. One of the files I edit (news_index) is named based on the month:</p>
<pre><code>host = &quot;remotenewshost.com&quot;

user = &quot;username&quot;

pass = &quot;password&quot;

path = &quot;/news/articles/&quot;

latest_news = &quot;latest_news.html&quot;

news_index = Date.today.strftime(&quot;news_%m_%y.htm&quot;)

transmit.make(:new =&gt; :document)

doc = transmit.documents[0]

doc.current_tab.connect(:to_address =&gt; host,

	:with_password =&gt; pass,

	:as_user =&gt; user,

	:with_initial_path =&gt; path)
</code></pre>
<p>Then I download the files I need. If it&rsquo;s early in the month, one of them might not exist on the remote server, so I pull a copy of a template I store locally. There are native Ruby commands to move files around, but I just don&rsquo;t bother.</p>
<pre><code>doc.current_tab.remote_browser.download(

	:with_resume_mode =&gt; :overwrite, 

	:to =&gt; &quot;~/	Desktop&quot;, 

	:item_at_path =&gt; &quot;{path}{latest_news}&quot;)

list = doc.current_tab.remote_browser.browser_items.name.get

if list.include?(news_index)

	puts &quot;Found monthly index, downloading ...&quot;

	doc.current_tab.remote_browser.download(

		:with_resume_mode =&gt; :overwrite, 

		:to =&gt; &quot;~/Desktop&quot;, 

		:item_at_path =&gt; &quot;{path}{news_index}&quot;)

else

  puts &quot;Didn't find monthly index, copying from a template ...&quot;

  `cp /Users/mike/Documents/Application\ Data/pracnet_news_index_skel.htm\

	 /Users/mike/Desktop/{latest_news}`

end
</code></pre>
<p>Then I open the files in my text editor, TextMate:</p>
<pre><code>`mate -w /Users/mike/Desktop/{latest_news}`

`mate  -l 25 -w /Users/mike/Desktop/{news_index}`
</code></pre>
<p>The &ldquo;-l 25&rdquo; tells TextMate to place the cursor at line 25 of the file, which is after all the header junk. It saves me cursoring to where I need to go.</p>
<p>Then I squirt the files back up:</p>
<pre><code>puts &quot;Uploading latest news file ...&quot;

doc.current_tab.remote_browser.upload(:with_resume_mode =&gt; :overwrite, :to =&gt; \

path, :item_at_path =&gt; &quot;~/Desktop/{latest_news}&quot;)

puts &quot;Uploading monthly news file ...&quot;

doc.current_tab.remote_browser.upload(:with_resume_mode =&gt; :overwrite, :to =&gt;\

path, :item_at_path =&gt; &quot;~/Desktop/{news_index}&quot;)
</code></pre>
<p>and check to see what the status of the VPN connection was when I started the script to determine whether to keep it open or bring it down:</p>
<pre><code>if was_up == false

  puts &quot;Shutting down VPN connection ...&quot;

  shimo.disconnect

else

  puts &quot;VPN connection was up at launch ... keeping it up and ending.&quot;

end
</code></pre>
<p>Know what&rsquo;s awful?  My employer won&rsquo;t allow me to connect this way for much longer. Some time in the next 30 days, I&rsquo;ll be forced to do all this from a Windows machine. No more Transmit, no more rb-appscript. I can dig out the code I wrote that uses the standard Ruby ftp library, but it won&rsquo;t be as handy.</p>
<p>Rats.</p>
<p>#appscript #ruby #shimo #transmit</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20New%20Transmit%20-%20Use%20It%20With%20rb-appscript">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Scripting iWork Numbers &#39;09 With Appscript</title>
      <link>https://mike.puddingtime.org/posts/2009-03-12-scripting-iwork-numbers-09-with-appscript/</link>
      <pubDate>Thu, 12 Mar 2009 00:53:09 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2009-03-12-scripting-iwork-numbers-09-with-appscript/</guid>
      
      <description>Simple work problem: I need to keep a log of stories published on the sites I cover. Part one of the problem is getting all the existing stories into the log. Part two of the problem is getting new stories into the log as I publish them from now on.
I was pretty excited about taking Numbers ‘09’s …</description>
      <content:encoded><![CDATA[<p>Simple work problem:  I need to keep a log of stories published on the sites I cover. Part one of the problem is getting all the existing stories into the log.  Part two of the problem is getting new stories into the log as I publish them from now on.</p>
<p>I was pretty excited about taking Numbers &lsquo;09&rsquo;s scripting support out for a spin. Unfortunately it&rsquo;s a little anemic, especially compared to full-featured Ruby libraries like <a href="http://roo.rubyforge.org/">roo</a> and <a href="http://spreadsheet.rubyforge.org/">spreadsheet</a>. For instance, it doesn&rsquo;t really have a conception of &ldquo;the last row with data in it,&rdquo; as the other two do.  So you can&rsquo;t just plop new data into the first empty row without doing something like iterating through all rows and finding the first one where a particular cell is empty. I uploaded <a href="http://mph.puddingbowl.org/ruby/Numbers-rb/index.html">the appscript-exported Numbers scripting dictionary</a> if you&rsquo;re curious about what it can do.</p>
<p>There&rsquo;s some interesting room to grow for both scripts.  In addition to tracking stories, we have to keep up with their overall performance.  With the <a href="http://github.com/robmckinnon/rugalytics/tree/master">rugalytics</a> gem it&rsquo;s possible to mine performance data from Google Analytics based on the title of a given article or regular expressions taken from the URL.</p>
<p>Anyhow, this one solves part one.  It&rsquo;s a one-time-only importer that runs through the indexes for each container and grabs everything:</p>
<pre><code>    [sourcecode language=&quot;ruby&quot;]

    !/usr/bin/env ruby

    require 'rubygems'

    require 'appscript'

    include Appscript

    require '/Users/mph/lib/ruby/CDEV.rb'

    require 'hpricot'

    require 'open-uri'

    include Hpricot

    num = app(&quot;Numbers&quot;)

    ss = num.open(&quot;/Users/mph/Desktop/Invoices.numbers&quot;)

    sheet = ss.sheets[&quot;Invoices&quot;]

    table = sheet.tables[&quot;Current Quarter&quot;]

    containers = [&quot;netsysm&quot;, &quot;nethub&quot;, &quot;netsecur&quot;, &quot;linux_unix&quot;, &quot;netos&quot;, &quot;windows&quot;]

    base_url = &quot;http://enterprisenetworkingplanet.com/&quot;

    cdevids = []

    containers.each do |con|

      page = Hpricot(open(&quot;{base_url}{con}&quot;))

      index = page.search(&quot;//div[@class='section_index_list'&quot;)

      articles = index.search(&quot;//div[@class='post']&quot;)

      articles.each do |a|

        link =  a.search(&quot;//h3/a&quot;).first

        url =  link[:href]

        art = CDEV.new(url)

        unless cdevids.include?(art.id)

          cdevids &lt;&lt; art.id

          title = art.title

          url = art.url

          author = art.author

          pubdate = art.pubdate.strftime(&quot;%m/%d/%y&quot;)

          row = table.rows.add_row_above(table.rows[2])

          table.rows[2].cells[1].value.set(author)

          table.rows[2].cells[2].value.set(pubdate)

          table.rows[2].cells[3].value.set(title)

          table.rows[2].cells[6].value.set(url)

        end

      end

    end

    [/sourcecode]
</code></pre>
<p>This one is for part two.  It&rsquo;s just part one stripped down and cast toward working on the foremost window in Safari, so when I&rsquo;m giving an article a look from the front-end to make sure the CMS didn&rsquo;t mangle it, I can run the script and capture the article info in my spreadsheet.</p>
<p>This one points to another oversight in the existing dictionary for Numbers &lsquo;09:  One of the new features in the software is something called &ldquo;Table Categories.&rdquo;  You can pick any column and create a category based on its content.  It&rsquo;s handy for things like quarterly invoicing, because you can take a lump of rows, create a table category out of the publication date and get a nicely sorted table with quarterly subtotals for each month. That poses two problems for my script:</p>
<ol>
<li>
<p>When a spreadsheet has active Table Categories, you can&rsquo;t add a row to it.</p>
</li>
<li>
<p>The Table Categories functionality doesn&rsquo;t exist in the current Numbers scripting dictionary.</p>
</li>
</ol>
<p>So if the script is run while the table is categorized, it fails. It doesn&rsquo;t have any way to query the table and figure out if it&rsquo;s categorized, so I had to fall back on UI scripting to look for whether the &ldquo;Table&rdquo; menu has an item that reads &ldquo;Disable All Categories.&rdquo;  If it does, the script clicks the menu item. Once the script is done adding stuff, it clicks a menu item called &ldquo;Enable All Categories&rdquo; to put the table into a more readable state again.</p>
<p>I hate UI scripting. <a href="http://blog.zenspider.com/2007/07/applescript-is-a-pita-exportin.html">Another blog entry</a> gave me a head start on figuring out what to call the menu items I needed to find, and <a href="http://appscript.sourceforge.net/tools.html">ASTranslate</a> did me the favor of cutting through all the Applescript hyperventilation and rendering things down to something more usable.</p>
<p>So anyhow:</p>
<pre><code>[sourcecode language=&quot;ruby&quot;]



!/usr/bin/env ruby

require 'rubygems'

require 'appscript'

require '/Users/mph/lib/ruby/CDEV.rb'

include Appscript

num = app(&quot;Numbers&quot;)

saf = app(&quot;Safari&quot;)

num_sys = app(&quot;System Events&quot;).application_processes[&quot;Numbers&quot;]

num_cat_menu = num_sys.menu_bars[1].menu_bar_items[&quot;Table&quot;].menus[1]

num_cat_disable = num_cat_menu.menu_items[&quot;Disable All Categories&quot;]

num_cat_enable = num_cat_menu.menu_items[&quot;Enable All Categories&quot;]

ss = num.open(&quot;/Users/mph/Desktop/Invoices.numbers&quot;)

sheet = ss.sheets[&quot;Invoices&quot;]

table = sheet.tables[&quot;Current Quarter&quot;]

num.activate

table.activate

page = saf.documents[0].get

url = page.URL.get

art = CDEV.new(url)

title = art.title

url = art.url

author = art.author

pubdate = art.pubdate.strftime(&quot;%m/%d/%y&quot;)

num_sys.frontmost.set(true)

if num_cat_disable.exists

 num_cat_disable.click

end

row = table.rows.add_row_above(table.rows[2])

table.rows[2].cells[1].value.set(author)

table.rows[2].cells[2].value.set(pubdate)

table.rows[2].cells[3].value.set(title)

table.rows[2].cells[6].value.set(url)

num_cat_enable.click

 [/sourcecode]
</code></pre>
<p>#appscript #iwork #numbers #ruby</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Scripting%20iWork%20Numbers%20%2709%20With%20Appscript">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Inbox Glue</title>
      <link>https://mike.puddingtime.org/posts/2009-02-19-inbox-glue/</link>
      <pubDate>Thu, 19 Feb 2009 23:24:39 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2009-02-19-inbox-glue/</guid>
      
      <description>MailTags is handy because it lets you assign due-dates (“tickle dates”) to incoming messages. One problem I’ve got with anything like that, though, is that I’ve already got an inbox for e-stuff in the form of Evernote. It’s possible to forward messages to Evernote for clipping, but I like having a …</description>
      <content:encoded><![CDATA[<p><a href="http://www.indev.ca/MailTags.html">MailTags</a> is handy because it lets you assign due-dates (&ldquo;tickle dates&rdquo;) to incoming messages. One problem I&rsquo;ve got with anything like that, though, is that I&rsquo;ve already got an inbox for e-stuff in the form of Evernote.  It&rsquo;s possible to forward messages to Evernote for clipping, but I like having a list of actionable messages for a given day in one place, hence the script below.</p>
<p>It goes through my &rsquo;tickler&rsquo; mail folder and pulls anything with a tickle date of the current day or earlier, finds Evernote notes tagged with today&rsquo;s date (I haven&rsquo;t gotten around to parsing the tags so I can grab earlier notes), and compiles them into a single Evernote note item.  I write other to-dos on a printed copy, which gives me a one-stop place to find everything.</p>
<p>One beef:  Evernote&rsquo;s HTML interpreter is sub-par.  It doesn&rsquo;t understand Apple&rsquo;s <code>message://</code> URIs, so it&rsquo;s not possible to dump an Evernote item with hyperlinks to messages as they appear in Mail.app.  I&rsquo;m guessing the way around that might involve importing an HTML file (instead of building a note object and storing HTML in it), but I haven&rsquo;t bothered testing yet.  I just dump plain text into the note for now.</p>
<p>One semi-neat thing is its use of the Mac &lsquo;Summarize&rsquo; feature in Applescript.  It lets you take something like <a href="http://www.google.com/hostednews/ap/article/ALeqM5iWxiu65iLP4CvDJ7BEsBOx-u_vdwD96DK3HO0">this article from the AP</a> and render it into a summary:</p>
<blockquote>
<p>&ldquo;President Barack Obama approved adding some 17,000 U.S. troops for the flagging war in Afghanistan, his first significant move to change the course of a conflict that his closest military advisers have warned the United States is not winning.&rdquo;</p>
</blockquote>
<p>The AppleScript syntax for that is just:</p>
<pre><code>summarize &quot;some text&quot; in 1
</code></pre>
<p>where &ldquo;1&rdquo; is the number of paragraphs you want back.</p>
<p>In Ruby/appscript, it&rsquo;s:</p>
<pre><code>osax.summarize(&quot;some text&quot;)
</code></pre>
<p>So when the script goes through the day&rsquo;s e-mail messages, it passes the message text through the summarizer, which has a better chance of getting me a useful nut than a simple <code>string.slice[0,200]</code> approach (though sometimes it misses in a way that at least provokes some stimulating head-scratching).</p>
<p>One other curiosity in this script.  Sometimes native Applescript has to use the &lsquo;using terms from&rsquo; convention.  MailTags is one such case. It tells Applescript that you&rsquo;re &rsquo;tell&rsquo;-ing Mail something, but you need the supplemental dictionary provided by the MailTags add-on.  rb-appscript doesn&rsquo;t allow for that, quite, so you&rsquo;ve got to do <a href="http://rubyforge.org/pipermail/rb-appscript-discuss/2008-October/000184.html">a little dancing around</a>.</p>
<pre><code>[sourcecode language=&quot;ruby&quot;]

!/usr/bin/env ruby

require 'rubygems'

require 'appscript'

require 'Date'

include Appscript

require 'osax'

include OSAX

require '/Users/mph/lib/ruby/mailtags.rb'

require 'erb'

today = Date.today.strftime(&quot;%Y-%m-%d&quot;)

title = &quot;Tickler File for {Date.today.strftime(&quot;%A, %B %d&quot;)}&quot;

mail = app(&quot;Mail&quot;, MailTags)

en = app(&quot;EverNote&quot;)

nb = en.notebooks[&quot;tickler&quot;]

ical = app(&quot;ical&quot;)

note = &quot;&quot;

messages = mail.accounts[&quot;Gmail&quot;].mailboxes[&quot;tickler&quot;].messages.get

notes = nb.notes.get

todays_notes = []

todays_messages = []

notes.each do |n|

  n.tags.get.each do |t|

    if t.to_s =~ /{today}/

      todays_notes &lt;&lt; n

    end

  end

end

messages.each do |m|

  due_date = m.due_date.get.strftime(&quot;%Y-%m-%d&quot;)

  if due_date &gt;= today

    todays_messages &lt;&lt; m

  end

end

template = &lt;&lt;END

Tickler File for &lt;%= Date.today.strftime(&quot;%A, %B %d&quot;) %&gt;



Today's Messages

=================================================

&lt;% todays_messages.each do |m| %&gt;

  [  ] &lt;%= m.subject.get %&gt; (due &lt;%= m.due_date.get.strftime(&quot;%m/%d&quot;) %&gt;)

  from &lt;%= m.sender.get %&gt; on &lt;%= m.date_sent.get.strftime(&quot;%A, %B %d&quot;) %&gt;

  &quot;&lt;%= osax.summarize(m.content.get).strip %&gt;&quot;







--------------------------------------------------------------------------------------------------

&lt;% end %&gt;

Today's Notes

=================================================

&lt;% todays_notes.each do |n| %&gt;

[  ] &lt;%= n.title.get %&gt;

&lt;%end %&gt;

END

tickle_text = ERB.new(template).result

tickle_note = en.create_note(:title =&gt; title, :notebook =&gt; &quot;Inbox&quot;, :with_text =&gt; tickle_text)

[/sourcecode]
</code></pre>
<p>#appscript #attention #evernote #mail #ruby</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Inbox%20Glue">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Save to Instapaper from NetNewsWire</title>
      <link>https://mike.puddingtime.org/posts/2009-02-10-save-to-instapaper-from-netnewswire/</link>
      <pubDate>Tue, 10 Feb 2009 06:30:23 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2009-02-10-save-to-instapaper-from-netnewswire/</guid>
      
      <description>At some point some applescripts I found for posting from NetNewsWire to Instapaper broke. A few days ago, during one of my rare jaunts to the bottom of the Instapaper homepage I came across a reference to the Read Later API. I wrote it down on my todo list as a thing to deal with over lunch some …</description>
      <content:encoded><![CDATA[<p>At some point some applescripts I found for posting from NetNewsWire to <a href="http://instapaper.com">Instapaper</a> broke. A few days ago, during one of my rare jaunts to the bottom of the Instapaper homepage I came across a reference to the <a href="http://blog.instapaper.com/post/73123968/read-later-api">Read Later API</a>. I wrote it down on my todo list as a thing to deal with over lunch some day.</p>
<p>The API involves nothing more than an HTTP request with a half-dozen parameters, a few of which are optional. I stopped shy of simulating the wonderful Instapaper response popup, settling instead on a system beep:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;p&gt;</span></span></code></pre></div>
<p>[sourcecode language=&lsquo;ruby&rsquo;]</p>
<p>!/usr/bin/env ruby</p>
<p>require &lsquo;rubygems&rsquo;</p>
<p>require &lsquo;open-uri&rsquo;</p>
<p>require &lsquo;openssl&rsquo;</p>
<p>require &lsquo;appscript&rsquo;</p>
<p>include Appscript</p>
<p>require &lsquo;osax&rsquo;</p>
<p>include OSAX</p>
<p>username = &ldquo;USERNAME&rdquo;</p>
<p>password = &ldquo;PASSWORD&rdquo;</p>
<p>nnw = app(&ldquo;NetNewsWire&rdquo;)</p>
<p>OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE</p>
<p>item = nnw.selectedHeadline.get</p>
<p>url = URI.encode(item.URL.get).gsub!(/^htt.+?///, &ldquo;&rdquo;)</p>
<p>title = item.title.get</p>
<p>description = item.description.get.gsub!(/&lt;.+?&gt;/, &ldquo;&rdquo;)</p>
<p>selection = description.length &gt; 150 ? description.slice(0,150) + &quot; ...&quot; : description</p>
<p>base_url = &ldquo;https://www.instapaper.com/api/add?&rdquo;</p>
<p>params = &ldquo;title={title}&amp;url={url}&amp;username={username}&amp;password={password}&amp;selection={selection}&rdquo;</p>
<p>post_url = &ldquo;{base_url}{params}&rdquo;</p>
<p>begin</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">response = open\(URI\.encode\(post\_url\)\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">osax\.beep</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">or display a dialog:</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">osax\.display\_dialog\(&#34;Posted\.&#34;\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">rescue =&gt; ex</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">case ex\.message\.gsub\(/\\s\.\*/, &#34;&#34;\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code> ```
</code></pre>
<p>when &ldquo;400&rdquo; : message = &ldquo;Error: Bad Request.&rdquo;</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">     ```
</span></span><span class="line"><span class="cl">when &#34;403&#34; : message = &#34;Bad password/username\.&#34;</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code> ```
</code></pre>
<p>when &ldquo;500&rdquo; : message = &ldquo;Server error.&rdquo;</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>end</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>osax.display_dialog(message)</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">end
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">\[/sourcecode\]</span></span></code></pre></div>
</p>
```
<p>#appscript #instapaper #netnewswire #ruby</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Save%20to%20Instapaper%20from%20NetNewsWire">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
    <item>
      <title>Quixotic, Appscript, Mail</title>
      <link>https://mike.puddingtime.org/posts/2009-01-18-quixotic-appscript-mail/</link>
      <pubDate>Sun, 18 Jan 2009 12:35:32 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2009-01-18-quixotic-appscript-mail/</guid>
      
      <description>I don’t know why I get into these things.
Below is a script that takes the selected messages in Mail.app and saves them to Yojimbo, which I like a lot for keeping schtuff.
Some things that might have told me to quit and use someone else’s AppleScript instead of rolling my own:
First, I couldn’t …</description>
      <content:encoded><![CDATA[<p>I don&rsquo;t know why I get into these things.</p>
<p>Below is a script that takes the selected messages in Mail.app and saves them to <a href="http://www.barebones.com/products/Yojimbo/">Yojimbo</a>, which I like a lot for keeping schtuff.</p>
<p>Some things that might have told me to quit and use someone else&rsquo;s AppleScript instead of rolling my own:</p>
<p>First, I couldn&rsquo;t figure out how to make rb-appscript work with references between apps.  So the part that grabs the attachment from Mail has no way to say to the part that imports the attachment to Yojimbo, &ldquo;Hey &hellip; this object here is a file.  Deal with it.&rdquo; Instead, the file has to be stowed somewhere then picked up for use by Yojimbo.</p>
<p>Second, Yojimbo can&rsquo;t import everything &hellip; like zip files, for instance. So instead of just doing something to catch exceptions I decided to go and read the MIME types of attachments then check them against an array of legal file types.</p>
<p>On the other hand, I can tag the attachments as they&rsquo;re imported, and this is much faster than dragging the attachments into Yojimbo, because I can tie it to a <a href="http://www.indev.ca/MailActOn.html">Mail Act-On</a> keystroke (and because Mail.app gets really slow with attachment handling sometimes, even if you don&rsquo;t mind mousing).</p>
<p>And there&rsquo;s one other good reason to do stuff like this:  I&rsquo;d rather get the practice with Ruby than crib AppleScript from someone else.   I&rsquo;ll take <code>foo.split(',')</code> over <code>set AppleScript's text item delimiters to &quot;,&quot; </code> any day of the week.</p>
<p>
<p>[sourcecode language=&lsquo;ruby&rsquo;]</p>
<p>!/usr/bin/ruby</p>
<p>require &lsquo;rubygems&rsquo;</p>
<p>require &lsquo;appscript&rsquo;</p>
<p>require &lsquo;mime/types&rsquo;</p>
<p>require &lsquo;osax&rsquo;</p>
<p>include OSAX</p>
<p>include Appscript</p>
<p>mail = app(&ldquo;Mail&rdquo;)</p>
<p>yoj = app(&ldquo;Yojimbo&rdquo;)</p>
<p>tmpdir = &ldquo;/Users/mph/tmp&rdquo;</p>
<p>legal_files = [&ldquo;image/gif&rdquo;, &ldquo;image/jpeg&rdquo;, &ldquo;application/pdf&rdquo;, &ldquo;image/png&rdquo;, &ldquo;application/word&rdquo;,&ldquo;text/plain&rdquo;, &ldquo;application/msword&rdquo;, &ldquo;text/html&rdquo;]</p>
<p>messages = mail.selection.get</p>
<p>messages.each do |m|</p>
<p>m.mail_attachments.get.each do |a|</p>
<pre><code>tmpfile = &quot;{tmpdir}/{a.name.get}&quot;



a.save(:in =&gt; tmpfile)

type = MIME::Types.type_for(tmpfile)[0]



if legal_files.include?(type)

  yoj.import(tmpfile)

  item = yoj.database_items.last

  taglist = osax.display_dialog(&quot;Enter tags for {a.name.get}&quot;, :default_answer =&gt; &quot;&quot;, :buttons =&gt; ['Cancel', 'Okay'],  :default_button =&gt; 2, :with_icon =&gt; :note).fetch(:text_returned).split(&quot;,&quot;)

  

  taglist.each {|t| item.add_tags(t)}

else

  osax.display_dialog(&quot;Yojimbo can't import {a.name.get} - (filetype: {type})&quot;, :with_icon =&gt; :stop)

end



File.delete(tmpfile)



end
</code></pre>
<p>end</p>
<p>[/sourcecode]</p>
</p>
<p>#applescript #appscript #mail #ruby #yojimbo</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Quixotic%2C%20Appscript%2C%20Mail">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
  </channel>
</rss>
