On this page:

Publishing WordPress thumbnail images using Emacs and Org2Blog

I often include large images in my blog posts since I use sketches as another way to think out loud. I’d gotten used to using the WordPress web interface to drag and drop them into the relevant section of the page. I write most text in Emacs/Org Mode/Org2Blog because of the better outlining and writing tools, and then I used sacha/org-copy-region-as-html (which you can grab from my Emacs configuration) to copy the HTML markup and paste it into WordPress. Of course, I use Emacs for source-code heavy posts that make the most of its syntax formatting support.

Someone asked me recently about how to post and update blog posts with images through Org2blog, and if I had any recommendations for workflow. I’d dropped Windows Live Writer since it was flaking out on me and the WordPress web interface had improved a lot, but before recommending just using WordPress to add images, I was curious about whether I could improve my blogging workflow by digging into Org Mode and Org2Blog further.

It turns out (like it usually does in the Emacs world) that someone had already solved the problem, and I just didn’t have the updated version. Although the upstream version of Org2Blog didn’t yet have the thumbnail code, searching for “org2blog wordpress thumbnail” led me to cpbotha’s Github issue and pull request. Punchagan’s version had some changes that were a little bit ahead of cpbotha’s, so I dusted off my ancient org2blog repository, cloned it onto my computer, and issued the following commands:

git remote add upstream https://github.com/punchagan/org2blog
git pull upstream master
git remote add cpbotha https://github.com/cpbotha/org2blog.git
git pull cpbotha image-thumbnail

and tested it out on a blog post I’d already drafted in Org. It took me a little while to remember that the file URLs didn’t like ~, so I specified a relative path to the image instead. But then it all worked, yay! A quick git push later, and my Github repository was up to date again.

So now I’m back to running a Git version of org2blog instead of the one that I had installed using the built-in packaging system. The way I make it work is that I have this near the beginning of my Emacs configuration:

;; This sets up the load path so that we can override it
(package-initialize nil)
;; Override the packages with the git version of Org and other packages
(add-to-list 'load-path "~/elisp/org-mode/lisp")
(add-to-list 'load-path "~/elisp/org-mode/contrib/lisp")
(add-to-list 'load-path "~/code/org2blog")
(add-to-list 'load-path "~/Dropbox/2014/presentations/org-reveal")
;; Load the rest of the packages
(package-initialize t)
(setq package-enable-at-startup nil)

This allows me to mostly use the packages and to satisfy dependencies, but override some of the load paths as needed.

Hope that helps someone else!

Planning for winter – tweaking my layers

It’s getting cooler here in Toronto, with possible snow showers and scattered flurries this weekend. Time to think about how I can make this winter even better!

The Scott Quest Vest is working out really well, allowing me to leave my belt bag behind. I haven’t quite gotten the hang of all the pockets, but I can generally find the most frequent things I use. One of the earphone loops has worked loose and gotten frayed by nearby Velcro, though. I’ll check with the manufacturer, since I haven’t figured out how to securely hand-sew elastic loops like that.

I’ve started wearing my thermals again. With that, the vest, and maybe a sweater, I’m pretty okay with the 5-10C temperatures these days. A rain jacket is handy, too. A hoodie and maybe gloves will take me down to 3C or so.

Here are some notes I put together while thinking about what kind of coat I wanted to get this year:

I ended up deciding on a waterproof jacket with an interchangable lining that’s compatible with a down jacket. I’m still keeping an eye out for a large, warm hat, but I can probably get by with a nice warm scarf and my winter hats. It turns out that I’m somewhat picky about hats, so I haven’t quite found the one I like the most yet.

The new office my clients have moved to is directly connected to the PATH, so my winter exposure during consulting days will just be the 10-20 minute walk to the subway station. I plan to be at Hacklab more often, though, so that will still involve a bit of waiting. The new Hacklab has nicely vivid accent colours, so I’ll probably head over there if I feel colour-deprived.

I probably need to get new winter boots. I noticed last year that my insulated boots were no longer waterproof. The shoe stores don’t seem to have brought in their winter boot selections yet, but I’ll check again in a few months. I tried looking for winter boots at end-of-season sales earlier this year, but since I have small feet and a preference for simple styles, the sizes tend to be sold out quickly. I had the same problem with coats, too, which is why I decided to get a new coat early in the season instead of waiting to see what the rest of the options were.

Compared to last year, I’m even more comfortable with cooking and baking, and I’m looking forward to keeping the house warm and the fridge full.

Bring it on!

Emacs hangout notes

Prompted by Michael Fogleman’s tweet that he’d like to see a bunch of us Emacs geeks get together in one room for a hackathon, Nic Ferrier and I tried out a casual Emacs hangout. Tinychat didn’t work, but Google Hangouts worked fine. A bunch of people saw our tweets about it too and dropped by, yay! Here are some things we talked about (mostly nifty tweaks from Nic):

  • shadchen is great for pattern matching, especially within trees
  • Alec wanted to know about Emacs and Git, so Nic demonstrated basic Magit
  • after-init-hook – load things there instead of in your ~/.emacs.d/init.el, so that your init.el does not break and you can test things easily from within Emacs
  • I shared isearch-describe-bindings, which had a number of goodies that I hadn’t known about before
  • Recognizing the opportunity to share what you’re working on (ex: nicferrier’s working on an Emacs Lisp to Javascript compiler)

Google Hangouts screensharing worked well for us, giving multiple people the opportunity to share their screen and allowing people to choose what they wanted to focus on. Nic also started up a tmux session and a repository of public keys, but that’s a bit more involved and requires more trust/coordination, so screen-sharing will likely be the way to go unless people have more of a pairing thing set up. This kind of informal hangout might be a good way for people to share what they’re working on just in case other people want to drop by and help out or ask questions (which people can optionally answer, or postpone if they want to stay focused on their work). Something a little more focused than this might be to pick one bug or task and work on it together, maybe starting with a “ridealong” (one person screenshares, thinking out loud as he or she works, and taking the occasional question) and moving towards full pairing (people working on things together). Some of my short-term Emacs goals are:

  • Improve my web development workflow and environment (including getting the hang of Magit, Smart Parens, Skewer, AutoComplete / Company Mode, and other good things)
  • Learn how to write proper tests for Emacs-related things
  • Get back into contributing to the Emacs community, perhaps starting to work on code/tests
  • Look up my Org agenda on my phone, probably with Org Mobile or some kind of batch process

Let’s give this a try. =) I set up a public calendar and added an event on Nov 5, 9-11PM Toronto time. If folks want to drop by, we’ll see how that works out!

Hacklab Cooking: Thai curry from scratch, and coconut tapioca pudding too

It feels a little odd to post two cooking-related entries in a row, but I wanted to take notes on this (and share it with y’all!). =) Yesterday at Hacklab, Eric, Abtin, and I made Thai curry from scratch, and I made coconut tapioca pudding too. We (mostly) followed this recipe for the Thai curry, tripling the proportions:

Paste (we prepared this in a blender instead of a food processor, and we thinned it with a little coconut milk to make it blendable)

  • 3 Thai chilies
  • 1 stalk lemongrass
  • 3 shallots
  • 1/2 red pepper, deseeded
  • zest of 1 lime
  • stalks from a third of a bunch of coriander
  • thumb-size piece of ginger – we didn’t grate this, we just blended it
  • 2 garlic cloves
  • 1 tsp freshly ground pepper
  • 1 tsp ground coriander

Curry

  • Tofu, marinated in soy sauce, chopped chili, and the juice of 1 lime
  • 400ml coconut milk
  • eggplant
  • zucchini
  • green beans
  • mushrooms
  • half a red pepper, deseeded
  • 1 tsp brown sugar
  • basil

Coconut tapioca pudding

  • Tapioca
  • Coconut milk
  • Sugar
  • Maple syrup

The Fresh.co near Hacklab didn’t carry the kind of tapioca I wanted for the coconut tapioca pudding, so I made do with the minute tapioca that they sell in the instant snacks area (along with Jello and custard powder). I couldn’t figure out how to translate either the coconut tapioca recipe (which specifically tells you to avoid minute tapioca) or the instructions on the back of the tapioca package, so I made something up instead. I used the entire package of minute tapioca, added the remainder of the carton of coconut milk, whisked it to dissolve the tapioca, and cooked it over medium heat (constantly stirring) until the tapioca was no longer crunchy. I added sugar to taste, and I followed the original recipe’s suggestion to top it with maple syrup (… which happened to be the maple syrup that had boiled over during last week’s icing experiment). You’re supposed to let it cool down, but it was yummy while warm anyway. =)

So, more experience points earned and achievements unlocked!

  • First time to make Thai curry from scratch instead of using the canned curry paste
  • First time to cook something with lemongrass
  • First time to make tapioca pudding
  • First time to make up dessert as I went along
  • … First time I’d gone through that much coconut milk

Also, Monday, I made chicken pot pie with a biscuit crust. Technically, I made most of it on Sunday, and then I made a quick biscuit crust after we came back from the polling station (I voted in Canada for the first time, yay!). It was wonderfully chicken-y, not at all like the frozen pot pies you can get at the supermarket. Mmm.

I really like this cooking thing. It’s fun to be able to turn simple ingredients into good tastes, decent food, and shared experiences, even though there’s a lot of figuring things out and adjusting and occasionally making the wrong decisions. =) So far, things have been working out really well.

Cupcake challenge: accepted!

CameraZOOM-20141024194729408

For the Hacklab grand re-opening party, I made 58 vegan chocolate cupcakes using about four batches of this Basic Vegan Chocolate Cupcake. Each batch called for:

  • 1 cup soy milk
  • 1 tsp apple cider vinegar
  • 3/4 cup sugar
  • 1/3 cup canola oil
  • 1.5 tsp vanilla extract
  • 1 cup all-purpose flour
  • 1/3 cup cocoa powder
  • 3/4 tsp baking soda
  • 1/2 tsp baking powder
  • 1/4 tsp salt

mixed and baked in a 350F oven for 18-20 minutes (20 minutes at Hacklab). Once cooled, we decorated them with this Vegan Fluffy Buttercream Frosting, which called for:

  • 1/2 cup vegetable shortening
  • 1/2 cup vegan margarine
  • 3.5 cups icing sugar
  • 1 tsp vanilla extract
  • 1/4 cup soy milk

Fortunately, Eric had donated an electric mixer (hand), so whipping up the frosting was easy. The cupcakes were not too sweet, so the frosting was a nice balance.

I also made 12 non-chocolate, non-vegan, gluten-free cupcakes from a boxed mix, since some Hacklab members have those dietary restrictions. Eric iced those with a different recipe.

It was actually pretty fun making dozens of cupcakes. Because they’re in liners, it’s easy to make large batches of them and set them cooling on whatever surfaces are handy. I started at 4ish and spent the whole afternoon cooking. I also had fun using the simple cake decoration kit to pipe letters and icing on it, although my hands were a smidge shaky. I actually forgot to add the soy milk and extract the first time around, but I caught it after icing the first ten cupcakes with something that was mostly sugar. After I beat in the soy milk, icing was a lot easier.

We don’t really make a lot of desserts at home because we’d like to eat more healthily, but since J-‘s friends are often over, maybe I should look into making more snacks to keep around the house. Probably not chocolate cupcakes – maybe something healthier? – but it’s definitely baking season, so some kind of baked good. Then again, W- reminds me that a box of cookies on sale is pretty cheap, so we might as well use the time for other things.

I don’t quite remember making cupcakes before the party. Maybe I’ve made cupcakes before, but just forgot about it? Anyway, they’re not intimidating after all. =) And with vegan recipes, I can taste the batter a little to see if I’m on the right track!

Upgrading from Rails 3 to Rails 4; thank goodness for Emacs and rspec

I spent some time working on upgrading Quantified Awesome from Rails 3 to Rails 4. I was so glad that I had invested the time into writing enough RSpec and Cucumber tests to cover all the code, since that flushed out a lot of the differences between versions: deprecated methods, strong parameters, and so on.

rspec-mode was really helpful while testing upgrade-related changes. I quickly got into the habit of using C-c , m (rspec-verify-matching) to run the spec file related to the current file. If I needed to test specific things, I headed over to the spec file and used C-c , s (rspec-verify-single). Because RSpec had also changed a little bit, I needed to change the way rspec-verify-single worked.

(defun sacha/rspec-verify-single ()
  "Runs the specified example at the point of the current buffer."
  (interactive)
  (rspec-run-single-file
   (concat
     (rspec-spec-file-for (buffer-file-name))
     ":"
     (save-restriction
               (widen)
               (number-to-string (line-number-at-pos))))
   (rspec-core-options)))

(sacha/package-install 'rspec-mode)
(use-package rspec-mode
  :config
  (progn
    (setq rspec-command-options "--fail-fast --color")
    (fset 'rspec-verify-single 'sacha/rspec-verify-single)))

C-c , c (rspec-verify-continue) was also a handy function, especially with an .rspec containing the --color --fail-fast options. rspec-verify-continue starts from the current test and runs other tests following it, so you don’t have to re-run the tests that worked until you’re ready for everything.

I should probably get back to setting up Guard so that the tests are automatically re-run whenever I save files, but this is a good start. Also, yay, I’m back to all the tests working!

Test coverage didn’t mean I could avoid all the problems, though. I hadn’t properly frozen the versions in my Gemfile or checked the asset pipeline. When I deployed to my webserver, I ran into problems with incompatible changes between Rails 4.0 and 4.1, and Bootstrap 2 and Bootstrap 3. Whoops! Now I’m trying to figure out how to get formtastic-bootstrap to play nicely with Bootstrap 3 and Rails 4 and the latest Formtastic… There are some git repositories that claim to do this correctly, but they don’t seem to work.

Grr.

Fine, I’ll switch to simple_form, since that seems to be sort of okay with Bootstrap 3. I ended up using this simple_form_bootstrap3 initializer along with

# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
config.collection_wrapper_tag = :div

# You can define the class to use on all collection wrappers. Defaulting to none.
config.collection_wrapper_class = 'collection'

and this in my style.css.sass:

.form-horizontal
  .control-group
    @extend .form-group
  .control-label
    @extend .col-sm-2
  .control-group > .form-control, .form-group > .form-control, .form-group > .collection
    @extend .col-sm-10
  .help-block
    @extend .col-sm-offset-2
  .control-label.boolean
    text-align: left
    font-weight: normal
    @extend .col-sm-offset-2
  label.radio
    font-weight: normal

which is totally a hack, but it sort-of-semi-works for now.

More changes to come, since I’ve got to get it sorted out for Rails 4.1 too! Mrph.