Category Archives: geek

Pattern-making: Generating SVGs for sewing with Python and tmtp

I like sewing simple clothes, and I’d like to be able to continue doing that even as measurements change without having to rely on commercial patterns that would need to be manually adjusted anyway. I also want to experiment with computer-assisted cutting, like the way the laser cutter at made it super-easy to precisely cut the same top in different fabrics.

In sewing, there’s the idea of drafting a pattern based on a set of measurements and a few calculations. You could do this with a large roll of paper, a ruler, and some way to draw a smooth curve (French curves, hip curves, or even tracing around the edge of a plate). There are software programs to do this as well, but the commercial ones tend to cost a lot if you want one that automatically drafts the rest of the pattern based on your measurements. Still, you can translate the manual instructions to digital form by drawing the appropriate lines and curves in a vector drawing program such as Inkscape or Adobe Illustrator.

While researching open source options for pattern-making, I came across Tau Meta Tau Physica (tmtp). At its core, it’s a Python script that produces an SVG based on a programmed pattern and a set of measurements. With a little fiddling (downgraded pySVG, fixed some case sensitivity issues), I got it working on my system.

Both documentation and actual code samples were pretty sparse, but I figured out the basics by reading the library code and the test patterns. I spent the day working on translating some of the basic patterns from Cal Patch’s book Design-It-Yourself Clothes: Pattern Making Simplified. So far, I’ve put together plausible-looking replicas of the A-line skirt and the basic shirt.

One of the nifty things about writing programs to draft patterns is that I can use the library functions to calculate the lengths of the cubic Bezier curves I’m using for necklines and armholes. This is handy when calculating collar length or adjusting sleeve caps. In particular, it’s neat to be able to use a loop to adjust the sleeve cap by offsetting the bicep point, although I’ll probably tweak the algorithm because it might be good to balance that with other ways to adjust that sleeve cap length.

I still haven’t tested the patterns, though, and I’m not even sure I’m collecting all these measurements correctly. At some point, I’ll print them out and sew a muslin yet. It would be good to test the sleeve cap. But the patterns look reasonable, so that’s a start.

Here are some screenshots based on my current measurements, and some links to the patterns on Github:

A-line skirt: My default measurements have this skirt sitting at my natural waist, although I’ll probably drop the waistline a bit lower before sewing it.

2015-09-29 20_57_39-foo.svg

Basic shirt: Totally untested. Would be interesting to see if this sleeve actually works, or what needs tweaking.

2015-09-29 20_59_55-_foo.svg - Inkscape

I’ll work on encoding the Burda bodice block, and then I can use that to sanity-check the shirt. Then there’s figuring out poster printing, taping up the pattern, and trying it out. Looks promising, though! I’m still boggled that the math I did for squaring lines seems to actually work. Now if only I can figure out proper seam allowance calculations instead of leaving that as a post-processing step in Inkscape or on paper…

My Github fork of tmtp

Update on Emacs Conf 2015 videos; Org Mode tables and time calculations

I spent the day cutting up the rest of the videos from the Emacs Conference 2015 stream into individual talks. I’d already cut the set of talks before lunch, but there were quite a few more after. As it turned out, keeping the video data in .ts format instead of converting it to .mp4 is actually better for Youtube processing.

Since Camtasia Studio and Movie Maker were both having problems with the large videos, I used VLC to play the video and find the timestamps at which I needed to cut the segments. I made an Org Mode table with the start and end times, and then I used the ;T flag in a table function to get the duration. A little bit of Emacs Lisp code later, and I had my ffmpeg commands. Here’s the source from my Org file:

#+NAME: emacsconf-c.ts
| Notes                                            |      Start |        End | Duration |
| Emacs configuration                              | 4:02:25.37 | 4:27:09.30 | 00:24:44 |
| Hearing from Emacs Beginners                     |    4:27:27 |    5:01:00 | 00:33:33 |
| Lightning talk: Emacs Club                       | 5:03:19.30 | 5:19:37.83 | 00:16:18 |
| Starting an Emacs Meetup - Harry Schwartz part 1 | 5:31:52.03 |    6:01:20 | 00:29:28 |
#+TBLFM: $4=$3-$2;T

#+NAME: emacsconf-a.ts
| Notes                                                    |   Start |     End | Duration |
| Starting an Emacs Meetup - Harry Schwartz part 2         |  0:0:00 | 0:20:04 | 00:20:04 |
| Literate Devops - Howard Abrams                          | 1:28:20 | 2:08:15 | 00:39:55 |
| Lightning talk: Wanderlust and other mail clients        | 2:15:04 | 2:26:55 | 00:11:51 |
| Making Emacs a Better Tool for Scholars - Erik Hetzner   | 2:27:00 | 2:57:38 | 00:30:38 |
| Wrapping up and going forward                            | 2:58:09 | 2:59:44 | 00:01:35 |
| Lightning talk: Collaborative coding with tmux and tmate | 3:00:20 | 3:05:53 | 00:05:33 |
| Lightning talk: Cask and Pellet                          | 3:05:56 | 3:09:04 | 00:03:08 |
| Lightning talk: File sharing with Git and save hooks     | 3:09:34 | 3:17:50 | 00:08:16 |
| Lightning talk: Calc                                     | 3:18:42 | 3:33:20 | 00:14:38 |
| Lightning talk: Magit                                    | 3:35:15 | 3:49:42 | 00:14:27 |
| Lightning talk: gist.el                                  | 3:53:50 | 4:01:58 | 00:08:08 |
| Lightning talk: Go                                       | 4:02:45 | 4:16:37 | 00:13:52 |
| Question: Emacs Lisp backtraces                          | 4:16:50 | 4:20:09 | 00:03:19 |
#+TBLFM: $4=$3-$2;T

#+begin_src emacs-lisp :var data=emacsconf-a.ts :var data2=emacsconf-c.ts :colnames t :results output
(let ((format-str "ffmpeg -i %s -ss %s -t %s -c:v copy -c:a copy \"EmacsConf 2015 - %s.ts\"\n"))
  (mapc (lambda (file)
    (mapc (lambda (row) 
      (princ (format format-str (car file) (elt row 1) (elt row 3) (my/convert-sketch-title-to-filename (elt row 0))))) 
     (cdr file)))
    `(("emacsconf-c.ts" . ,data2)
      ("emacsconf-a.ts" . ,data))))

and the output:

ffmpeg -i emacsconf-c.ts -ss 4:02:25.37 -t 00:24:44 -c:v copy -c:a copy "EmacsConf 2015 - Emacs configuration.ts"
ffmpeg -i emacsconf-c.ts -ss 4:27:27 -t 00:33:33 -c:v copy -c:a copy "EmacsConf 2015 - Hearing from Emacs Beginners.ts"
ffmpeg -i emacsconf-c.ts -ss 5:03:19.30 -t 00:16:18 -c:v copy -c:a copy "EmacsConf 2015 - Lightning talk - Emacs Club.ts"
ffmpeg -i emacsconf-c.ts -ss 5:31:52.03 -t 00:29:28 -c:v copy -c:a copy "EmacsConf 2015 - Starting an Emacs Meetup - Harry Schwartz part 1.ts"
ffmpeg -i emacsconf-a.ts -ss 0:0:00 -t 00:20:04 -c:v copy -c:a copy "EmacsConf 2015 - Starting an Emacs Meetup - Harry Schwartz part 2.ts"
ffmpeg -i emacsconf-a.ts -ss 1:28:20 -t 00:39:55 -c:v copy -c:a copy "EmacsConf 2015 - Literate Devops - Howard Abrams.ts"
ffmpeg -i emacsconf-a.ts -ss 2:15:04 -t 00:11:51 -c:v copy -c:a copy "EmacsConf 2015 - Lightning talk - Wanderlust and other mail clients.ts"
ffmpeg -i emacsconf-a.ts -ss 2:27:00 -t 00:30:38 -c:v copy -c:a copy "EmacsConf 2015 - Making Emacs a Better Tool for Scholars - Erik Hetzner.ts"
ffmpeg -i emacsconf-a.ts -ss 2:58:09 -t 00:01:35 -c:v copy -c:a copy "EmacsConf 2015 - Wrapping up and going forward.ts"
ffmpeg -i emacsconf-a.ts -ss 3:00:20 -t 00:05:33 -c:v copy -c:a copy "EmacsConf 2015 - Lightning talk - Collaborative coding with tmux and tmate.ts"
ffmpeg -i emacsconf-a.ts -ss 3:05:56 -t 00:03:08 -c:v copy -c:a copy "EmacsConf 2015 - Lightning talk - Cask and Pellet.ts"
ffmpeg -i emacsconf-a.ts -ss 3:09:34 -t 00:08:16 -c:v copy -c:a copy "EmacsConf 2015 - Lightning talk - File sharing with Git and save hooks.ts"
ffmpeg -i emacsconf-a.ts -ss 3:18:42 -t 00:14:38 -c:v copy -c:a copy "EmacsConf 2015 - Lightning talk - Calc.ts"
ffmpeg -i emacsconf-a.ts -ss 3:35:15 -t 00:14:27 -c:v copy -c:a copy "EmacsConf 2015 - Lightning talk - Magit.ts"
ffmpeg -i emacsconf-a.ts -ss 3:53:50 -t 00:08:08 -c:v copy -c:a copy "EmacsConf 2015 - Lightning talk - gist.el.ts"
ffmpeg -i emacsconf-a.ts -ss 4:02:45 -t 00:13:52 -c:v copy -c:a copy "EmacsConf 2015 - Lightning talk - Go.ts"
ffmpeg -i emacsconf-a.ts -ss 4:16:50 -t 00:03:19 -c:v copy -c:a copy "EmacsConf 2015 - Question - Emacs Lisp backtraces.ts"

You can watch the Emacs Conference 2015 playlist on YouTube. At some point, each talk will probably have individual wiki pages and IRC logs at . =) Enjoy!

Related tech notes: Emacs Conf video tech notes:,, livestreamer, ffmpeg

Emacs Conf video tech notes:,, livestreamer, ffmpeg

Last week’s Emacs Conf was fantastic. There were lots of people at the in-person event in San Francisco, and people could also watch the stream through and ask questions through IRC. There were remote speakers and in-person speakers, and that mix even worked for the impromptu lightning talks sprinkled throughout the day.

This is how the tech worked:

  • Before the conference started, the organizers set up a laptop for streaming on This was hooked up to the main display (a large television with speakers). They also configured the account to record and archive videos. In the free account, recorded videos are available for 14 days.
  • Remote speakers were brought in using the Jitsi open source video conferencing system, using the public servers at This was on the same computer that did the streaming, so people watching the stream could see whatever was shared through Jitsi. Organizers read out questions from the in-person audience and from the IRC channel. The audio from Jitsi wasn’t directly available through, though. Instead, the audio came in as a recording from the laptop’s microphone.
  • Local speakers either used the streaming laptop to go to a specific webpage they wanted to talk about, or joined the Jitsi web conference using Google Chrome or Chromium so that they could share their screen. The organizers muted the second Jitsi client to avoid audio feedback loops.

That worked out really well. There were more than a hundred remote viewers. As one of them, I can definitely rate the experience as surprisingly smooth.

All that’s left now is to figure out how to make a more lasting archive of the Emacs Conf videos. As it turns out, or online tools don’t make it easy to download stream recordings that are longer than three hours. Fortunately, livestreamer can handle the job. Here’s what I did to download the timestream data from one of the recordings of EmacsConf:

livestreamer -o emacsconf-1.ts --hls-segment-threads 4 best
ffmpeg -i emacsconf-1.ts -acodec copy -absf aac_adtstoasc -vcodec copy emacsconf-1.mp4

I normally use Camtasia Studio to edit videos, but for some reason, it kept flaking out on me today. After the umpteenth crash, I decided to keep things simple by using ffmpeg to extract the relevant part of the video. To extract a segment, you can use -ss to specify the start time and t to specify the duration. Here’s a sample command:

ffmpeg -i emacsconf-1.mp4 -ss 1:18:06.11 -t 0:03:32.29 -c:v copy -c:a copy emacsconf-engine-mode.mp4

Your version of ffmpeg might have a -to option, which would let you specify the end time instead of using -t to specify duration.

I’m coordinating with the other organizers to see if there’s a better way to process the videos, so that’s why we haven’t released them publicly yet. (Soon!) It would be nice to improve the audio, especially for some of the talks, and maybe it would be good to add overlays or zoom in as well. The on-site organizers captured backup videos and screen recordings, too, so we might want to edit some of those clips into the streamed recording. One of the organizers has access to better video editing tools, so we’ll try that out.

Anyway, those were the commands that helped me get started with command-line conversion and editing of recorded videos. Hope they come in handy for other people too.

For more info about EmacsConf 2015, check out There’ll probably be an announcement there once the videos are up. =)

Hat tip to Reddit and for tips.

August 2015 Emacs Hangout

Thanks to Philip Stark for hosting this one!

Text chat:

Paul Harper 2:08 PM Evan’s Links: Dart Throwing Chimp:
Philip Stark 2:15 PM
Paul Harper 2:19 PM mu4e: Zawinski’s Law “Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.” Law of Software Envelopment, Jamie Zawinski. Mutt with Org-Mode:
me 2:23 PM Maybe ?
Magnus Henoch 2:24 PM I mashed some of those together into this monster: link (
Mond Beton 2:25 PM org mode is new
Rogelio Zarate 2:26 PM Just started with emacs
Paul Harper 2:27 PM Emacs and Vim started in 1976 link (
me 2:28 PM Was it this Err, link ( ?
Paul Harper 2:41 PM Not sure if this might help. Setting up Emacs key mappings on Windows Outlook link (
me 2:42 PM suggests XKeymacs, but I don’t know if it will work with recent versions of Windows.
Mond Beton 2:44 PM thank you
Rogelio Zarate 2:48 PM Too many opinions on how to do things, example keybing on emacs/os x
me 2:50 PM link ( may be helpful if you want it to reuse an existing Emacs if possible
Daniel Gopar 2:58 PM
Paul Harper 2:59 PM Something for beginners like me. A course in research tools which includes some clear videos on using Emacs. Kurt Schwehr put the course on YouTube (linked in note) and the course is in org mode. The Course itself is GIS focused. You can download the whole thing with Mercurial. Instructions on the page. I found it very helpful when I started.
Philip Stark 3:02 PM What’s GIS?
me 3:03 PM Phil: Hmm, something like using tags?
Philip Stark 3:05 PM
Philip Stark 3:07 PM
Daniel Gopar 3:09 PM so im learning elisp. Does elisp have any ways of creating private/public variables? or is everything exposed once you run the require command on the file?
Philip Stark 3:09 PM
Rogelio Zarate 3:14 PM How do you handle projects, like in Sublime, do you use Projectile or Perspective?
Philip Stark 3:14 PM
me 3:16 PM and
Philip Stark 3:18 PM
Rogelio Zarate 3:19 PM Keeping just one list sounds like the correct approach. Great tip.
me 3:19 PM link (
Paul Harper 3:21 PM Notmuch
me 3:29 PM Want to get notified about upcoming hangouts? You can sign up for notifications at

Org Mode date arithmetic

Whenever I need to get Emacs to prompt me for a date or time (even for non-Org things), I use org-read-date. I love its flexibility. It’s great to be able to say things like +3 for three days from now, fri for next Friday, +2tue for two Tuesdays from now, +1w for next week, and +1m for next month. It’s easy to use org-read-date in Emacs Lisp. Calling it with (org-read-date) (usually as an interactive argument, like so: (interactive (list (org-read-date)))) gives me a date like 2015-08-06 depending on what I type in.

I use org-read-date for non-interactive date calculations, too. For example, if I want to quickly get the Org-style date for tomorrow, I can use org-read-date‘s third parameter (from-string) like this:

(org-read-date nil nil "+1")

Here’s how to calculate relative dates based on a specified date. You can hard-code the base date or use another org-read-date to get it. In this example, I’m getting the Monday after 2015-08-31. Note the use of two + signs instead of just one.

(org-read-date nil nil "++mon" nil (org-time-string-to-time "2015-08-31"))

org-time-string-to-time converts a date or time string into the internal representation for time. You can then extract individual components (ex: month) with decode-time, or convert it to the number of seconds since the epoch with time-to-seconds. Alternatively, you can convert Org time strings directly to seconds with org-time-to-seconds.

If you’re working with days, you can convert time strings with org-time-string-to-absolute. For example, you can use this to calculate the number of days between two dates (including the first day but excluding the last day), like this:

(let ((start-date (org-read-date))
      (end-date (org-read-date)))
  (- (org-time-string-to-absolute end-date)
     (org-time-string-to-absolute start-date)))

To get the month, day, and year, you can use org-time-string-to-time and decode-time, or you can use org-time-string-to-seconds and calendar-gregorian-from-absolute.

To convert internal time representations into Org-style dates, I tend to use (format-time-string "%Y-%m-%d" ...). encode-time is useful for converting something to the internal time representation. If you’re working with absolute days, you can convert them to Gregorian, and then format the string.

So, to loop over all the days between the start and end date, you could use a pattern like this:

(let* ((start-date (org-read-date))
       (end-date (org-read-date))
       (current (org-time-string-to-absolute start-date))
       (end (org-time-string-to-absolute end-date))
  (while (< current end)
    (setq gregorian-date (calendar-gregorian-from-absolute current))
    (setq formatted-date
          (format "%04d-%02d-%02d"
                  (elt gregorian-date 2) ; month
                  (elt gregorian-date 0) ; day
                  (elt gregorian-date 1))) ; year
    ;; Do something here; ex:
    (message "%s" formatted-date)
    ;; Move to the next date
    (setq current (1+ current))))

Alternatively, you could use org-read-date with a default date, like this:

(let* ((start-date (org-read-date))
       (end-date (org-read-date))
       (current start-date))
  (while (string< current end-date)
    ;; Do something here; ex:
    (message "%s" current)
    ;; Move to the next date
    (setq current (org-read-date nil nil "++1" nil (org-time-string-to-time current)))))

There are probably more elegant ways to write this code, so if you can think of improvements, please feel free to share.

Anyway, hope that helps!

July 2015 Emacs Hangout

We talked about Python, Org Mode, system administration, keybindings, Hydra, and other neat things. =)

I’ll probably set up another hangout mid-August, or we’ll just do the one on the 29th. We’ll see! You can follow the Emacs Conferences and Hangouts page for more information, or sign up to get e-mails for upcoming hangouts. Past Emacs Hangouts

Text chat (links edited to avoid weird wrapping things):

me 9:18 PM literate devops link
Daniel Gopar 9:34 PM config link
me 9:37 PM jwiegley/dot-emacs jwiegley – haskell
Howard Melman 9:48 PM cocoa-text-system
Mr Swathepocalypse 9:55 PM I have to go attend to some work stuff, I look forward to watching the rest of the hangout later on.
me 9:55 PM Orgstruct
Mr Swathepocalypse 9:55 PM Thanks guys!
me 9:55 PM Bye Dylan! my config erc erc-pass
Howard Abrams 9:59 PM Did I mention how I’ve been using emacs mail to mime encode an org-mode buffer into HTML for the most awesome mail messages.
Daniel Gopar 10:05 PM Have you guys used “helm-M-x”? It’s part of the helm package I believe
Kaushal Modi 10:07 PM ready to share which-key package
Daniel Gopar 10:10 PM Got to go. Nice talking to everyone.
Kaushal Modi 10:14 PM config link
Kaushal Modi 10:37 PM (setq debug-on-message “Making tags”)
me 10:39 PM org-map-entries
Correl Roush 10:47 PM git graphs
me 10:54 PM imagex-global-sticky-mode imagex-auto-adjust-mode
Kaushal Modi 10:54 PM Emacs-imagex config link example of setting ditaa and plantuml
Correl Roush 10:58 PM writing specs link that has some setup steps listed out as well