Add Atom parser test for getting the home page link. It passed, which means the bug I’m currently hunting (no favicon for Dr. Drang) is somewhere else.
This commit is contained in:
parent
0b5f470654
commit
97079108be
|
@ -60,6 +60,7 @@
|
|||
84469D401EFF29A9004A6B28 /* FeedParserError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84469D3F1EFF29A9004A6B28 /* FeedParserError.swift */; };
|
||||
84469D421EFF2B2D004A6B28 /* JSONTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84469D411EFF2B2D004A6B28 /* JSONTypes.swift */; };
|
||||
84469D441F002CEF004A6B28 /* JSONFeedParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84469D431F002CEF004A6B28 /* JSONFeedParser.swift */; };
|
||||
84628AAD1FCA10AE00566A9B /* allthis.atom in Resources */ = {isa = PBXBuildFile; fileRef = 84628AAC1FCA10AE00566A9B /* allthis.atom */; };
|
||||
849A03D01F0081EA00122600 /* DaringFireball.html in Resources */ = {isa = PBXBuildFile; fileRef = 849A03C51F0081EA00122600 /* DaringFireball.html */; };
|
||||
849A03D11F0081EA00122600 /* DaringFireball.rss in Resources */ = {isa = PBXBuildFile; fileRef = 849A03C61F0081EA00122600 /* DaringFireball.rss */; };
|
||||
849A03D21F0081EA00122600 /* EMarley.rss in Resources */ = {isa = PBXBuildFile; fileRef = 849A03C71F0081EA00122600 /* EMarley.rss */; };
|
||||
|
@ -156,6 +157,7 @@
|
|||
84469D3F1EFF29A9004A6B28 /* FeedParserError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FeedParserError.swift; path = Feeds/FeedParserError.swift; sourceTree = "<group>"; };
|
||||
84469D411EFF2B2D004A6B28 /* JSONTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = JSONTypes.swift; path = Feeds/JSON/JSONTypes.swift; sourceTree = "<group>"; };
|
||||
84469D431F002CEF004A6B28 /* JSONFeedParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = JSONFeedParser.swift; path = Feeds/JSON/JSONFeedParser.swift; sourceTree = "<group>"; };
|
||||
84628AAC1FCA10AE00566A9B /* allthis.atom */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = allthis.atom; sourceTree = "<group>"; };
|
||||
849A03C51F0081EA00122600 /* DaringFireball.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DaringFireball.html; sourceTree = "<group>"; };
|
||||
849A03C61F0081EA00122600 /* DaringFireball.rss */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = DaringFireball.rss; sourceTree = "<group>"; };
|
||||
849A03C71F0081EA00122600 /* EMarley.rss */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = EMarley.rss; sourceTree = "<group>"; };
|
||||
|
@ -347,6 +349,7 @@
|
|||
849A03E71F01F88600122600 /* ScriptingNews.json */,
|
||||
849A03CD1F0081EA00122600 /* scriptingNews.rss */,
|
||||
849A03CE1F0081EA00122600 /* sixcolors.html */,
|
||||
84628AAC1FCA10AE00566A9B /* allthis.atom */,
|
||||
849A03CF1F0081EA00122600 /* Subs.opml */,
|
||||
);
|
||||
path = Resources;
|
||||
|
@ -527,6 +530,7 @@
|
|||
849A03D61F0081EA00122600 /* manton.rss in Resources */,
|
||||
849A03D11F0081EA00122600 /* DaringFireball.rss in Resources */,
|
||||
849A03D01F0081EA00122600 /* DaringFireball.html in Resources */,
|
||||
84628AAD1FCA10AE00566A9B /* allthis.atom in Resources */,
|
||||
849A03EA1F01F92B00122600 /* inessential.json in Resources */,
|
||||
849A03D71F0081EA00122600 /* OneFootTsunami.atom in Resources */,
|
||||
849A03D41F0081EA00122600 /* inessential.html in Resources */,
|
||||
|
|
|
@ -20,4 +20,20 @@ class AtomParserTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
func testAllThisPerformance() {
|
||||
|
||||
// 0.003 sec on my 2012 iMac.
|
||||
let d = parserData("allthis", "atom", "http://leancrew.com/all-this")
|
||||
self.measure {
|
||||
let _ = try! FeedParser.parse(d)
|
||||
}
|
||||
}
|
||||
|
||||
func testGettingHomePageLink() {
|
||||
|
||||
let d = parserData("allthis", "atom", "http://leancrew.com/all-this")
|
||||
let parsedFeed = try! FeedParser.parse(d)!
|
||||
|
||||
XCTAssertTrue(parsedFeed.homePageURL == "http://leancrew.com/all-this")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,520 @@
|
|||
<?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>And now it’s all this</title>
|
||||
<atom:link href="http://leancrew.com/all-this/feed/" rel="self" type="application/rss+xml" />
|
||||
<link>http://leancrew.com/all-this</link>
|
||||
<description>I just said what I said and it was wrong. Or was taken wrong.</description>
|
||||
<lastBuildDate>Thu, 23 Nov 2017 21:08:29 +0000</lastBuildDate>
|
||||
<language>en-US</language>
|
||||
<sy:updatePeriod>hourly</sy:updatePeriod>
|
||||
<sy:updateFrequency>1</sy:updateFrequency>
|
||||
<generator>http://wordpress.org/?v=4.0</generator>
|
||||
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/>
|
||||
<atom:link rel="hub" href="http://aniat.superfeedr.com"/>
|
||||
|
||||
<item>
|
||||
<title>Last thoughts on modifier keys</title>
|
||||
<link>http://leancrew.com/all-this/2017/11/last-thoughts-on-modifier-keys/</link>
|
||||
<pubDate>Thu, 23 Nov 2017 21:08:29 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/11/last-thoughts-on-modifier-keys/</guid>
|
||||
<description>
|
||||
<![CDATA[When I wrote the post about <a href="http://leancrew.com/all-this/2017/11/modifier-key-order/">ordering Mac modifier keys</a> a few days ago, I was thinking primarily about the proper order of the <em>symbols</em> when writing about a keyboard shortcut, like ⌃⌥⌘P.<sup id="fnref:preview"><a href="#fn:preview" rel="footnote">1</a></sup>. I mentioned parenthetically that this order isn’t always observed when people speak about keyboard shortcuts or when they write the names of the keys out fully, as in “Command-Shift-3 takes a screenshot.”]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>When I wrote the post about <a href="http://leancrew.com/all-this/2017/11/modifier-key-order/">ordering Mac modifier keys</a> a few days ago, I was thinking primarily about the proper order of the <em>symbols</em> when writing about a keyboard shortcut, like ⌃⌥⌘P.<sup id="fnref:preview"><a href="#fn:preview" rel="footnote">1</a></sup>. I mentioned parenthetically that this order isn’t always observed when people speak about keyboard shortcuts or when they write the names of the keys out fully, as in “Command-Shift-3 takes a screenshot.”</p>
|
||||
<p>Jason Snell, in both <a href="https://sixcolors.com/link/2017/11/the-order-of-modifier-keys-on-the-mac/">a post at Six Colors</a> and in conversation with John Siracusa on <a href="https://www.relay.fm/upgrade/168">the lastest episode of Upgrade</a>, took a stand against Apple’s ordering:<sup id="fnref:hig"><a href="#fn:hig" rel="footnote">2</a></sup></p>
|
||||
<blockquote>
|
||||
<p>Command is the commander! Command is the monarch of all keys! Command always comes first, in my book.</p>
|
||||
</blockquote>
|
||||
<p>Siracusa agreed, and so do I. The ⌘ key is, and has always been, the key that signals a keyboard shortcut. While other modifier keys are sometimes used without ⌘—in cursor control and text selection, for example—I can’t think of any Apple applications that don’t use ⌘ to signal a keyboard shortcut for a menu item. And that primacy in shortcuts to menu items is, I think, why Apple puts it last rather than first.</p>
|
||||
<p>Keyboard shortcuts are always presented right-justified along the right edge of the menu. The most common shortcuts are just ⌘ and a letter, like ⌘N to start a new document, for example. It’s typically the variations on the basic command that get additional modifier keys, like ⌥⌘N to start a new project. If that were presented in a menu as ⌘⌥N, the menu would look wrong because the ⌘ symbols wouldn’t line up.</p>
|
||||
<p>Here’s the <span class="menu">File</span> menu in Safari:</p>
|
||||
<p><img alt="Safari File menu" class="ss" src="http://leancrew.com/all-this/images2017/20171123-Safari%20File%20menu.png" title="Safari File menu"/></p>
|
||||
<p>There are two different <span class="menu">New</span> commands and three different <span class="menu">Close</span> commands. This, in Apple’s opinion (and mine), wouldn’t be right:</p>
|
||||
<p><img alt="Altered Safari File menu" class="ss" src="http://leancrew.com/all-this/images2017/20171123-Altered%20Safari%20File%20menu.png" title="Altered Safari File menu"/></p>
|
||||
<p>It’s not just having the ⌘ symbols aligned. The additional modifier symbols go in front <em>because</em> ⌘ is king and must sit next to the N or the W. The importance of the modifier decreases as you move away from the letter.</p>
|
||||
<p>It should go without saying—but I’ll say it anyway—that the letter (or number or whatever) key is the most important because <em>nothing</em> happens until it’s pressed.</p>
|
||||
<p>Having said all this, and despite agreeing with Apple’s symbol ordering, my ear for shortcut ordering works just like Jason’s and John’s. The main reason I use keyboard shortcut symbols in my posts instead of words is that I can read ⌥⇧⌘W and not be bothered because I don’t “hear” it as I read the symbols. “Option-Shift-Command-W,” on the other hand, gets sounded out in my head, and it sounds wrong.</p>
|
||||
<p>I suspect that’s why Apple’s own documentation sometimes gets the order wrong when the modifiers get written out as words. In speaking out the keys, “Command” is natural to put first because it announces that what’s coming is a keyboard shortcut.</p>
|
||||
<div class="footnotes">
|
||||
<hr/>
|
||||
<ol>
|
||||
<li id="fn:preview">
|
||||
<p>Which happens to be the shortcut I use for previewing a blog post locally before publishing it. <a href="#fnref:preview" rev="footnote">↩︎</a></p>
|
||||
</li>
|
||||
<li id="fn:hig">
|
||||
<p>In the original post, I said I didn’t know where the order was documented. A few people pointed me to both the <a href="https://developer.apple.com/macos/human-interface-guidelines/user-interaction/keyboard/">Human Interface Guidelines</a> and the <a href="https://itunes.apple.com/us/book/apple-style-guide/id1161855204?mt=11">Style Guide</a>, where Apple gives the proper order explicitly. <a href="#fnref:hig" rev="footnote">↩︎</a></p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/11/last-thoughts-on-modifier-keys/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>My next Mac</title>
|
||||
<link>http://leancrew.com/all-this/2017/11/my-next-mac/</link>
|
||||
<pubDate>Wed, 22 Nov 2017 22:04:57 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/11/my-next-mac/</guid>
|
||||
<description>
|
||||
<![CDATA[Will probably be an iMac. I guess that spoils the suspense, doesn’t it?]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>Will probably be an iMac. I guess that spoils the suspense, doesn’t it?</p>
|
||||
<p>My iMac at work is the <a href="https://support.apple.com/kb/sp667?locale=en_US">27″ Late 2012 model</a>, the one that came out one step before Retina came to the iMac. I don’t regret buying it, as my previous iMac (a <a href="https://everymac.com/systems/apple/imac/specs/imac-core-2-duo-2.16-24-inch-specs.html">2006 model</a>, I think) was absolutely on its last legs—constantly swapping to hard disk and running hot. I hadn’t meant to wait so long to replace it, but there was <a href="https://buyersguide.macrumors.com/">a long delay</a> before that 2012 model came out, and I didn’t want to buy something that would be last year’s model almost as soon as I set it up.</p>
|
||||
<p>My home Mac is the venerable 2010 13″ MacBook Air, the first good Air. In the normal course of things, this would be the Mac I replace next, and I’ve been expecting to do so for a few years now. but…</p>
|
||||
<p>But Apple never came out with a Retina MacBook Air, choosing instead to go with the MacBook, which I find a little too far on the portable side of the portability/power spectrum. A couple of years ago, I had a crisis when <a href="http://leancrew.com/all-this/2015/06/beep-beep-beep/">my Air crapped out on me</a>. It seemed wrong to put money into a five-year-old machine, but I wasn’t enthused about any of the MacBooks in the lineup at the time. I didn’t know the just-released 2015 MacBook Pro would turn out to be the <a href="https://marco.org/2017/11/14/best-laptop-ever">best laptop ever made</a>, I didn’t want to spend MacBook Pro money on my home/travel machine.</p>
|
||||
<p>The $280 logic board upgrade turned out to be a good investment, as I’m now 2½ years into my rejuvenated Air. Yes, it takes a while to wake up when I open the lid. Yes, its 128 GB SSD is tiny. No, it can’t take advantage of many of the iOS integration features that newer Macs can. And no, I don’t think it’s a good idea to install High Sierra on it. But it’s given me 30 months of faithful use, much more than I expected at the time.</p>
|
||||
<p>The announcement of the Touch Bar last year made me certain I’d be getting a MacBook Pro with it. A software-configurable set of controls seemed perfect for someone who’s always ginning up little scripts. But no one seems to like it, possibly because its configurability isn’t especially open to users. Bummer.</p>
|
||||
<p>I’ve delayed the decision on my home Mac for such a long time that now my office Mac is long in the tooth, too. Still working fine for most tasks, but just a Core 2 Duo machine that often <a href="http://leancrew.com/all-this/2015/10/dealing-with-a-recalcitrant-pdf/">makes me wait</a> to scroll through long PDFs of scanned engineering and architectural drawings, something I need to do at work quite often. And no Retina.</p>
|
||||
<p>So it looks like my best bet is to buy a new iMac for work and bring my current office iMac home. This will put the power where I need it the most and will give me extra ooomph here at home. Especially with disk space (3 TB vs. 128 GB) and RAM (24GB vs. 4GB).</p>
|
||||
<p>It will be weird, though, as I haven’t had a desktop computer here at home in a dozen years. Will I enjoy being tethered to one spot in the house? And what about a travel computer?</p>
|
||||
<p>Both of these questions are made less pressing by the device I’m typing this on: a 9.7″ iPad Pro. While I agree with <a href="http://www.macdrifter.com/2017/11/the-mac-still-feels-like-home.html">Gabe</a> that it is by no means a Mac substitute, it can handle a lot of what I do at home and virtually everything I need to do on the road.<sup id="fnref:gabe"><a href="#fn:gabe" rel="footnote">1</a></sup></p>
|
||||
<p>As for which iMac, I think I’ll settle on a middle-of-the-road 27″ configuration with a 3TB Fusion drive. Sort of the 2017 of what I bought in 2012.</p>
|
||||
<div class="footnotes">
|
||||
<hr/>
|
||||
<ol>
|
||||
<li id="fn:gabe">
|
||||
<p>I bought the iPad Pro last year as a sort of experiment to find out how comfortable I’d be working on it. I intend to write a full post about the results of that experiment soon, but in the meantime, you really should read <a href="http://www.macdrifter.com/2017/11/the-mac-still-feels-like-home.html">Gabe’s post over at Macdrifter</a>. I’ll probably use his post as a jumping-off point. And there may be a quiz. <a href="#fnref:gabe" rev="footnote">↩︎</a></p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/11/my-next-mac/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Modifier key order</title>
|
||||
<link>http://leancrew.com/all-this/2017/11/modifier-key-order/</link>
|
||||
<pubDate>Mon, 20 Nov 2017 02:22:59 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/11/modifier-key-order/</guid>
|
||||
<description>
|
||||
<![CDATA[If you write about Mac keyboard shortcuts, as I did yesterday, you should know how to do it right. Just as there’s a <a href="https://dictionary.cambridge.org/grammar/british-grammar/adjectives-order">proper order for adjectives</a> in English, there’s a proper order for listing the modifier keys in a shortcut.]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>If you write about Mac keyboard shortcuts, as I did yesterday, you should know how to do it right. Just as there’s a <a href="https://dictionary.cambridge.org/grammar/british-grammar/adjectives-order">proper order for adjectives</a> in English, there’s a proper order for listing the modifier keys in a shortcut.</p>
|
||||
<p>I haven’t found any documentation for this, but Apple’s preferred order is clear in how they show the modifiers in menus and how they’re displayed in the Keyboard Shortcuts Setting.</p>
|
||||
<p><img alt="Canonical Mac modifier key order" class="ss" src="http://leancrew.com/all-this/images2017/20171119-Canonical%20Mac%20modifier%20key%20order.png" title="Canonical Mac modifier key order"/></p>
|
||||
<p>The order is similar to how you see them down at the bottom left of your keyboard.</p>
|
||||
<p><img alt="Modifier keys" class="ss" src="http://leancrew.com/all-this/images2017/20171119-Modifier%20keys.jpg" title="Modifier keys"/></p>
|
||||
<p>Control (⌃), Option (⌥), and Command (⌘) always go in that order. The oddball is the Shift(⇧) key, which sneaks in just in front of Command.</p>
|
||||
<p>Keyboard Maestro recognizes this standard order and presents its “hot key” shortcut the same way.</p>
|
||||
<p><img alt="Keyboard Maestro hot key field" class="ss" src="http://leancrew.com/all-this/images2017/20171119-Keyboard%20Maestro%20hot%20key%20field.png" title="Keyboard Maestro hot key field"/></p>
|
||||
<p>(When people speak about keyboard shortcuts, it’s not uncommon to put Command first, e.g., “Command-Shift-3 takes a screenshot.” I’ve seen it written out that way, too. Apple is usually pretty careful to use the same order when using words as when using symbols. <a href="https://support.apple.com/en-us/HT201361">This page</a>, for example, uses “Shift-Command-3,” to match the ⇧⌘3 you’d see in the Keyboard Shortcut Settings. But even Apple slips up. On <a href="https://support.apple.com/en-us/HT201236">the grand Mac keyboard shortcut page</a>, there are a few instances of “Command-Shift” instead of “Shift-Command.”)</p>
|
||||
<p>The last bit of standard syntax is that the letter key in the shortcut (if there is a letter) is always presented as a capital, even when the Shift key isn’t used. I suspect this was a serious topic of discussion at Bandley 3 back in the early 80s as the Mac was being developed. They got it right. When entering a keyboard shortcut, you’re not typing a letter, you’re pressing a set of physical keys on the keyboard in front of you. The symbols on the letter keys are capitals, so that’s the appropriate way to identify those keys.</p>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/11/modifier-key-order/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Command-E</title>
|
||||
<link>http://leancrew.com/all-this/2017/11/command-e/</link>
|
||||
<pubDate>Sun, 19 Nov 2017 02:02:50 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/11/command-e/</guid>
|
||||
<description>
|
||||
<![CDATA[Earlier this evening, Merlin tweeted out some advice we should all heed:]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>Earlier this evening, Merlin tweeted out some advice we should all heed:</p>
|
||||
<blockquote class="twitter-tweet" data-lang="en"><p dir="ltr" lang="en">Per today's <a href="https://twitter.com/thetalkshow?ref_src=twsrc%5Etfw">@thetalkshow</a>, here's an Apple Support doc that can change your life. I dare you not to find something new here.<a href="https://t.co/37FuPPUbYK">https://t.co/37FuPPUbYK</a></p>— Merlin Mann (@hotdogsladies) <a href="https://twitter.com/hotdogsladies/status/932031370800529408?ref_src=twsrc%5Etfw">November 18, 2017</a></blockquote>
|
||||
<script async="" charset="utf-8" src="https://platform.twitter.com/widgets.js"></script>
|
||||
<p>Even though I’ve been using a Mac for 32 years (albeit with an 8-year Linux hiatus) there were a few keyboard shortcuts in there I didn’t know about. And, just as important, several that I once knew but had fallen out of the habit of using.</p>
|
||||
<p>But one of my favorites—and a big convenience when writing code or prose—isn’t on the <a href="https://support.apple.com/en-ae/HT201236">Mac keyboard shortcut page</a>. I wonder if the folks at Apple have forgotten it.</p>
|
||||
<p>It has to do with finding text in a document. You know about ⌘F to specify a <span class="menu">Find</span>. That usually brings up a window or other control into which you can type (or paste) the text you’re going to be searching for. Often, there are options for controlling how the search will be performed and for replacement text. Here’s the Find window from BBEdit,</p>
|
||||
<p><img alt="BBEdit Find window" class="ss" src="http://leancrew.com/all-this/images2017/20171118-BBEdit%20Find%20window.png" title="BBEdit Find window"/></p>
|
||||
<p>here’s the Find window from Pages,</p>
|
||||
<p><img alt="Pages Find window" class="ss" src="http://leancrew.com/all-this/images2017/20171118-Pages%20Find%20window.png" title="Pages Find window"/></p>
|
||||
<p>and here’s TextEdit, which pops up a little Find section in the main window below the ruler,</p>
|
||||
<p><img alt="TextEdit with Find section" class="ss" src="http://leancrew.com/all-this/images2017/20171118-TextEdit%20with%20Find%20section.png" title="TextEdit with Find section"/></p>
|
||||
<p>You probably also know about ⌘G, which is usually given the menu name <span class="menu">Find Next</span>. It repeats the last <span class="menu">Find</span> command, allowing you to step through all the occurrences of that text in the document. There are usually other ways to cycle through all the found instances—Pages and TextEdit have arrow buttons you can click on—but ⌘G is the traditional way.<sup id="fnref:page"><a href="#fn:page" rel="footnote">1</a></sup></p>
|
||||
<p>A common situation, especially when looking through long documents or source code files, is to see a particular string of text and want to find other instances of it. You may, for example, see the definition of a function and want to search out where that function gets called later in the code. One way to do that would be to select the function name, copy it, ⌘F to bring up the text entry field, paste, and then ⌘G your way through the rest of the document.<sup id="fnref:all"><a href="#fn:all" rel="footnote">2</a></sup> But the copy/⌘F/paste dance is a little clumsy.</p>
|
||||
<p>Which is where ⌘E, which is typically given a menu name like <span class="menu">Use Selection for Find</span>, comes in.</p>
|
||||
<p><img alt="BBEdit Search menu" class="ss" src="http://leancrew.com/all-this/images2017/20171118-BBEdit%20Search%20menu.png" title="BBEdit Search menu"/></p>
|
||||
<p>Select the text you want to search for and hit ⌘E. That turns the selection into the search text, and you can go straight to ⌘G to walk through all the other occurrences.</p>
|
||||
<p>I use ⌘E all the time when searching through code for function and variable names, as in the example above. It also works in Safari, Chrome, Preview, and PDF Expert, so I do similar quick searching on words I come across as I read news articles, blogs, reports, papers, etc.</p>
|
||||
<p>⌘E works in other well-behaved applications, too, so you should give it a try. Note that “well-behaved applications” excludes MS Word. In Word, ⌘E centers the paragraph of text containing the selection. Of course.</p>
|
||||
<div class="update">
|
||||
<p><strong>Update Nov 19, 2017 8:40 AM</strong><br/>
|
||||
A couple of things I forgot to include:</p>
|
||||
<p>First, ⌘E in the Finder has, somewhat ironically, no relationship to finding. It ejects or unmounts the selected disk, assuming there is a selected disk. This shortcut is listed on Apple’s <a href="https://support.apple.com/en-ae/HT201236">Mac shortcut page</a> (which is why I was going to mention it), and a couple of people reminded me of it after the post was published. I guess I forgot about it because it’s a command I never use; I eject by right-clicking and selecting <span class="menu">Eject</span> from the menu that pops up.</p>
|
||||
<p>Second, editors and word processors on iOS have not inherited this useful shortcut from the Mac. There is, of course, no ⌘ key on the software keyboard, but many of the traditional Mac shortcuts that use ⌘, ⌥, and ⇧ for moving the cursor and selecting text do work on iOS when you use an external keyboard. ⌘F and ⌘G (and its backward cousin, ⇧⌘G) often work in iOS, too, but ⌘E didn’t make the cut. Too bad.</p>
|
||||
<p><img alt="Keyboard shortcuts in iOS Notes" class="ss" src="http://leancrew.com/all-this/images2017/20171119-Keyboard%20shortcuts%20in%20iOS%20Notes.jpg" title="Keyboard shortcuts in iOS Notes" width="60%"/></p>
|
||||
</div>
|
||||
<div class="footnotes">
|
||||
<hr/>
|
||||
<ol>
|
||||
<li id="fn:page">
|
||||
<p>I believe ⌘G was originally used as the shortcut for <span class="menu">Go To Page…</span> in MacWrite, but it’s been <span class="menu">Find Next</span> for ages. <a href="#fnref:page" rev="footnote">↩</a></p>
|
||||
</li>
|
||||
<li id="fn:all">
|
||||
<p>Yes, source code editors in general, and BBEdit in particular, have other ways to find all the instances of a string of text, and those ways may be more appropriate in some situations. But stepping your way through each instance in turn is often the best way to see the string in full context. <a href="#fnref:all" rev="footnote">↩</a></p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/11/command-e/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Converting fractions to decimal values</title>
|
||||
<link>http://leancrew.com/all-this/2017/11/converting-fractions-to-decimal-values/</link>
|
||||
<pubDate>Mon, 13 Nov 2017 04:35:39 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/11/converting-fractions-to-decimal-values/</guid>
|
||||
<description>
|
||||
<![CDATA[Recently, I’ve been getting Excel spreadsheets from clients that contain measurements in inches and/or fractions of an inch. In some cases, the cells with these measurements actually contain numbers but are displayed as fractions using one of the many formatting options Excel has.]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>Recently, I’ve been getting Excel spreadsheets from clients that contain measurements in inches and/or fractions of an inch. In some cases, the cells with these measurements actually contain numbers but are displayed as fractions using one of the many formatting options Excel has.</p>
|
||||
<p><img alt="Excel cell formatting options" class="ss" src="http://leancrew.com/all-this/images2017/20171112-Excel%20cell%20formatting%20options.png" title="Excel cell formatting options"/></p>
|
||||
<p>In these cases, it’s easy for me to change the formatting to a standard decimal representation before exporting the sheet as a CSV file.</p>
|
||||
<div class="sidebar">
|
||||
<p><strong>Aside</strong><br/>
|
||||
The only reason I own Excel is to be able to open spreadsheets that other people send me and export them into some other usable format. This wasn’t always the case. I used the hell out of Excel in the late 80s and early 90s, when it was still a proper Mac app. But somewhere there in the early to mid 90s, Microsoft turned Excel into a Windows app that ran on the Mac and ruined its user interface. I stopped using it shortly thereafter. In the quarter-century since, it’s only gotten worse. Note, for example, the absurd layout of the dialog box above.</p>
|
||||
<p>Small Excel spreadsheets usually get moved over to Numbers, a considerably less powerful spreadsheet, but one that works the way a normal Mac app works. Large Excel spreadsheets get converted to CSV (often after a short visit to Numbers, as I’ve had trouble with Excel’s CSV conversion) so I can query and manipulate the data with <a href="http://pandas.pydata.org/">Pandas</a>. Why don’t I just open the Excel file in Pandas <a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_excel.html">directly</a>? Because the spreadsheets I get are so filled with cruft, <code>read_excel</code> can’t be trusted.</p>
|
||||
</div>
|
||||
<p>Often, though, the measurements are entered as text. This is done by prefixing the data with a single quote mark, e.g.,</p>
|
||||
<pre><code>'2 5/16
|
||||
</code></pre>
|
||||
<p>or maybe</p>
|
||||
<pre><code>'2-5/16
|
||||
</code></pre>
|
||||
<p>These need to be converted into a decimal representation before exporting to CSV, so Pandas will recognize them as numbers rather than strings.<sup id="fnref:pandas"><a href="#fn:pandas" rel="footnote">1</a></sup></p>
|
||||
<p>To handle this situation, I created a Keyboard Maestro called Floatize. To use Floatize, I</p>
|
||||
<ul>
|
||||
<li>Select the column of data I want to convert.</li>
|
||||
<li>Copy it to the clipboard.</li>
|
||||
<li>Run Floatize, which converts the clipboard from a fractional representation to decimal.</li>
|
||||
<li>Paste the result back into the column.</li>
|
||||
</ul>
|
||||
<p>Here’s the macro:</p>
|
||||
<p><img alt="Floatize Keyboard Maestro macro" class="ss" src="http://leancrew.com/all-this/images2017/20171112-Floatize%20Keyboard%20Maestro%20macro.png" title="Floatize Keyboard Maestro macro" width="80%"/></p>
|
||||
<p>It takes the clipboard, sends it to a script as standard input, and then puts the output back into the clipboard. Here’s the Python script it runs:</p>
|
||||
<pre><code>python:
|
||||
1: #!/usr/bin/env python
|
||||
2:
|
||||
3: from fractions import Fraction
|
||||
4: import re
|
||||
5: import sys
|
||||
6:
|
||||
7: def floatize(s):
|
||||
8: if s in ['', 'n/a', 'none']:
|
||||
9: return ''
|
||||
10: else:
|
||||
11: try:
|
||||
12: num = float(s)
|
||||
13: except ValueError:
|
||||
14: t = re.sub(r'(.*\d) *- *(\d.*)', r'\1 \2', s)
|
||||
15: if t[0] == '-':
|
||||
16: num = -float(sum(Fraction(x) for x in t[1:].split(None, 1)))
|
||||
17: else:
|
||||
18: num = float(sum(Fraction(x) for x in t.split(None, 1)))
|
||||
19: return "{:f}".format(num)
|
||||
20:
|
||||
21: for line in sys.stdin.read().splitlines():
|
||||
22: item = line.strip().lower()
|
||||
23: print floatize(item)
|
||||
</code></pre>
|
||||
<p>The bulk of the fraction parsing is done by the <a href="https://docs.python.org/2.7/library/fractions.html"><code>fractions</code> module</a> in either Line 16 or Line 18. The rest of the script is an attempt to manipulate the oddball types of data I get into a format that <code>fractions</code> understands. Here’s what it can handle:</p>
|
||||
<ul>
|
||||
<li>Blank, <code>n/a</code> or <code>none</code> entries get turned into an empty string (Lines 8–9). Note that entries are converted to lower case in Line 22, before being passed to the <code>floatize</code> function, so this handles <code>N/A</code> and <code>None</code>, too.</li>
|
||||
<li>Entries already in decimal format get converted to a <code>float</code> (Line 12) and then output in decimal format (Line 19). This is basically a pass-through.</li>
|
||||
<li>Entries with a dash between the whole and fractional parts get the dash removed (Line 14).</li>
|
||||
<li>Negative entries (Line 15) have their whole and fractional parts added together with the sign reversed (Line 16), and then output in decimal format (Line 19).</li>
|
||||
<li>Positive entries have their whole and fractional parts added together (Line 18), and then output in decimal format (Line 19).</li>
|
||||
<li>Entries that don’t look like any of the above cause an error.</li>
|
||||
</ul>
|
||||
<p>The macro works perfectly in Numbers and BBEdit, but not in Excel. For some reason, nothing happens to the clipboard if I run the Floatize macro while Excel is the active application. I can, however, copy the column of fractions, activate another app, run Floatize, switch back to Excel and paste the converted clipboard. Another example of Excel not acting like a proper Mac app and another reason I move data out of Excel as quickly as I can.</p>
|
||||
<p>Despite its inability to work inside Excel, this macro has been very handy over the past couple of weeks. I’ve used it to clean up several data sets that were loaded with fractions.</p>
|
||||
<p>By the way, I will block anyone who tweets that I wouldn’t have this problem if I used the metric system.</p>
|
||||
<div class="update">
|
||||
<p><strong>Update Nov 13, 2017 10:04 PM</strong>
|
||||
The Twitter consensus is my problem in using this macro in Excel stems from Excel’s clipboard dumbassery. It apparently uses a private clipboard instead of the system clipboard until you bring another application to the front. Hence the macro’s inability to convert the clipboard unless I switched away from Excel.</p>
|
||||
<p>Jimmy Hartington suggested this workaround:</p>
|
||||
<div class="bbpBox" id="t929938579085807616">
|
||||
<blockquote>
|
||||
<span class="twContent"><a href="http://twitter.com/drdrang">@drdrang</a> Excel does something weird with the clipboard as you noticed. <br/>Try this. Copy in Excel. Press Escape. Run the macro.<br/>
|
||||
By pressing Escape I think Excel stops messing with the clipboard.
|
||||
<br/><span class="twDecoration">— </span><span class="twRealName">Jimmy Hartington</span><span class="twDecoration"> (</span><a href="http://twitter.com/jimmyhartington"><span class="twScreenName">@jimmyhartington</span></a><span class="twDecoration">) </span><a href="https://twitter.com/jimmyhartington/status/929938579085807616"><span class="twTimeStamp">Nov 12 2017 11:06 PM</span></a><span class="twDecoration"></span></span>
|
||||
</blockquote>
|
||||
</div>
|
||||
<p>This works perfectly and pointed me in the direction to make a better version of the macro, one that does all the copying, converting, and pasting:</p>
|
||||
<p><img alt="New Floatize Keyboard Maestro macro" class="ss" src="http://leancrew.com/all-this/images2017/20171113-New%20Floatize%20Keyboard%20Maestro%20macro.png" title="New Floatize Keyboard Maestro macro" width="80%"/></p>
|
||||
<p>Note the conditional action that simulates the pressing of the Escape key only if Excel is the front application. This is necessary because Escape causes Numbers to deselect the column, which screws up the paste action at the end of the macro.</p>
|
||||
<p>With this macro I can now select the column that needs converting and just press ⌃⌥⌘F to do the conversion in a single step. Thanks, Jimmy!</p>
|
||||
</div>
|
||||
<div class="footnotes">
|
||||
<hr/>
|
||||
<ol>
|
||||
<li id="fn:pandas">
|
||||
<p>There are probably ways to get Pandas to do the conversion as it imports the data, but I feel more comfortable—more in control—if I do it ahead of time. <a href="#fnref:pandas" rev="footnote">↩︎</a></p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/11/converting-fractions-to-decimal-values/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>A modest proposal</title>
|
||||
<link>http://leancrew.com/all-this/2017/11/a-modest-proposal/</link>
|
||||
<pubDate>Tue, 07 Nov 2017 03:27:11 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/11/a-modest-proposal/</guid>
|
||||
<description>
|
||||
<![CDATA[With Apple sales and graphing <a href="http://leancrew.com/all-this/2017/11/apple-sales-graphs-and-the-iphone-7/">on my mind</a>, I’d like to make a small complaint and suggestion to the folks at MacStories: some of your <a href="https://www.macstories.net/news/apple-q4-2017-results-52-6-billion-revenue-46-7-million-iphones-10-3-million-ipads-sold/">quarterly graphs</a> could use a little scrubbing; they’d be much easier on the eyes if they were cleaned up a bit.]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>With Apple sales and graphing <a href="http://leancrew.com/all-this/2017/11/apple-sales-graphs-and-the-iphone-7/">on my mind</a>, I’d like to make a small complaint and suggestion to the folks at MacStories: some of your <a href="https://www.macstories.net/news/apple-q4-2017-results-52-6-billion-revenue-46-7-million-iphones-10-3-million-ipads-sold/">quarterly graphs</a> could use a little scrubbing; they’d be much easier on the eyes if they were cleaned up a bit.</p>
|
||||
<p>I’m talking about the ones that look like this:</p>
|
||||
<p><img alt="MacStories unit sales graph" class="ss" src="http://leancrew.com/all-this/images2017/20171106-MacStories%20unit%20sales%20graph.jpg" title="MacStories unit sales graph"/></p>
|
||||
<p>My complaint is with the clutter along the x-axis. That uniform gray mass of text detracts from the data above it. And although putting a label at each quarter seems to provide more information to the reader, the reader actually gets less out of it because it’s too hard to read. The axis would be improved if it had just yearly Q1 labels. Maybe even one label every other year. Fewer labels would mean they could be turned back horizontal, which would be easier to read and would give more vertical space for the data.</p>
|
||||
<p>I suspect every data point is labeled because that’s the way Numbers wants to do it, and MacStories’ automated system for generating these graphs follows the Numbers defaults. But if you were making these graphs by hand, you’d never label the x-axis this way. An automated system shouldn’t, either.</p>
|
||||
<p>On the Mac, Numbers has a way to skip labels on the x-axis by selecting Custom Category Intervals from the Category Labels popup menu and then choosing how often to put the labels.</p>
|
||||
<p><img alt="Mac Numbers axis options" class="ss" src="http://leancrew.com/all-this/images2017/20171106-Mac%20Numbers%20axis%20options.png" title="Mac Numbers axis options"/></p>
|
||||
<p>Sadly, I can’t find that option in the iOS version. Maybe it’s tucked away in a less obvious place.</p>
|
||||
<p><img alt="iOS Numbers axis options" class="ss" src="http://leancrew.com/all-this/images2017/20171106-iOS%20Numbers%20axis%20options.jpg" title="iOS Numbers axis options" width="50%"/></p>
|
||||
<p>Personally, I’m not a fan of either version of Numbers when it comes to making graphs because I like way more control than they give. But Numbers (like most graphing programs and libraries) can make nice graphs if you’re willing to break away from its defaults.</p>
|
||||
<p>I don’t really want to pick on MacStories. Their graphs are as good as, if not better than, what you typically find in blogs and news sites. Most graphs, unfortunately, are based on the default settings of the software that made them, and come out looking a little clumsy.</p>
|
||||
<p>I read MacStories because it has stylish writing. I’d like its graphs to be just as stylish.</p>
|
||||
<div class="update">
|
||||
<p><strong>Update Nov 7, 2017 8:55 PM</strong><br/>
|
||||
I was informed on Twitter by two authoritative sources (<a href="https://twitter.com/greyham/status/927795367361441793">this one</a> and <a href="https://twitter.com/viticci/status/927830126481608705">this one</a>) that the MacStories graphs are made with Excel, not Numbers. I haven’t used Excel for graphing since the mid-90s, but even then it had more customization options than Numbers has now. So I’m crossing my fingers for cleaner x-axes in January’s graphs.</p>
|
||||
</div>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/11/a-modest-proposal/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Apple sales graphs and the iPhone 7</title>
|
||||
<link>http://leancrew.com/all-this/2017/11/apple-sales-graphs-and-the-iphone-7/</link>
|
||||
<pubDate>Mon, 06 Nov 2017 02:53:19 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/11/apple-sales-graphs-and-the-iphone-7/</guid>
|
||||
<description>
|
||||
<![CDATA[Last week Apple released its 2017 Q4 (which everyone else’s calendar says is 2017 Q3) <a href="https://www.apple.com/newsroom/2017/11/apple-reports-fourth-quarter-results/">sales and revenue figures</a>, which means a boatload of graphs from all your fave rave Apple-oriented bloggers. I’m a few days late, as usual, despite having long ago written scripts to generate these graphs.]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>Last week Apple released its 2017 Q4 (which everyone else’s calendar says is 2017 Q3) <a href="https://www.apple.com/newsroom/2017/11/apple-reports-fourth-quarter-results/">sales and revenue figures</a>, which means a boatload of graphs from all your fave rave Apple-oriented bloggers. I’m a few days late, as usual, despite having long ago written scripts to generate these graphs.</p>
|
||||
<p>I don’t make as many graphs as everyone else, partly because I’m lazy, but mainly because don’t care about revenue. My concern is the popularity of the devices I use, not how expensive they are. I want third-party developers to keep writing apps for them, and that means there has to be a market for them out there.</p>
|
||||
<p>Here’s the summary graph, with the sales figures for the three main Apple products. The dots are the quarterly sales and the lines are the four-quarter moving averages.</p>
|
||||
<p><img alt="Apple sales" class="ss" src="http://leancrew.com/all-this/images2017/20171105-Apple%20sales.png" title="Apple sales"/></p>
|
||||
<p>The iPhone dominates the scale of this graphs, so it’s helpful to also see the iPad and Mac on their own graphs.</p>
|
||||
<p><img alt="iPad sales" class="ss" src="http://leancrew.com/all-this/images2017/20171105-iPad%20sales.png" title="iPad sales"/></p>
|
||||
<p><img alt="Mac sales" class="ss" src="http://leancrew.com/all-this/images2017/20171105-Mac%20sales.png" title="Mac sales"/></p>
|
||||
<p>The good news is the second straight quarter of year-over-year increase in iPad sales after its long, well-documented slide since 2013. Additional good news is the Mac’s slow but consistent rise over the past year—four straight quarters of year-over-year sales increases. Imagine how much better the figures would be if people really liked the Touch Bar.</p>
|
||||
<p>I think its fair to say, though, that the iPhone 7 was something of a dud. It had a good start, but its non-intro quarters had almost exactly the same sales as the 6S had. Look at the final three quarters of each.</p>
|
||||
<p><img alt="Apple sales annotated" class="ss" src="http://leancrew.com/all-this/images2017/20171105-Apple%20sales%20annotated.png" title="Apple sales annotated"/></p>
|
||||
<p><a href="http://leancrew.com/all-this/2016/07/obligatory-apple-sales-post/">As I’ve argued before</a>, the iPhone 6S sales looked lackluster only in comparison to the gangbusters popularity of the iPhone 6. If one ignored the year of the 6, the 6S’s sales were more or less on the same upward trend as the previous three editions. The iPhone 7 was on that same trend for its first quarter but went dead flat after that.</p>
|
||||
<p>Apple’s report in January will be very interesting.</p>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/11/apple-sales-graphs-and-the-iphone-7/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Another one-off Keyboard Maestro macro</title>
|
||||
<link>http://leancrew.com/all-this/2017/11/another-one-off-keyboard-maestro-macro/</link>
|
||||
<pubDate>Fri, 03 Nov 2017 02:02:41 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/11/another-one-off-keyboard-maestro-macro/</guid>
|
||||
<description>
|
||||
<![CDATA[Do you use Keyboard Maestro (or AppleScript or whatever) for one-time, throwaway macros as often as you should? I know I don’t, but I did put one together a couple of days ago and used a feature I’d never tried before.]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>Do you use Keyboard Maestro (or AppleScript or whatever) for one-time, throwaway macros as often as you should? I know I don’t, but I did put one together a couple of days ago and used a feature I’d never tried before.</p>
|
||||
<p>I had one of those <a href="http://leancrew.com/all-this/2015/10/dealing-with-a-recalcitrant-pdf/">recalcitrant PDFs</a> that I often get from clients. This one was 25–30 pages long, each an E-sized floor plan drawing for a building. The drawings were all black-and-white, but the PDF had color annotations added. I needed to add my own annotations to most of the pages, but something about the format of the file made it very cumbersome to work with. I tried Preview, PDF Expert, and PDfpen Pro, and they all were glacially slow when panning, zooming, and switching pages.</p>
|
||||
<p>So I broke the file up into individual pages using <a href="https://www.pdflabs.com/tools/pdftk-server/">PDFtk</a>:</p>
|
||||
<pre><code>pdftk drawings.pdf burst
|
||||
</code></pre>
|
||||
<p>The single-page files didn’t make me wait for the spinning beach ball, so I was able to add my annotations quickly in <a href="https://pdfexpert.com/">PDF Expert</a>. Then came an impasse.</p>
|
||||
<p>I wanted to email the drawings with my annotations back to the client and to some other parties, but they were too big to fit in an email. I could use multiple emails, but that’s a recipe for losing some of the files. I could use a Dropbox link, but I had a sense that one of the other parties wouldn’t understand how that worked. What seemed best was to convert the files to JPEGs at the lowest legible resolution, zip them together, and send the zipped file in a single email.<sup id="fnref:zip"><a href="#fn:zip" rel="footnote">1</a></sup></p>
|
||||
<p>My normal practice would be to use <a href="https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/sips.1.html"><code>sips</code></a> for this, because I can issue a single command to convert any number of files. But I soon learned that <code>sips</code> doesn’t handle annotations properly when converting the format of a file from PDF to JPEG. In my brief testing, I found that neither my annotations or the ones that came from the client were visible in the converted JPEGs.</p>
|
||||
<p>Preview, though, <em>can</em> export a PDF as a JPEG with the annotations intact and visible. Which presumably means that <code>sips</code> and Preview are using different code bases for the conversion. Whatever.</p>
|
||||
<p>The problem with using Preview is I’d have to convert every file by hand. Not the most burdensome job I’ve ever had, but one that’s boring and susceptible to error. Enter Keyboard Maestro.</p>
|
||||
<p>Here’s the macro that exports the current file in Preview to a JPEG and closes it:</p>
|
||||
<p><img alt="Convert to JPEG macro" class="ss" src="http://leancrew.com/all-this/images2017/20171101-Convert%20to%20JPEG%20macro.png" title="Convert to JPEG macro" width="80%"/></p>
|
||||
<p>You’ll note there’s no step for setting the resolution for the exported file. That’s because once it’s set, it doesn’t change from one export to the next.</p>
|
||||
<p>I didn’t try to have the macro open each PDF in turn, because I didn’t trust myself to do that right. I just opened all of them and then ran the macro by pressing ⌃⌥⌘J repeatedly. The macro closed each file after exporting it, leaving the next window ready to be operated on.</p>
|
||||
<p>The new (for me) thing with this macro was the “and drag to” part at the bottom of the third step. That’s what moved the popup menu selection from <span class="menu">PDF</span> up to <span class="menu">JPEG</span>.</p>
|
||||
<p><img alt="Preview export sheet" class="ss" src="http://leancrew.com/all-this/images2017/20171102-Preview%20export%20sheet.png" title="Preview export sheet"/></p>
|
||||
<p>I figured out how much to drag by taking a screenshot like the one above and using a selection in <a href="https://flyingmeat.com/acorn/">Acorn</a> to measure the vertical distance from the center of <span class="menu">PDF</span> to the center of <span class="menu">JPEG</span>. No trial and error.</p>
|
||||
<p>With 25–30 files to convert, it’s possible I did save time with this macro. But the main reason I made it was to avoid the tedium and the likelihood of error on my part. These are not independent—I’m far more prone to make errors when the task is repetitive and doesn’t maintain my attention.</p>
|
||||
<div class="footnotes">
|
||||
<hr/>
|
||||
<ol>
|
||||
<li id="fn:zip">
|
||||
<p>No, a Dropbox link is really no more complicated than a zip file, but zip files are more familiar to more people. And although zipping JPEGs doesn’t make them smaller, it does package them up in a way that naive Windows users are usually comfortable with. It would be lovely if I always worked with people whose computer skills were trustworthy, but that’s not the world I live in. <a href="#fnref:zip" rev="footnote">↩︎</a></p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/11/another-one-off-keyboard-maestro-macro/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Binomial baseball</title>
|
||||
<link>http://leancrew.com/all-this/2017/10/binomial-baseball/</link>
|
||||
<pubDate>Mon, 30 Oct 2017 18:14:47 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/10/binomial-baseball/</guid>
|
||||
<description>
|
||||
<![CDATA[While reading a recap of last night’s World Series games, I saw this statistic: of the 65 Series that have had a sixth game, the team with the 3–2 lead has won the Series 43 times. This was, I think, intended to show us that the Astros have a strong chance to beat out the Dodgers for the title. And they do. But not as strong as you might expect.]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>While reading a recap of last night’s World Series games, I saw this statistic: of the 65 Series that have had a sixth game, the team with the 3–2 lead has won the Series 43 times. This was, I think, intended to show us that the Astros have a strong chance to beat out the Dodgers for the title. And they do. But not as strong as you might expect.</p>
|
||||
<p>If the teams were evenly balanced and each game independent of the others, we would expect the team with the 3–2 lead to win 75% of the time. 50% of the time they’d win the sixth game and the Series would be over; 25% of the time (50% of the other 50%) they’d win in the seventh game. So the leading team “should” have won the Series 48 or 49 times out of 65, not 43 times.</p>
|
||||
<p>Is this 5 or 6 game difference meaningful? For that we need to do some calculations using the <a href="https://en.wikipedia.org/wiki/Binomial_distribution">binomial distribution</a>. Python’s SciPy set of libraries has a subsection of statistical modules, including one for <a href="https://docs.scipy.org/doc/scipy-0.19.1/reference/generated/scipy.stats.binom.html">binomial distribution calculations</a>. We can import it this way:</p>
|
||||
<pre><code>python:
|
||||
from scipy.stats import binom
|
||||
</code></pre>
|
||||
<p>Let’s start by figuring out the probability that the leading team would win 43 times in 65 trials. With a 75% probability of winning the Series in each trial, the probability of 43 Series wins in 65 chances is calculated through</p>
|
||||
<pre><code>python:
|
||||
binom.pmf(43, 65, .75)
|
||||
</code></pre>
|
||||
<p>where the <code>pmf</code> function gets its name from the standard abbreviation for “<a href="https://en.wikipedia.org/wiki/Probability_mass_function">probability mass function</a>.” The answer is 0.029 or just under 3%. This makes it seem very unlikely that our assumption of 50–50 games would lead to only 43 Series wins for the leading team.</p>
|
||||
<p>But that isn’t the way these sorts of calculations are normally done. If we want to find out if a seemingly out-of-whack result is “statistically significant,” we should look at the probability of results that are at least as far away from our expectations as the actual result was. In our case, that means looking not only at the probability of 43 Series wins out of 65 chances, but also 42 wins, 41 wins, and so on. We then add up all of these “at least as weird” probabilities.</p>
|
||||
<p>The usual terminology for this sort of summation is “cumulative distribution function,” and the <code>binom</code> module has a function for it:</p>
|
||||
<pre><code>python:
|
||||
binom.cdf(43, 65, .75)
|
||||
</code></pre>
|
||||
<p>The result is 0.0695, or about 7%. Another way of looking at this is that if our assumption of 50–50 games were correct, there’s a 93% chance that the leading team would win the Series more than 43 times in 65 chances.</p>
|
||||
<p>In <a href="https://onlinecourses.science.psu.edu/statprogram/node/138">hypothesis testing</a>, the value 0.0695 is called the <em>p-value</em>,
|
||||
and it’s common in many fields to consider a result statistically significant if its p-value is less than 0.05. Using that criterion, we would not take the difference between our “null hypothesis” of 50–50 games and the World Series history as statistically significant.<sup id="fnref:two"><a href="#fn:two" rel="footnote">1</a></sup></p>
|
||||
<p>But it’s something for Dodgers fans to cling to.</p>
|
||||
<div class="footnotes">
|
||||
<hr/>
|
||||
<ol>
|
||||
<li id="fn:two">
|
||||
<p>Yes, I’ve been a little breezy here with my definition of null and alternate hypotheses and one-sided vs. two-sided rejection areas, but it’s just baseball. <a href="#fnref:two" rev="footnote">↩︎</a></p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/10/binomial-baseball/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Judas</title>
|
||||
<link>http://leancrew.com/all-this/2017/10/judas/</link>
|
||||
<pubDate>Sat, 28 Oct 2017 14:33:47 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/10/judas/</guid>
|
||||
<description>
|
||||
<![CDATA[I can’t say I wasn’t warned. The concert’s promotional artwork (especially those fonts) and the previous two albums, <a href="https://geo.itunes.apple.com/us/album/shadows-in-the-night/id945762927?uo=4&at=10l4Fv"><em>Shadows in the Night</em></a> and <a href="https://geo.itunes.apple.com/us/album/fallen-angels/id1099677284?uo=4&at=10l4Fv"><em>Fallen Angels</em></a>, were strong clues that I was going to be seeing a Bob Dylan infected by the Great American Songbook.]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>I can’t say I wasn’t warned. The concert’s promotional artwork (especially those fonts) and the previous two albums, <a href="https://geo.itunes.apple.com/us/album/shadows-in-the-night/id945762927?uo=4&at=10l4Fv"><em>Shadows in the Night</em></a> and <a href="https://geo.itunes.apple.com/us/album/fallen-angels/id1099677284?uo=4&at=10l4Fv"><em>Fallen Angels</em></a>, were strong clues that I was going to be seeing a Bob Dylan infected by the Great American Songbook.</p>
|
||||
<p><img alt="Dylan concert promo" class="ss" src="http://leancrew.com/all-this/images2017/20171028-Dylan%20concert%20promo.png" title="Dylan concert promo"/></p>
|
||||
<p>So yes, we got “Melancholy Mood” and “Autumn Leaves” and “The September of My Years” with Bob crooning into a big microphone and holding its stand at a jaunty angle. But that’s not what I disliked about the concert. In fact, those songs were done pretty well, and Dylan’s voice sounded better than any previous concert I’ve been to. It was what he did to his own songs that was frustrating.</p>
|
||||
<p>No one in his right mind goes to a Dylan concert expecting to hear his classics played or sung the way they were done originally. But the treatment they’re given is always interesting and usually fun. Not this time. Apart from “It Ain’t Me, Babe” and “Highway 61 Revisited,” the Dylan songs suffered from arrangements that were, I guess, meant to match the style of the non-Dylan songs. Under these conditions, you can’t expect the songs to rock, but you can expect them to swing. And the band just didn’t swing.</p>
|
||||
<p>There was a sameness to Charlie Sexton’s guitar work throughout the night. Despite changing instruments several times, his sound was constrained and repetitive. But when a band doesn’t swing, it’s mainly because of the rhythm section. These are talented musicians who can play in any style, so if they didn’t find a groove it must have been because Bob didn’t want them to.</p>
|
||||
<p>As a result, he lost the audience. Many left early and those who hung in there stayed glued to their seats until the encores. Can you imagine a Dylan audience not standing to “Tangled Up in Blue”?</p>
|
||||
<p>The optimist in me notes that Dylan never sticks with anything for long, and after two albums of standards he may be ready for the next thing. I hope he comes back to the notion that that it’s his songs, and the blues and country/folk they came out of, that are truly the Great American Songbook and gives them the treatment they deserve.</p>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/10/judas/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Icons</title>
|
||||
<link>http://leancrew.com/all-this/2017/10/icons/</link>
|
||||
<pubDate>Fri, 27 Oct 2017 01:39:06 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/10/icons/</guid>
|
||||
<description>
|
||||
<![CDATA[I have some code sitting around here somewhere for extracting the images (app icons, book covers, album art, etc.) from the various iTunes and App Stores. But I think it’ll be easier to use <a href="http://brettterpstra.com/2017/10/25/itunesicon-2-dot-3/">Brett Terpstra’s iTunesIcon Automator app</a>, which just got an update.]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>I have some code sitting around here somewhere for extracting the images (app icons, book covers, album art, etc.) from the various iTunes and App Stores. But I think it’ll be easier to use <a href="http://brettterpstra.com/2017/10/25/itunesicon-2-dot-3/">Brett Terpstra’s iTunesIcon Automator app</a>, which just got an update.</p>
|
||||
<p>Apart from its appeal to my laziness, Brett’s little app has a cool icon that I took an instant liking to.</p>
|
||||
<p><img alt="iTunesIcon icon" class="ss" src="http://leancrew.com/all-this/images2017/20171026-iTunesIcon%20icon.png" title="iTunesIcon icon"/></p>
|
||||
<p>If you work around industrial and construction equipment, Brett’s icon should bring a smile of familiarity. It’s highly reminiscent of the hands in safety signs and decals that are in dire straits.</p>
|
||||
<p><img alt="Safety symbols" class="ss" src="http://leancrew.com/all-this/images2017/20171026-Safety%20symbols.png" title="Safety symbols"/></p>
|
||||
<p class="caption">Images from <a href="http://www.safetysign.com/iso-warning-labels">SafetySign.com</a></p>
|
||||
<p>I’m sure your fingers are safe when using iTunesIcon.</p>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/10/icons/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Feed reading</title>
|
||||
<link>http://leancrew.com/all-this/2017/10/feed-reading/</link>
|
||||
<pubDate>Mon, 23 Oct 2017 00:10:42 +0000</pubDate>
|
||||
<dc:creator>
|
||||
<![CDATA[Dr. Drang]]>
|
||||
</dc:creator>
|
||||
<guid>http://leancrew.com/all-this/2017/10/feed-reading/</guid>
|
||||
<description>
|
||||
<![CDATA[Gabe Weatherhead has <a href="http://www.macdrifter.com/2017/10/feedbin-as-a-multi-device-reader.html">a nice article today</a> on how he uses Feedbin to handle his reading on the web. If you follow Gabe—and if not, why don’t you?—it will not surprise you to learn that he’s formidably organized. I don’t see myself following in his footsteps, but it’s always useful to learn how smart people do things. His article also reminded me that I’ve been meaning to write about <em>my</em> feed reading setup.]]>
|
||||
</description>
|
||||
<content:encoded>
|
||||
<![CDATA[<p>Gabe Weatherhead has <a href="http://www.macdrifter.com/2017/10/feedbin-as-a-multi-device-reader.html">a nice article today</a> on how he uses Feedbin to handle his reading on the web. If you follow Gabe—and if not, why don’t you?—it will not surprise you to learn that he’s formidably organized. I don’t see myself following in his footsteps, but it’s always useful to learn how smart people do things. His article also reminded me that I’ve been meaning to write about <em>my</em> feed reading setup.</p>
|
||||
<p>A couple of years ago, I let my subscription to <a href="https://feedwrangler.net/welcome.html">Feed Wrangler</a> lapse and started using a homemade, web-based RSS reading system. The heart of the system is still the script described in <a href="http://leancrew.com/all-this/2015/11/simpler-syndication/">this post</a>, but with a some changes as I thought of better ways of doing things.</p>
|
||||
<p>The biggest change came in the past few months. Initially, I created a single static web page with all of today’s articles from the feeds I subscribe to. A <a href="https://en.wikipedia.org/wiki/Cron">cron</a> task updated the page a few times an hour throughout the day. In this system, “today” was defined as “from 10:00 pm last night until now,” and the page would grow in size from morning to night.</p>
|
||||
<p>The advantage of this temporal arrangement from a programming point of view was that I didn’t have to write any code to keep track of whether I’d already read an article or not, and there were no external dependencies. If it was published “today,” it got on the page.</p>
|
||||
<p>The disadvantage was from the reading point of view. As I visited the page throughout the day, it became more and more filled with article I’d already read. This wasn’t as terrible as you might think. The articles were arranged in reverse chronological order by publication time, so the ones I’d read were typically at the bottom of the page. I say “typically” because some feeds—<a href="https://xkcd.com/">XKCD</a> comes to mind—are very bad at providing accurate publication times and their articles would sometimes end up at the bottom despite being recently published.</p>
|
||||
<p>Eliminating the reading disadvantage meant keeping track of what I’d read and showing only what I hadn’t—eliminating the programming advantage. I decided to keep track of read articles in an <a href="https://www.sqlite.org/">SQLite</a> database and to add items to that database through a button placed at the bottom of each article on my RSS page.</p>
|
||||
<p><img alt="RSS buttons" class="ss" src="http://leancrew.com/all-this/images2017/20171022-RSS%20buttons.png" title="RSS buttons" width="60%"/></p>
|
||||
<p>This meant</p>
|
||||
<ol>
|
||||
<li>Building a database that would uniquely identify every article. This was pretty simple. Each record has just two fields: the name of the website and the unique article ID (which is often just the article’s URL but is sometimes a long alphanumeric string generated by the site’s blogging software).</li>
|
||||
<li>Altering the existing script that builds the RSS page to filter out feed items that are in the database. Because Python has an <a href="https://docs.python.org/2/library/sqlite3.html">SQLite module</a> as part of its standard library and the syntax of SQL commands is straightforward, this wasn’t as tricky as I thought it would be. In fact, the new code is easier to read than the time-based filtering code I removed.</li>
|
||||
<li>Writing a server script (basically just a CGI script) to add an article to the database when given the blog name and article ID via the <code>POST</code> method. It’s been a while since I last wrote a CGI script, but it was like riding a bicycle.</li>
|
||||
<li>Adding some JavaScript with <a href="https://en.wikipedia.org/wiki/XMLHttpRequest"><code>XMLHttpRequest</code></a> to the RSS page to call the server script when a button is pressed. This took the most time, mainly because everyone in the world (except me) knows how to do AJAX now, and finding references written at an appropriately low level was harder than I expected. I found <a href="https://stackoverflow.com/questions/9713058/send-post-data-using-xmlhttprequest">this Stack Overflow discussion</a> helpful.</li>
|
||||
</ol>
|
||||
<p>So now I usually tap the <span class="menu">Mark as read</span> button when I get to the end of an article. If it’s a <a href="https://stratechery.com/">long article</a> that I want to read later, I don’t mark it as read, and it’ll be there the next time I bring up the RSS page.</p>
|
||||
<p>Fearing I’d forget how to use <code>XMLHttpRequest</code>, I quickly included another form at the end of each article for adding that article to my <a href="https://pinboard.in/api">Pinboard</a> account. I didn’t bother adding labels to the text field, because I’m the only one who uses this and I know the field is for tags. I did, however, include some DOM stuff to make it obvious when I’d marked an article as read or added it to Pinboard.</p>
|
||||
<p><img alt="RSS buttons marked" class="ss" src="http://leancrew.com/all-this/images2017/20171022-RSS%20buttons%20marked.png" title="RSS buttons marked" width="60%"/></p>
|
||||
<p>What I like about this system is how portable and (I hope) future-proof it is. I’ve been reluctant to sign on with Feedbin or Feedly or BazQux or any of the other Google Reader replacements because I worry they’ll <a href="http://observer.com/2017/01/medium-fail-post-literary-genre/">write a Medium post</a> and disappear with my subscription list and whatever organization scheme I’ve created. My system can run on any web server with Python, SQLite, and a <code>cgi-bin</code> directory. I think that’ll mean “any server, anywhere” for a very long time.</p>
|
||||
<br />
|
||||
<p>[If the formatting looks odd in your feed reader, <a href="http://leancrew.com/all-this/2017/10/feed-reading/">visit the original article</a>]</p>]]>
|
||||
</content:encoded>
|
||||
</item>
|
||||
|
||||
</channel>
|
||||
</rss>
|
||||
|
Loading…
Reference in New Issue