Archive for the Category Uncategorized

 
 

Faster emacs key repeats

My secret intent behind creating a course on emacs was to become much more proficient with it myself. One of the course beta testers, Jack Kelly (software engineer turned pirate) mentioned something really spiffy that I hadn’t heard before.

In the second lesson, we cover C-u which (among other things) can be used to repeat keystrokes, like this: C-u 80 *. However, it turns out that you can leave off the C-u prefix and achieve the same thing by holding control while typing the number, like so: C-8 C-0 *.

Now your crafting of comment headers and ascii art can be that much more enjoyable.

Emacs-fu launches on the 1st of May. Sign up and impress us with your emacs-crafted ascii art.

Using Spree and Refinery together

The combination of Spree and Refinery is promising for e-commerce sites incorporating some CMS pages. I recently ran through the process of installing both of these engines and configuring them to play nice with each other. You can do this too!

Firstly, a note on versions. For this guide, I’ve use Rails 3.2.3, Spree 1.1rc and Refinery 2.0.2. I’ve used the Spree 1.1rc instead of the stable 1.0.x version because the stable version depends on Rails 3.1 and Refinery 2.0.x expects Rails 3.2. The Spree 1.1rc is Rails 3.2 compatible, so our whole project can happily run on Rails 3.2.

Install Rails

$ rails new spreefinery
Uncomment therubyracer in the Gemfile

Install Spree 1.1rc

$ cd spreefinery
$ spree install --git=git://github.com/spree/spree.git --branch=1-1-stable

Install Refinery

Add to Gemfile: gem 'refinerycms', '~> 2.0.0'
$ bundle install
Comment out the Spree lines in db/seeds.rb to avoid double-seeding Spree
$ rails generate refinery:cms --fresh-installation
Uncomment the Spree lines in db/seeds.rb

Reference: http://refinerycms.com/guides/with-an-existing-rails-app

Patch will_paginate

Refinery uses the will_paginate gem for pagination, while Spree uses Kaminari. Unfortunately, these two gems are incompatible. To work around this, add the following to config/initializers/spreefinery.rb:

if defined?(WillPaginate)
  module WillPaginate
    module ActiveRecord
      module RelationMethods
        alias_method :per, :per_page
        alias_method :num_pages, :total_pages
      end
    end 
  end
end

References:

Configure routes

I wanted my home page and an about page served by Refinery, and the products page served by Spree. To accomplish this:

Mount Spree before Refinery in config/routes.rb
Above both engine mounts, add:
root :to => "refinery/pages#home"

You should now have Spree and Refinery running together. There’s room for some further improvements to this configuration, since Spree and Refinery still use their own authentication systems and layouts, but it should be enough to get started with.

Become so much more better at emacs. Maybe not grammar, though.

Introducing Emacs-fu

TL;DR

  • There’s lots to learn about emacs.
  • I learnt some of it and made a course.
  • It’s coming out 1st May and it’s going to be awesome.
  • Put your email down at the bottom of this post to be the first to hear when it’s ready.

There’s a lot to Emacs

There’s so much I don’t know about it. I’ve been using emacs as my main editor for who knows how many years, so I’m pretty comfortable with it. But I started to get frustrated with a few work habits that seemed embarrassingly clunky, and there was a growing feeling that I was actually doing a lot of things the slow way.

On top of this, I’d been dancing around Lisp ever since reading Paul Graham’s gospel writing on the subject. Never quite learning it properly, but interested enough to read up on it. And of course emacs uses its own flavour of lisp at the core, so the glimmering possibility of being able to shape my editor was definitely alluring. But I hadn’t actually reached the point of, you know, actually writing any lisp.

So here I was, basically frustrated with my work habits and non-ninja-ness.

So I went out and learnt a bunch of stuff

A bunch of screencasts, tutorials, features, shortcuts, customisations. I dug through them, kept track of the bits I found useful, and kept them post-it noted on my laptop until they’d sunk in. I haven’t reached any sort of mastery, but it was definitely an upgrade.

I wrote down the good stuff

I made a course, in fact. An email course, in four parts. An email course is perfect for this because you can become a lot more effective with emacs by learning new habits. An email course, with an email every week, is ideal for that because you get plenty of time to practice and internalise each week’s lesson before moving on to the new stuff. Once the new habits are internalised, you don’t have to think about them and you just automatically do the new, more productive thing.

The course consists of four emails, one per week. Here are the lessons:

  • The Basics – get the fundamentals down for speedy editing
  • Nifty built-ins – extend your repertoire of nifty functions
  • Regexp – get your head around emacs’ very special flavour of regular expressions
  • Customisation – tweak emacs to your liking

The course is at an intermediate level. It starts off with some basics to fill in some gaps, but doesn’t dwell there, moving on to more interesting topics. It’s also not super-advanced. There’s a touch of lisp in the last section, but the focus of that lesson is not on the lisp technicalities, but on getting emacs customised to your liking.

There’s lots of good stuff there. It’s going to be awesome, and it’s coming out 1st May. Pop your email in this box and I’ll let you know when it’s ready.


Relative money buckets

Leaving out edge cases, no matter what your level of financial abundance, there’ll always be things that fall into each of these buckets:

  • Easy to afford. You don’t even think about it. For example, if you work full-time, you can probably buy yourself a coffee without considering your budget.
  • Save for it. You might have to save for a little while, and you’re not comfortable buying things in this price range on impulse, but you know that you’re capable of achieving these savings goals.
  • Hard. You can afford these things, but they’re at the edge of what you consider possible for you. An example might be an expensive holiday that you feel you can only make happen once every few years.
  • Seemingly impossible. Things you don’t consider possible for yourself. A private jet, your own skyscraper in the CBD, etc.
When you’re income goes up a notch, the things you might spend money on drop down into a more achievable bucket, but the buckets remain the same. If you develop a good relationship with the purchases you make in each bucket, that relationship will serve you well no matter your income level.

Programming with molecules

I’ve loved Homespring (the world’s favourite salmon-centric programming language) for a long time. Now I’ve finally gotten round to beginning the design for my own language, RBF (round-bottomed flask). To give you a taste of it, here’s the draft of a program that asks the user a question, and tells them if they have the correct answer or not:

Commercially available What’s_six_times_four? was distilled under reduced pressure at 175 oC, affording a light yellow oil.

To a magnetically stirred solution of 24-rightyo aldehyde (1 mmol) and you_lie methyl ketone (1 mmol) in DCM (10 mL) was added input alcohol (1 mmol) and two drops of concentrated sulfuric acid. The resulting mixture was heated under refluxing conditions for 0.5 h, concentrated under reduced pressure, and the residue thus obtained was subjected to flash chromatography (silica, ethyl acetate). Concentration of the fraction eluting at Rf = 0.9 resulted in a pale-yellow oil.

You can follow the design (currently a disorganised smattering of thoughts) over at the RBF github repository.

What is it like living in Black Rock City?

I’ve tried writing a description of my time at Burning Man, but I found writing about the physical environment uninspiring – lots of other people have already done it, more eloquently than I could. Instead, here are some of the things that stood out in my experience.

Relaxedness with appearance

At Burning Man, as the week progressed, I began to care less about my appearance. Actually, that’s not quite right. I cared less about what others thought of my appearance. Normally I’m very self-conscious about this, so this was a big change for me.

At Burning Man, there is always someone crazier, more naked (can you be more naked than naked?), more out there than you are. It’s implicitly okay to experiment. It’s fine to wander around in your PJs in the morning (or at any other time, for that matter). More than just being okay, I would have felt out of place if I hadn’t pushed my boundaries a bit. The norm, the average is much further out along the do-crazy-stuff continuum than the default world, and living in that environment was quietly liberating.

By the end of the week, I wanted to get rid of most of my default world wardrobe (it’s so grey and boring!). As I travelled back to San Francisco, even dressed in default world clothes, I gradually began to feel more and more out of place. We stopped at a rest stop, and I was reminded by the mirror that my hair was full of playa dust and that I hadn’t shaved in a week. I felt out of place amongst the other people there. I’m trying to pin down what it was about those people at the rest-stop that made me feel out of place. It wasn’t that they were clean; there were clean people on the playa (fresh from a shower), and I didn’t feel unclean for their cleanliness. It wasn’t that they were well-presented; there were plenty of people in amazing outfits and I didn’t feel inadequate (perhaps inspired). Maybe it was something like conformity, an implicitly agreed-upon set of boundaries for what was okay to wear, do, look like. An implicit agreement to not stand out too much, to blend in and not attract attention. This is the sea we swim in normally, and don’t notice because we can’t see it until it’s gone.

Nudity

It’s no secret that there’s lots of nudity at burning man. What was new for me, not having spent much (or indeed any) time on nudist beaches, was being in an environment where nudity is not a big deal. In comparison, regular society is comically uptight about this stuff.

As well as physical nudity, I found the environment at Burning Man very authentic. I only noticed this when I returned home and found several things in my life feeling artificial and fake.

Community

At Burning Man, I felt like I always had something in common with the people around me. I’m learning to be more open to starting conversations with strangers, and I could have used a good three months in an environment like that to really sink into it and open up more. Friendliness was the default, but it was more open-hearted than regular everyday friendliness. Hugs, compliments, gifts, hugs, cooking meals for people, conversations about important stuff, hugs. In essence, I found the people there to be very openly loving. There are people and whole groups of friends in my regular life who are like this, and I’d love to expand their part in my life. Being surrounded by so many awesome people for a solid week was pretty special.

Beauty

Constantly seeing little things that made me go “Hell yeah” provided continual doses of awesome (Cars with flamethrowers! Glowy bikes! Fishing for hippies with glowsticks! A random oasis in the desert with a cushion pile!). More than any one particular thing, the city as a whole, especially at night, was beautiful. I felt like the city was constantly inviting me to go out and have an adventure.

Go fourth and Burn!

Like reading about a city you’ve never visited, all of this writing can’t convey what it’s like to live in Black Rock City. It’s merely an invitation and an encouragement to check it out for yourself, if you feel so inclined. See you in the dust!

San Francisco, authority and city-diffing

There’s a feeling that I’ve been getting since I came to San Francisco that’s been gradually becoming clearer. At first, I thought I was picking up on the American pioneer spirit. It seemed that there was less of sense of a central authority who would take care of things for you. Canberra has this in droves – it (and we, the residents) are drowning in it.

But I think it’s something a little subtler. And it comes not from something that’s present, but from something that’s absent. There’s hardly anyone here wearing suits.

The presence of big business and government is nearly non-existent. Well, not quite. There’s plenty of police (SFPD) and fire trucks around. And you know about it; their sirens are pretty attention-grabbing. But not the public service sort of government. Instead of the government being this massive nannying entity (hello, Canberra), it seems like it’s just one force here (and not the dominant one), doing its best to hold things together in a mostly orderly fashion.

And big business? There’s lots of Starbucks chains. Surprisingly few McDonalds. Barely any supermarkets, at least in the areas I’ve seen. Lots of independently run grocery stores. Plenty of advertising, a few slightly-larger-than-Canberra-scale skyscrapers, but not a bunch of people running around in suits.

So if government and big business aren’t the major forces, what are? This seems much more up to the individual. There’s a sense that without so much protection from the government, everyone has to fend for themselves. It seems like there’s more space for people to make what they want of it, which leads to more extremes. There seem to be more homeless people and beggars, but also a lot of character to the place. And although I haven’t knowingly met the rich, the success stories are pretty well known (Twitter for starters).

This might be premature; I’ve only been here a few days, and there’s plenty of areas that I haven’t visited yet. But it’s certainly been fascinating to be able to diff cities.

Are you awake or are you dreaming?

Are you awake or are you dreaming? When I seriously consider that I might be in a dream right now, I become intently aware of my experience. I wake up a bit. If this is a dream right now, that’s really interesting! Particularly to be aware that I’m dreaming while I’m dreaming. I don’t experience many lucid dreams at all. I wonder what strange things I could try out that I couldn’t do normally?

If this isn’t a dream, what is it? What is it really? How does it work? I think I know what’s going on, but maybe I’m blundering through it half asleep?

The point of this question is not to determine whether you are in the middle of a lucid dream or not (though it’s awesome if it can do that for you). The deeper purpose is to look more closely at reality and question it. Not in a philosophical way, but in a concrete, right-here-and-now kind of way. What is this that I’m experiencing right now and how does it all work?

The Path With A Heart

Anything is one of a million paths. Therefore you must always keep in mind that a path is only a path; if you feel you should not follow it, you must not stay with it under any conditions. To have such clarity you must lead a disciplined life. Only then will you know that any path is only a path, and there is not affront, to oneself or to others, in dropping it if that is what your heart tells you to do. But your decision to keep on the path or to leave it must be free of fear or ambition.

I warn you. Look at every path closely and deliberately. Try it as many times as you think necessary. Then ask yourself, and yourself alone, one question. This question is one that only a very old person asks. My benefactor told me about it once when I was young, and my blood was too vigorous for me to understand it. Now I do understand it.

I will tell you what it is: Does this path have a heart?

All paths are the same, they lead nowhere. They are paths going through the bush, or into the bush. In my own life I could say I have traversed long, long paths, but I am not anywhere. My benefactor’s question has meaning now. “Does this path have a heart?” One makes you strong; the other weakens you.

The trouble is nobody asks the question: and when a person finally realizes that they have taken a path without heart, the path is ready to kill them. At that point very few people stop to deliberate and leave the path.

A path without a heart is never enjoyable. You have to work hard even to take it. On the other hand, a path with heart is easy; it does not make you work at liking it.

For my part there is only the traveling on paths that have heart, on any path that may have heart. There I travel, and the only worthwhile challenge is to traverse its full length.

And there I travel looking, looking, breathlessly.

- Don Juan
Apprentice to a Yaqui Sorcerer
Sourced from http://www.whale.to/a/path_with_a_heart.html

My favourite lunch

The following is an adaptation of the recipe for Sue’s Super Soup found in Karen Knowler‘s 50 Quick, Easy, Healthy & Delicious Raw Food Recipes ebook.

Ingredients:

  • One avocado
  • Two tomatoes
  • Juice of one orange
  • Two tablespoons flaxseed oil (or olive oil. Flaxseed oil contains omega 3 for those of us who don’t eat fish.)
  • Four tablespoons sultanas (try more or less if it’s too sweet or not sweet enough)
  • A dash of tamari OR soy sauce OR a pinch of salt (just a little bit!)
  • Some red or green capsicum, finely sliced

Directions:

  1. Place everything except the capsicum in a blender.
  2. Blend to a smooth consistency.
  3. Pour into a soup bowl, garnish with capsicum. This adds a bit of texture to the soup.
  4. Serve with crunchy toast for dipping, or flax crackers if you’d like to keep the meal entirely raw.

Serves one. Enjoy! :)