Weekly review: Week ending November 6, 2015

It was warmer and sunnier than usual, which felt great. Lots of long walks, and even a sunny afternoon on the deck.

More interactions with people, too. I made it out to Hacklab and helped with Tuesday’s dinner. On Friday, another friend dropped by and we went for a walk in the park.

Lots of coding this week. More progress on the scraper I’ve been working on, and some ideas for other prototypes my clients want me to build. Whee! Some fun on the Emacs front, too. I finally set up org-protocol, and I’m looking forward to playing with more integration points.

I filed my corporate taxes, yay! I’d done most of the figuring out in September before my fiscal year end, so it was mostly a matter of updating the numbers with the final statements from the bank and doublechecking all the calculations before submitting it to the government. Looks like everything’s good.

I might tilt the balance towards consulting a little bit more over the next couple of months. There are a few projects that might be interesting to pull off, and the team would probably find them very helpful. I can move the time from things like Latin and sewing, which I can reduce without much of a tradeoff.


2015-11-08b Week ending 2015-11-06 -- index card #journal #weekly output

Blog posts


Focus areas and time review

  • Business (24.9h – 14%)
    • Earn (13.0h – 52% of Business)
      • Prepare invoice
      • Do monthly data dump
      • Start second scraper
      • Draft browsing interface
    • Build (8.4h – 33% of Business)
      • Drawing (0.0h)
      • Paperwork (2.5h)
        • Include September bank statements
        • Do Paypal USD conversion
        • Do HST quicktax calculation
        • Credit personal amounts
        • Doublecheck prepaid expenses
        • Write reimbursement cheque
        • Finalize return
        • File federal return
        • File HST return
        • Set up quarterly payments
    • Connect (3.5h – 14% of Business)
  • Relationships (9.3h – 5%)
    • Have dimsum with family
    • Hang out with Jen
  • Discretionary – Productive (12.3h – 7%)
    • Emacs (2.8h – 1% of all)
      • Do another Emacs review
      • Set up a nested hydra
      • Play with melpa stats
      • Update missing podcast episode
    • Sewing (1.2h)
    • Writing (1.4h)
    • Check out Stoic Week
    • Update Quantified Awesome goals
    • Rake leaves
    • Investigate library xml dump
    • Check out Stoic Week
    • Do another Emacs review
  • Discretionary – Play (26.0h – 15%)
  • Personal routines (21.0h – 12%)
  • Unpaid work (9.4h – 5%)
  • Sleep (66.1h – 39% – average of 9.4 per day)

Capturing links quickly with emacsclient, org-protocol, and Chrome Shortcut Manager on Microsoft Windows 8

UPDATE 2015-11-30: Well, that bitrotted quickly! Chrome Shortcut Manager is no longer available, so I might look into customizing https://github.com/CestDiego/org-capture-chrome instead.

Since I’ll be snipping lots of Emacs-related resources and organizing them into Emacs news roundups, I figured it was time to get org-protocol working.

Step 1: Get emacsclient to work

I was getting the error “No connection could be made because the target machine actively refused it.” I needed to change my Windows Firewall rules. From the Windows Firewall screen, I clicked on Advanced settings and chose Inbound Rules. On the Programs and Services tab, I confirmed that the right Emacs binary was selecI looked for the rules for GNU Emacs, consolidating them down to two rules (UDP and TCP). I limited the scope to local/remote On the advanced tab, I selected all the profiles and changed edge traversal to blocked.

I was still getting the error despite a fresh M-x server-start. After I deleted the contents of ~/.emacs.d/server and did another M-x server-start. When I ran emacsclient test.txt from the command-line, it correctly opened the file in my existing Emacs instance. Hooray!

Step 2: Load org-protocol

I added org-protocol to the org-modules variable so that Org would load it when Emacs reaches the (org-load-modules-maybe t) in my config. Since I didn’t want to restart Emacs, I also evaluated (load-library "org-protocol") to load it.

Step 3: Register the protocol

I ran an org-protocol.reg that set up the appropriate org protocol entry:

Windows Registry Editor Version 5.00

"URL Protocol"=""
@="URL:Org Protocol"



@="\"c:\\Program Files (x86)\\GNU Emacs 24.4\\bin\\emacsclientw.exe\"  \"%1\""

You can find a similar one in the org-protocol documentation.

Step 4: Add support to Chrome

I wanted something a bit different from the org-capture extensions available for Chrome. In particular, I wanted:

  • a keyboard-friendly way to quickly store a link
  • a keyboard-friendly way to capture a link with some notes

The Shortcut Manager extension for Chrome lets you specify your own keyboard shortcuts for running short Javascript. Inline Javascript doesn’t work on all sites. For example, Github blocks it with the following error: Refused to execute inline script because it violates the following Content Security Policy directive: "script-src assets-cdn.github.com". Either the 'unsafe-inline' keyword, a hash ('...'), or a nonce ('nonce-...') is required to enable inline execution. Still, it works for many sites, so it’s a start. Here are the shortcuts I put together.

l Store link
L Store link (prompt for title, default to selection or document title)
c Capture link (prompt for template)

You can import them by going to Chrome’s More Tools > Extensions screen and choosing the Options link for Shortcut Manager. From there, use Import settings.

// ==UserScript==
// @ShortcutManager
// @name Store link
// @namespace XPrUJhE4wRsC
// @key l
// @include *
// ==/UserScript==
var storeLink = function(){
  var selection = window.getSelection().toString();
  var uri = 'org-protocol://store-link://' +
        encodeURIComponent(window.location.href) + '/' +
        encodeURIComponent(selection || document.title);
  window.location = uri;
  return uri;

// ==UserScript==
// @ShortcutManager
// @name Capture link
// @namespace XPrUJhE4wRsC
// @key c
// @include *
// ==/UserScript==
var captureLink =function(){
  var uri = 'org-protocol://capture://' +
        encodeURIComponent(window.location.href) + '/' +
        encodeURIComponent(document.title) + '/' +
  window.location = uri;
  return uri;

// ==UserScript==
// @ShortcutManager
// @name Store link with prompt
// @namespace XPrUJhE4wRsC
// @key Shift+l
// @include *
// ==/UserScript==
var storeLinkWithPrompt = function(){
  var selection = window.getSelection().toString();
  var uri = 'org-protocol://store-link://' +
        encodeURIComponent(window.location.href) + '/' +
        encodeURIComponent(window.prompt('Title', selection || document.title));
  window.location = uri;
  return uri;

Shortcut Manager looks like a really useful extension. Here are some other shortcuts I set up:

x close the current tab
r reload (cacheless)
t open a new tab
n select the right tab
p select the left tab
b back
f forward

Step 5: Add shortcuts for managing stored links

I added my/org-insert-link and org-insert-last-stored-link to my main hydra, which is on my hh keychord. my/org-insert-link is like org-insert-link, except it adds a newline if the cursor is at an Org link so that we don’t trigger org-insert-link‘s behaviour of editing links.

(defun my/org-insert-link ()
  (when (org-in-regexp org-bracket-link-regexp 1)
    (goto-char (match-end 0))
    (insert "\n"))
  (call-interactively 'org-insert-link))

(key-chord-define-global "hh"
                         (defhydra my/key-chord-commands ()
                           ;; ...
                           ("L" my/org-insert-link)
                           ("l" org-insert-last-stored-link)
                           ;; ...

This lets me quickly insert a bunch of links with a key sequence like h h l l l l or select a link to insert with h h L. C-y (yank) pulls in the URL of the last stored link, too.

Let’s see how this works out!

Monthly review: October 2015

What a month for learning and making. =)

I think I’m starting to get the hang of asynchronous programming using the Q library for Javascript, with its ability to defer execution and pass values along. After I sorted out the mistakes I made while coding – such as returning the deferred object instead of the promise, or doing a convoluted promise instead of using q(…) to simplify handling either return values or promises – things made sense.

I used d3 to sketch one of the little visualizations I’ve been thinking about doing for my consulting client for a while now. It was well-received. I should get back to it and make it interactive.

Also, tech-wise: nudged by John Wiegley, I’ve started summarizing new Emacs-related resources from planet.emacsen.org, reddit.com/r/emacs, and Youtube.

I’ve been getting my business papers together in preparation for another tax return, and my notes from last year have been helpful. I’ve added more notes, so maybe next year will be even easier. The more I write down, the better things are for my future self.

In terms of sewing, I’ve gotten a bit more comfortable with the mathematics and programming involved in creating parametric sewing patterns using the Python framework I started playing around with some time ago. I’ve also moved into the mass production phase for some of the projects I’ve been working – well, not really mass production, but quite a few multiples of patterns that look like they’ll work out nicely.

Slow and steady progress through the Latin textbooks. I’m starting to get the hang of the first to third declensions, I think, and some of the types of verbs as well. It’s amusing to discover these little things about the phrases we’re so familiar with. In caveat emptor, caveat is the subjuctive of caveo (beware), so caveat is “let him/her/it beware”. Cave – from cave canem – is the imperative, “Beware!” Little things. =)

We cleared out the garden and got it ready for winter. The irrigation system was very helpful, keeping things surprisingly alive and thriving despite my neglect. We didn’t get as much out of it as we probably could have, but it was nice to have had a few bitter melons, a good supply of peas, and the surprise of a huge bok choy.

Lots of playing Borderlands 2: going through the downloadable content, and trying out a new character. W- and I have settled into a comfortable routine of playing an hour or two (and sometimes more) of Borderlands late at night, and then reading a bit before bed.

It’s been great being able to think clearly again, mostly. It’s probably more likely for me to assume fuzziness rather than clarity as the default. I wonder what I can put into place now so that later will be easier.

Let’s see what November will be like. It’s pretty cool to see the progression of months, each an unexpectedly full gift. Day by day, I know it adds up, but it’s still surprising.

2015-11-01c October 2015 -- index card #journal #monthly #review output

Blog posts



Category Last month % This month % Avg h per week Delta (h/wk)
Business – Earn 5.9 11.2 19 8.9
Business – Connect 0.5 1.1 2 1.0
Discretionary – Family 2.1 2.6 4 0.8
Personal 19.7 20.0 34 0.5
Business – Build 3.1 3.2 5 0.2
Discretionary – Social 0.4 0 0 -0.7
Discretionary – Productive 11.7 11.2 19 -0.8
Discretionary – Play 8.3 6.9 12 -2.4
Unpaid work 7.8 6.3 11 -2.5
Sleep 40.5 37.4 63 -5.2

A lot more consulting than I expected. The projects were useful and fun, so it was easy to work on that instead of other things. I thought I spent more time cooking and tidying, too, but the numbers don’t agree. Mmm. My time sense is a bit off for month-long spans, even though the days and the weeks make sense. Ah well, that’s why there’s data! =)

2015-11-02 Emacs News

Previous roundup – Links from reddit.com/r/emacs, planet.emacsen.org, and Youtube

Weekly review: Week ending October 30, 2015

This was a good week for making things. I coded a bunch of patterns and capabilities in the Python-based sewing pattern generator I’ve been tinkering around with. Now that I can easily rescale patterns and set measurements from the command-line, I can create paper models to test ideas. It was fun doing the math for rotating points and doing simple dart manipulation, too. In addition to programming, I also finished the mass production phase of one of my sewing projects. Yay!

Good cooking this week, too. We tried this General Tsao Chicken recipe – our first time to double-fry – and it was yummmmmy. I made a pan of lasagna, too.

The Latin 101 video course I’d checked out from the library turned out to have a few errors in the guidebook, so I’ve been using a combination of that and Wheelock’s Latin for practice. It’s fun feeling things start to make sense.

W- and I started a new playthrough of Borderlands 2, the shooter/RPG we’ve been playing for a few months now. We picked different characters, so we’ve been adapting to the new playstyles required.

Some fuzziness and tiredness, but such is life. Taking it easy. =)

2015-11-01b Week ending 2015-10-30 -- index card #journal #weekly output

Blog posts


Link round-up

  • Business (29.7h – 17%)
    • Earn (10.0h – 33% of Business)
      • Attend scraper meeting
      • Prepare invoice
    • Build (13.3h – 44% of Business)
      • Drawing (1.0h)
      • Paperwork (0.4h)
        • Include September bank statements
        • Finalize return
    • Connect (6.3h – 21% of Business)
  • Relationships (3.1h – 1%)
  • Discretionary – Productive (16.4h – 9%)
    • Emacs (2.6h – 1% of all)
      • Do another Emacs review
      • Do another Emacs review
    • Sewing (5.0h)
      • Add scale to tmtp
      • Try papercraft tmtp with my measurements
      • Programmatically rescaling and manipulating the darts in sewing patterns
      • Add SVG splitter to tmtp
      • Add seam allowances to tmtp
      • Sanity-check with someone else’s basic bodice block instructions
      • Python + sewing: Making basic shapes and splitting up larger patterns
      • Circle skirt pattern
      • Box tote pattern
      • Sew box tote prototype
    • Writing (2.0h)
    • Do a chapter of Wheelock’s Latin
    • Send in form
  • Discretionary – Play (17.1h – 10%)
  • Personal routines (30.7h – 18%)
  • Unpaid work (9.9h – 5%)
  • Sleep (61.1h – 36% – average of 8.7 per day)

Python + sewing: Making basic shapes and splitting up larger patterns

More Python and sewing. =) The first step was to make parameterization even easier by allowing command-line specification of measurements. I refactored some code from client.py and modified mkpattern to accept the new arguments, splitting up the name and value based on regular expressions (commit). That way, I could quickly generate patterns based on different dimensions, like so:

python ../mkpattern --client=../customer/Sacha/sacha-cm.json \
   --pattern=../patterns/box_tote.py \
   --styles=../tests/test_styles.json \
   -m height=4in -m width=7.5in -m seam_allowance=0.5in \
   -m depth=7.5in -m strap_width=1in -m strap_length=10in -m hem_allowance=1in \

I sketched basic patterns for cylindrical and box-type containers the other day, so I wanted to try them out. It turned out that the Python framework I used for sewing patterns didn’t yet support arcs. Adding the arc element to the SVG was straightforward. I initially faked the bounding box for the arc, but since that made the code misbehave a little, I looked around for a better implementation. I translated the code from this post from 2011 to Python and added it to the code (git commit). That allowed me to make a simple cylinder pattern generator. I haven’t tested it yet, but it looks reasonable.

2015-10-27 20_30_11-foo.svgThe box tote was interesting to work on. When I did the math, I couldn’t believe that the calculations were that simple. I was waiting for a sqrt or a cos to show up, I think. Still, the small-scale paper version I taped up looks like it makes sense, and I’ll sew a full-size version soon. J- asked for a light blue lunch bag that would fit our standard containers, and I’ve been meaning to make a casserole carrier for a while now. It would be handy to be able to make bags that are the right size. Too small and things don’t lie flat, too big and they move around too much.

2015-10-27 20_31_54-foo.svg - Inkscape

I spent most of my time making a flexible circle skirt pattern, pretzeling my brain around circumferences, angles, multiple pieces, and fullness multipliers. I’m happy with the way it turned out. It can generate patterns for quarter-circle skirts, half-circle skirts, full-circle skirts – even an arbitrary fraction of skirt fullness split into an arbitrary number of pieces, with optional seam allowance, waist seam allowance, and hem allowance. If you give it the fabric width, it will split the pattern into however many pieces are needed. If you specify a seam allowance and you want a full-circle skirt in a single piece (maybe for dolls), it’ll leave room for the seam allowances by adjusting the inner radius. We’re heading into snow pants season, so I probably won’t get around to testing it in fabric for a while. Caveat netrix, I guess.

I also got around to writing a tool for splitting up large patterns so that I could print them on a regular printer. I had tried Posterazor and a few other tools for splitting up large images into smaller pages, but I wanted something that would add cutting lines and page numbers. It turns out that all you need to do is change the SVG’s height, width, and viewPort. I added a rectangle for the cutting line and some text for the page numbers. I haven’t figured out how to use pysvg to replace the contents of an existing text element, but since the tool prints out non-overlapping regions, I just keep adding more text elements. My script creates a numbered sequence of SVGs. I haven’t found a convenient way to print multiple SVGs in one go, but I can select multiple PNGs and print those, and I can use Inkscape’s command line to convert SVGs to PNGs like so:

inkscape -z -e output-01.png -d 300 output-01.svg

There’s supposed to be a -p command to output Postscript ready for printing, but command-line printing on Windows doesn’t seem to be as much of a thing as it is on Linux. Something to figure out another time, maybe. Anyway, now that I have a conversion pipeline, I can write a Bash script or Emacs Lisp to process things automatically.

I’ll probably move from all this theoretical script-writing to more hands-on sewing during the rest of the week. My fabric order has arrived, so I’ve got a bit of cutting and sewing ahead of me.

Hmm. With the command-line measurement and scaling overrides, it might be interesting to use this framework for papercraft and laser-cutting too. Someday!