Tag Archive: “code”
Making Ground Track Generator
I wrote a little program to make shapefiles (GIS map layers) of satellite ground tracks. Here’s the story of its development, recounted from my comments on Twitter (the internet’s water cooler).
Posted on Saturday, March 31st, 2012.
Save Selection and Compare Selected Files scripts for BBEdit
Here are a pair of handy scripts for BBEdit (or TextWrangler). Paste them in to Applescript Editor, save them in your BBEdit Scripts folder, and assign shortcut keys in BBEdit > Preferences > Menus & Shortcuts.
Save Selection as New File
Select some text and invoke this script to create and save a new file containing the selection. (Add close doc to the end of the block if you don’t need to edit the file.)
tell application "BBEdit"
set txt to contents of selection
set doc to make new document with properties {contents:txt}
save doc
end tell
This is pretty similar to choosing File > New > Text Document (with selection) and then choosing Save, but it combines the two into one step, which is helpful if you need to do this repeatedly.
Compare Selected Project Files
Use this script to compare two files selected in the files list of a disk browser or project window.
tell application "BBEdit" set selectedProjectItems to selected items of project window 1 if (count of selectedProjectItems) is not 2 then return set comparisonResults to compare first item of selectedProjectItems against second item of selectedProjectItems if not differences found of comparisonResults then display alert "No differences found:" message reason for no differences of comparisonResults end if end tell
You can accomplish the same thing with Search > Find Differences, but if you’ve already selected some files this is quicker.
Posted on Thursday, March 29th, 2012.
Send Reading List to Instapaper
I made a tool called Send Reading List to Instapaper. It does just what it says: it sends the unread articles from your Safari Reading List to Instapaper, a multi-platform service that provides a superset of Reading List’s features. Download and more details at GitHub.

The script is based on readinglistlib, an offspring of my previous experiments with Reading List. It also uses instapaperlib by Daniel Schauenberg.
Articles are not automatically removed from your Reading List when sent to Instapaper, which may limit its utility as a way to “sync” the two. However, it may be useful if you’ve accumulated a large number of Reading List bookmarks which you’d rather read with Instapaper.
Posted on Thursday, March 8th, 2012.
Reading List integration for Vienna
Vienna is a desktop newsreader for OS X. Here is an AppleScript to add the article currently selected in Vienna to Safari’s Reading List:
tell application "Vienna" set the_article to current article try set article_URL to the link of the_article set article_title to the title of the_article set article_intro to paragraph 1 of (body of the_article as text) tell application "Safari" to add reading list item article_URL with title article_title and preview text article_intro end try end tell
Here’s a downloadable version. Stick it in your script runner and read some articles. Requires Mac OS X Ten Point Recent.
Posted on Thursday, February 16th, 2012.
Reading List Reader
I’ve written a standalone script called readinglistreader.py derived from my ebook recipe for Safari Reading List. This script simply lists the contents of your Safari Reading List. It has many options to allow detailed control of the output list. By default, output is formatted as a CSV table, but it can also be formatted as a bookmarks file suitable for importing into other programs or services. In fact, since there seems to be no other easy way to grab the contents of Reading List (besides Safari’s interface), this script is intended is to help export your Reading List bookmarks to other services, presumably as part of some other script you write.
Posted on Monday, February 13th, 2012.
Ebook Recipe for Safari Reading List
Reading List is a Safari browser feature that helps you bookmark articles you want to read later. Calibre is an ebook utility program. I wrote a script for Calibre that generates an ebook of the articles in your Reading List, so you can read them at your leisure on the device of your choice.
Click here for a more detailed introduction and instructions…
Posted on Thursday, February 9th, 2012.
Strange Horizons ebook issue generator
Attentive readers may notice I’ve been on a bit of an ebook kick recently. Here’s a tool I made to generate ebook issues of Strange Horizons, an SF magazine:
Strange Horizons is a weekly magazine of and about speculative fiction. Calibre is a free and open source ebook library management application.
Calibre has an extensible system “for downloading news from the Internet and converting it into an ebook.” The scripts Calibre uses to retrieve and format news are known as recipes. Recipes can be configured as simple RSS readers or as custom Python scripts using Calibre’s recipe API.
Strange Horizons is published online as a web site. This Calibre recipe retrieves the current issue of Strange Horizons and outputs an ebook suitable for reading on a Kindle or other ereader device.
The script and other details, including installation and usage notes, are available on GitHub. It is included with Calibre since Calibre version 0.8.38.
Update, March 4, 2012: This script has been acknowledged on the Strange Horizons blog.
Posted on Tuesday, January 31st, 2012.
McReadability updated
Readability was a bookmarklet developed by Arc90 Lab that would conceal distractions and reformat article text in a consistent manner. I created a modified stylesheet (“McReadability”) that presented the article text in multiple columns, like a newspaper. Readability has since been relaunched and rebranded as a paid service. It still performs the same basic function – it makes web pages nicer to read – but now also offers financial support for article authors and publishers. This is a commendable alternative to the annoying advertising-driven segmentation of articles into multiple pages that is so common on the web. (Web advertising is often paid per page view – thus there is incentive to spread “content” across as many pages as possible. That’s why you see those “Page 1 of 4″ links at the bottom of every online newspaper article. It’s not like web pages run out of paper at the bottom.)
Anyway, my multi-column version of Readability relied on some regular Readability code hosted at Arc90. This dependency broke shortly after the introduction of the revamped service. Fortunately, the original Readability code is open source, so I have updated the McReadability bookmarklet maker to be self-contained. The McReadability bookmarklets now use a copy of the article-cleansing code hosted here at anoved.net. If your McReadability bookmarklet recently stopped working, I encourage you to update it.
Besides this fix, McReadability remains unchanged – although now that is independent of Readability proper, I may customize it more in the future.
Posted on Sunday, March 6th, 2011.
“Export to LDraw” plugin for Google SketchUp
As mentioned in my previous post, I recently drafted a new LDraw part in SketchUp. I converted that model to LDraw format with a script derived from su2ldraw. My version of the plugin is now available as ldraw_export.rb; you can get it here (now at GitHub). More details on installation and usage in the file itself.
Posted on Tuesday, February 1st, 2011.
Reigning in Readability’s Multi-Page Stitching
Readability’s new multi-page integration feature is great for reading articles that are split into a few pages. However, in some cases I still prefer not to load any additional pages of text. For instance, online ePub readers such as Bookworm, the open source predecessor to Ibis Reader, present one book chapter per page. The chapters are sequentially linked in a way recognized by Readability, so an entire novel could be loaded and displayed if you invoke Readability to view one chapter!
As it turns out, an internal maxPages variable limits how many pages Readability will load. By default, it is set to 30. However, as I suggest, a small addition to the main Readability script will allow this limit to be set by the user via an extra bookmarklet parameter.
If you want to experiment with this yourself, you can modify your Readability (or McReadability) bookmarklet such that _readability_script.src points to the following copy of the script: http://anoved.net/js/readability.js (I’m not going to provide an easy link because I’m wary of using up too much of my low-rent bandwidth). Also add readMaxPages to the list of parameters in your bookmarklet; use readMaxPages=1; to prevent loading any text not on the current page (a link to the next page found, if any, will still be appended).
Posted on Sunday, September 26th, 2010.