July 2008

Enough time: a new hire’s reflections

July 1, 2008 - Categories: career, life

After one of the new hires read my blog, she asked me, "How do you find the time to do what you do?" This was after I’d sent her a couple of useful links, so I didn’t think she meant it in the "You have too much time on your hands" kind of way. I said that I saved lots of time and and I use that time to get good enough at what I do so that people want me to do what I want to do. After reflecting on the question, though, I realized that my answer is at least half-wrong.

It’s not about time management or productivity.

I probably work less than most new hires do. I don’t work long hours because my evenings and weekends are full of wonderful things to do. (Okay, I do some work in the evenings and on the weekends, but that’s because it’s fun.) I’ve also kept a careful rein on the urge to immerse myself in work because I’ve heard that it can take over one’s life. This is not to say that people who live for work have made the wrong choice (we owe so much to people like them!), but I like the balance I have.

I don’t think I work significantly smarter than other people do. This is not about tips for handling e-mail faster or to make better use of your downtime. I’ve read a good number of productivity books and blogs, and I’ve incorporated many of their suggestions into my habits, but that’s really more to minimize frustration than to trim every last minute and streamline my daily routines. Besides, all these things are things other people can do. Whenever I come across something that saves me time, I try to teach it to other people–lifting as I climb. I’m not looking for a competitive advantage. I want to make the path even easier for other people than it was for me.

Besides, it’s difficult to compare productivity anyway. Let’s take my current project. I can read and figure out PHP code quickly, but it takes me forever to do cascading style sheet designs for websites. Am I faster or slower than my teammate? I don’t think it matters. My manager and my team members are happy with my work. I fulfill my end of the deal, and I help other people work more productively as well. I’m happy with my work and how I spend my time, and that’s probably the best result.

So if it’s not about longer hours or greater productivity, what’s the deal, then?

These three things are true about time: you will always have the same amount of time in one day as other people do, there will never be enough time to do everything, and there’s plenty of time to do the things that matter. The first point is the answer to "Where do you find the time to do this?" The second point is what stresses lots of people out. The third point is what makes all of that easier to deal with. It’s like the difference between a half-empty glass and a half-full glass. If you’re stressed out because you feel you don’t have enough time, you’ll feel even worse and you’ll use up more energy when you’re doing things. If you’re happy that you have the time to do a number of valuable things and maybe even a little more, you’ll feel better and you’ll bring that energy to your work and your life. So much of happiness is in how you see things.

What matters? For me, my formal responsibilities matter. My team relies on me to do certain kinds of work. I can see the value in what I’m doing, and I know that if I do a good job at what I do, I help other people create even more value doing the work they do. So yes, my work matters.

But my formal responsibilities aren’t everything. Even when it comes to work, I feel that it’s important for me not to run totally flat out. Some people relish that kind of challenge. Me, I can probably pull it off as a sprint, but not a marathon. I’m not the kind of person you want working 80-hour weeks, schedule packed to the brim. I need gaps of unstructured, potentially "unproductive" time.

Where does that "unproductive" time go? I use that time to reflect, to learn, to reach out, and to share what I’m learning.

I regularly reflect on what I’ve been doing, how I’ve been doing it, how I can do it better, and where I want to go. This helps me practice relentless improvement. Reflection is such an important part of the way I work and live that when I don’t give myself the time to step back, I feel raw, stretched, frayed. I need that quiet time. I need that space to learn, and I need that space to share.

When I learn, I divide my time between focused skill-building (like the way I’d burn through twenty books on a single topic or focus on a particular programming platform), general scanning (a feed reader makes it easy to stay up to date), and random-walking in search of serendipitous connections. All three types of learning have given me incredible value, not only for myself but also for other people. Focused skill-building gives me the deep knowledge I can use at work and I can share with others. General scanning lets me fish out just the right example from my memory when we’re throwing ideas around at a meeting. Random-walking helps me draw connections between different areas.

Reaching out to people lets me find opportunities to learn more and to be of even more help. I’m a little shy about inviting people out for a walk or interrupting their concentration with an instant message, but I feel comfortable commenting on blog entries or e-mailing people about something we’ve talked about. My blog also helps me reach out. People come across it for all sorts of different reasons, such as a search result, an e-mail signature, or a casual conversation. If they find it useful, they sometimes write to say hi or to ask a question. So even if I’m shy or busy working on something else, my blog is always out there, reaching out to people for me.

My blog is also the primary place where I share what I’m learning. Teaching something helps you learn it more effectively, and you can create lots of value by doing so. I spent at least two days struggling with multi-step form validation in Drupal, and I happily spent fifteen minutes writing about it in the hopes of saving other people time. I try to do the same with the other things I learn. Teaching what I’m learning is a natural fit with my reflections. It helps me learn more effectively. It’s a terrific way to reach out. I also give presentations, answer questions through e-mail, coach people over the phone, and talk to people. A lot of that material starts out as a blog post, though, as I try to figure out what I want to say and how to say it.

Teaching–whether it’s an informal blog post or a dressed-up presentation–is a fantastic way to keep getting extra value from the time you’ve already spent learning something. It’s like what I tell myself when I make a mistake or when I spend a long time trying to figure something out: "You’ve already paid the tuition. Now collect the paycheck." If you’re the one in that situation, you know that the time you spent is gone. You won’t be able to get it back. What you can do, however, is not only to learn the lesson, but to get even more value out of it by sharing it with others. It’s like passive income, except it’s about creating additional value over and over again. A little investment of time now can save lots of people time in the future, and that has a way of working out for you too.

So that’s the long answer to "How do you find the time to do the things you do?" I do this stuff because it matters to me. It looks like it matters to other people too, so maybe I’m on to something here. I hope it works for you too!

Awesome, I’ve been quoted in Portuguese!

July 2, 2008 - Categories: enterprise2.0

Todas as faces da colaboração?

O poder do indivíduo já era. Experiências com colaboração e ferramentas sociais em grandes companhias, como a IBM, dão conta de mostrar o valor do trabalho desenvolvido em rede e global

Que tal conseguir o emprego dos sonhos compartilhando suas idéias em um blog? Foi assim que Sacha Chua, atual evangelizadora de Empresa 2.0 da IBM, conquistou o posto que ocupa hoje dentro da companhia, em Toronto, Canadá. Aos 23 anos, tão logo a jovem estudante passou a circular pela empresa por conta do projeto de conclusão de sua tese de mestrado em computacão social, em 2006, não hesitou em disparar posts sobre a própria pesquisa pela ferramenta interna de blogs que a IBM disponibilizava aos funcionários.

“Percebi que se não fizesse isso, no final de mestrado poucas pessoas leriam minha tese. Escrever sobre a pesquisa enquanto ela era feita permitiu que eu compartilhasse meu conhecimento com outras pessoas e aprendesse com as sugestôes e conselhos que me davam”, conta.

Foi como se a partir daquele momento tivesse calçado os sapatinhos de cristal de uma Cinderela moderna que ascendia para o universo corporativo. Do dia para a noite, o blog da então ilustre desconhecida caiu no gosto dos funcionários e se tournou o mais popular da empresa não só no Canadá–com média de 300 a 600 acessos diários–tudo sem sair da esfera interna da IBM. “Queria fazer mais do que escrever software, queria ajudar as pessoas a se conectarem por blogs, wikis e outras ferramentas web 2.0 e a IBM era a empresa perfeita para aplicar tudo que aprendi a respeito no mundo real. Quando chegou a hora de pedir o emprego, o processo foi fácil porque os futuros colegas de equipe já me conheciam e sabiam o suficiente para convencer a gerência a criar um cargo só para mim”, lembra.

A história de Sacha poderia ser uma exceção, mas não é. Essa é apenas uma das faces das oportunidades que as ferramentas sociais e de colaboração apresentam dentro de companhias. Por isso, a IBM vem apostando na criação de ambientes férteis para a inovação.

Except for my age, most of it’s right. Nifty! There’s more, but it would take me a while to type it all in from the scan. I wonder if I can get a copy of the magazine for my mom… =)

Pereira, Paula. June 2008. “Todas as faces da colaboração?”, B2B Magazine

Taking book notes

July 3, 2008 - Categories: book, productivity, reading

It turned out that our newest team member, Tom Plaskon, is also a bookworm. Over lunch last Wednesday, we chatted about how we keep track of what we’re learning from books. My system hasn’t changed that much sinceI described it in February, but I thought I’d post an updated blog post about it, just in case writing about it prompts ideas.

How I get books:

I still read lots of books. I usually order books from the Toronto Public Library system or pull them off the library shelves when I go on a library run, but sometimes I’ll pick up books from the bookstore or order them online. I occasionally get book recommendations from other people, too.

I tend to read in sprints, focusing on a single subject. I’m currently revisiting personal finance, and I’ve read about comics and graphic novels, sketching, storytelling, writing, leadership, time management, Javascript, CSS, relationships, communication, management, consulting, entrepreneurship, photography, cooking, presentation skills, education, reading, economics, parenting (yes, I read my mom’s parenting books when she was raising me – made for an interesting childhood!), social networking, quarter-life crises, career planning, learning, creativity, self-defense, exercise, romances (particularly classic Regency ones) gardening, and other topics that slip my mind at the moment. Reading in sprints allows me to get through books quickly (few non-fiction books are packed with new ideas) and see the interconnections between ideas in books. Sometimes I’ll go for variety when I’m raiding the library shelves.

This is a pattern of reading that practically requires a well-stocked public library, as there’s no way I’m going to spend all that money doing a reading sprint by buying books from Chapters or Amazon. I’d be limited by my book budget and I’d end up with too many books full of too much filler. Using the public library allows me to get value from books I might not ordinarily buy and books that are mostly fluff except for one or two good insights. (Or books that have one good idea and just keep hammering it in.)

How I read books

While I’ll slow down and enjoy a dense, well-written book, most books are worth cursory scans. Sometimes I’ll look at the table of contents to get the lay of the land. Other times, I’ll just plunge right into it, skimming the book for good quotes, interesting insights, or good explanations.

I read books on the subway, over breakfast or dinner, while walking (except across intersections), on evenings and weekends, and whenever I can steal a moment. I try to always have a book or two in my bag.

How I take notes

The first step is to mark the passages I want to keep. I don’t like writing in books (and absolutely abhor the idea of writing in a library book!), so I have to keep track of the passages I want to put into my book notes system. I must confess that I’ve resorted to dogearing pages. Post-It flags feel wasteful and torn slips of paper are inconvenient. I’d be happy to switch to a better method for remembering pages if it was something I could do while walking around (rules out scanning text with a digitizing pen) and it allowed me to keep track of any number of pages (rules out bookmarks, unless I carry a whole stack of them).

After I’ve gone through a book once, it’s time to put the passages into my book notes system. If I have time, I use Dragon NaturallySpeaking to dictate the book details, page numbers, and relevant passages to my computer. It’s fun, it reinforces my memory, and it helps me train the speech recognition engine. If I’m pressed for time, I scan the relevant pages, then and use Tesseract Optical Character Recognition to convert the scans into text.

I currently keep my book notes in a large text file with a little markup to make it easier for Emacs to display it as an outline. (Hooray org-mode!) Each book is an outline item, and each quotation starts with the page number. I also add my own notes.

How I review my books

The human brain is good at associative memory. When a conversation topic reminds me of something I’d read, I can usually come up with a few titles or keywords from the quotations. My book notes allow me to send not only the book details but also the relevant quote, which helps other non-bookwormish people zero in on the part they might want to check out. So far, my text file has been working well.

I occasionally review my book notes by flipping through my book notes on the computer or on my Nintendo DS, jumping to a random note, or searching for certain keywords. I also reread particularly good books to see if I’ll get even more insight this time around. This helps me keep the content fresh, and it also prompts me to think about who I know would benefit from the book I’m reviewing.

How I can make this system better

I think I’ll start using LibraryThing to keep track of the books I’ve read. This allows me to take advantage of social recommendations. I used to use Amazon for that, but it’s also nice to run into fellow bookworms with similar interests and to see what else they’re reading.

It might be good to capture diagrams neatly. I’ve got the scanner, so I just need to work out a good image storage thing.

I want to be able to link related quotations and books with each other. Blog posts would be a good way to do that. I just need to make sure I save my post locally, too.

I need to think about which new books are worth acquiring. =) There are a few presentation-related books I’m going to order (Back of the Napkin, Presentation Zen, Slideology).

Weekly report, week ending July 4, 2008

July 4, 2008 - Categories: weekly

As promised, weekly report on Friday instead of Sunday! Let’s see how well that works.

This week:

Next week:

Sowing seeds: What is technology evangelism, anyway?

July 4, 2008 - Categories: enterprise2.0

Today, I want to talk about grassroots adoption, when you’re trying to influence people around you to try out something new–a new tool, a new idea, a new way of working–without dictating to people. I hope that I can help you get a better sense of where other people are, what might be stopping them from moving forward, where you are, and how you can get better at helping other people learn.

I’m interested in this because as a technology evangelist, I’ve talked to a lot of people about social tools like blogging and wikis. Over the next few blog entries, I want to share some of the objections that I’ve come across. I also want to share some of the methods I’ve tried and observed.

But first, let’s talk about what technology evangelism is. You might be wondering why I use the term “evangelism”, considering its religious roots and sometimes negative connotations.

For me, evangelism has that hint of being more than just a dry list of facts. You want to inspire people to action, and you want to do this in a way that sticks even when you’re not around.

The technology you want to promote is not going to be a perfect fit for everyone or every time. Technology evangelism is not about convincing people that your way is the right way. It’s about showing people what their options are, helping them find something that fits them, and helping them learn how to make it part of their work or their lives. (I forget this sometimes, too.)

So if a technology isn’t going to be a perfect fit for everyone immediately, how can you encourage grassroots adoption?

One way is to scatter the seeds as widely as possible. If you reach out, you might find a lot of people who can benefit from the technology you want to promote. Help them, and their success stories and influence will help you reach out to even more people.

You might not have that option. You might have been asked to help a team get up to speed on a tool. You might want to explore a collaborative tool, but before you can take advantage of that tool, you’ll need to get other people on board too. (After all, you can’t collaborate on your own.)

This is where it can get frustrating.

Next post on Monday (or earlier =) ): Sowing seeds: Five common objections

What do I want to learn?

July 6, 2008 - Categories: learning, life

Inspired by Michele Martin’s post on personal learning environments, I started working on a mindmap and a blog post about how I learn. Before I got far into it, though, I realized that I wanted to first share what I want to learn – the why, not just the how.

So here are a few things that I want to learn more about, why I want to learn more about them, and how I’m currently learning about them. I’d appreciate your suggestions, and I’d love to hear about what you’re learning!

Telling stories with words and images

A good story can make a point so much more effectively than charts or data can. I love listening to stories and showing people that they’ve learned something other people will find useful. I love collecting stories so that I can pick an appropriate story later. I love telling stories in my presentations, blog posts, and conversations, and I want to get better at it.

I want to get better at finding and telling stories because I believe it’s a remarkably effective way to understand people’s experiences and to communicate.

I practice telling stories with words and images by writing blog posts
and by including stories in my presentations. So far, I’m doing well,
but there’s still so much more I can learn. When I grow up, I want to
be Dan Pink. ;)

I want to get better at listening for hints of a story and bringing it out. I think I’ve read as much as I could about this, so it’s really just a matter of getting out there and talking to people.

I want to improve my visual literacy. I often have a hard time thinking of a good image that can illustrate an abstract idea, and an even harder time finding an image that fits. I’ve used Creative Commons-licensed pictures from Flickr and stock photography from low-cost photo sites, and I’ve seen how they can make presentations much richer. I want to develop my ability to think of illustrations and either sketch them myself or find good stock photos. In order to improve that, I:

I think I just need to expose myself to a whole lot of images so that I can start making associations in my brain. =)

Helping new hires connect with the rest of the organization (and vice versa) through Web 2.0

Yes, that’s pretty specific. =) I’m also curious about how individual employees can use social media to grow their networks and provide more value, how communities can use social media to support their activities, and how companies can incorporate social technologies into their strategies, but I’m particularly passionate about helping new hires connect. I think it’ll not only make a big difference in employee retention and satisfaction, it’ll also help companies get more value from what new hires know and what new hires are learning.

I want to get better at communicating the benefits and needed actions to experienced people. To practice this, I’ve joined a community that helps colleagues learn about Web 2.0 and use our internal tools effectively.

I want to improve my ability to show new hires the benefits and help them get started.
I’m working on some materials for new hires, and I’ve gotten involved with our local new hire network.

Experience will help me learn a lot, and I’ll also get to provide a lot of value along the way. =)

Sharing what I’m learning

I want to get better at figuring things out and sharing what I’ve learned. I’m practicing this by blogging and by talking to people. I can improve this in several ways:

I want to get better at mapping what I know. If you know what I know, then you can make better use of it. I’ve got too many blog posts for someone to go and read all of them, but a good map of that – and a map of things I’ve learned but haven’t written about yet – can help you find things you might find interesting.

Helping people change

The thing I enjoy about technology evangelism isn’t convincing people to change, it’s helping people who already want to change. I want to get better at helping people understand their options, figure out how to get started, and learn how to be more effective. I’m practicing by helping people at work and on my blog, and I’m learning more by talking to other people who have a similar urge to help others learn and grow.

Nurturing relationships over a distance

I’m here in Canada because my significant other is here and he can’t move to the Philippines with me. My family and my old friends are half a world away. Being split between worlds is the biggest source of pain in my life. It’s hard to stay in touch when you don’t get to share as many experiences. It’s hard to deal with expectations – both mine and other people’s. It hurts because I don’t want to go for either extreme. I don’t want to give up on this wonderful relationship and focus instead on my duty to my family and my country. I don’t want to focus only on this relationship and forget my roots.

I need to connect with other young first-generation folks. How do other people manage it?

I’d also like to nurture my old friendships, because I’d gotten to know some really incredible people over there. Some friends are easier to keep in touch with than others–they blog, they chat… Through them, I get to hear about other friends, too. I still need to think about how I can do this better.

I also want to learn how to nurture connections with people around the world – coworkers, acquaintances, people I’ve gotten to know through blogs… I currently practice that by responding to mail and by reading other people’s blogs.

Learning how to nurture relationships over a distance is difficult, but I need to learn.

Being more practical

There are a lot of little things in life that I still need to learn. Driving, sewing, gardening, stuff like that. No substitute for experience – I just have to do it.

So those are a few of the things I’m working on learning these days. I’d love to hear your tips. How about you? What are you learning?

Configuration management with Drupal – Multiple developers, live site

July 6, 2008 - Categories: drupal

We’ve moved into the next phase of our development. External users now have access to our testing server, and theylle be busy not only filing bugs but also creating editorial content. This means that we can’t just drop the database and recreate everything from scratch. (Darn!) However, we still need a way to make sure that:

Here’s our current plan:

When we deploy the system to production, we’ll review all the content, remove the test data, and push the data and the code to the live site.

See http://heyrocker.com/drupal/content/deployment-and-change-management-problem for more analysis.

Might need to spend more time hanging out with Emacs geeks =)

July 6, 2008 - Categories: emacs, wickedcoolemacs, writing

This is dreadful. I’ve made no progress on my book, and I’ve noticed that it has steadily crept down my list of priorities. I suspect it has a lot to do with the kinds of people I hang out with and the kinds of places I hang out. ;)

I used to hang out in irc.freenode.net#emacs a lot, and I used to frequently check the RecentChanges page of http://www.emacswiki.org. Both were great sources for Emacs questions and answers, and they often inspired me to go and write blog posts sharing what I discovered.

Lately, I’ve been hanging out with Drupal geeks and social networking geeks–hence all the blog posts about Drupal and technology evangelism. This is because of work, and so my blog posts are about things I’m learning at work. My Emacs use is down to reading mail, reading news, and managing my day. I still use it every day, but I’m not doing a lot of development in it. (Hmm, maybe that’s something else I can set up.)

Maybe I should start writing from the front of the book instead – basic Emacs stuff, leading up to more advanced tips…

Sowing seeds: Common objections to technology evangelism for collaborative tools

July 7, 2008 - Categories: Uncategorized

Whether you’re a team member trying to convince your coworkers to explore a new tool, or a manager trying to require everyone to use a new system, you know that influencing other people’s opinions and behavior is really difficult. You’re no stranger to rejection.

You know what rejection sounds like.  “I’m too busy.” “I don’t have the time to learn that right now.” Or–more frankly–”I don’t see the value in that.” If you’ve _never_ heard these phrases, e-mail me – I want to know how you do what you do. Chances are, you’ve heard them. Chances are, you’ve even said them.

When someone says these things to you, it’s not a rejection of you or of the idea. It’s a sign that there’s a deeper issue that hasn’t been addressed.

In some cases, people will be firmly against your idea, and there’s not much you can do to help them consider the options. Many times, though, people do want to learn more and try things out–but they’re held back by one thing or another. If you can help them get over those barriers, they’re open to trying things out.

Here are five of the barriers I often come across, and some ways to help people break through them. Think about people you’ve tried to help and see if you can identify them on this spectrum. You’ve probably thought about each of these items before, but it helps to be able to take a step back and think about what’s stopping people.

  1. I’m happy with the existing tools. It’s difficult to introduce something new when an existing way is good enough for the needs people currently have, particularly if the new tool doesn’t do everything the old tool does and more. People who were happy with horse-drawn carts simply didn’t see why they would need a “horseless carriage” that was complex and finicky. Likewise, it can be hard to introduce new collaborative tools when people have gotten used to their existing tools and workarounds. It’s not enough to say that something is new and interesting. Try to identify significant pain points that give people enough reason to try something out, or point out compelling opportunities to get new benefits.
  2. No one else is doing it. This is a chicken-and-egg problem: You can’t use a tool to collaborate with other people unless they use it too, and they won’t use it unless other people are using it. You can address this by looking for ways to get individual productivity benefits from these tools, and then drawing people in when they need help from you. Sometimes you won’t be able to introduce a tool gradually. In that case, you’ll probably need your entire team’s cooperation or at least willingness to give the new tool a try for a limited period of time. Be prepared to help your teammates learn how to use the new tool, and focus on efforts that will get quick results.
  3. I don’t think I can trust beta software. New tools may not be fully supported, and they may not be able to provide as much performance as your team needs. Unfortunately, this is another chicken-and-egg problem that’s probably outside your control. Your early adoption can help the tool development teams justify additional investment in the tool, but it’s difficult to get other people to trust something that may be discontinued or that does not have sufficient resources. Team members may also lack trust in their ability to use the tools effectively. Your best bet is probably to use established tools for mission-critical collaboration until your team has more confidence in the new tools and their ability to use them.
  4. I don’t know where to start. This is probably the easiest barrier to address. At this point your team members are interested in changing and are ready to take action. Show people small actions they can take to get immediate benefit.
  5. I can’t make it a habit. If you’ve ever made a New Year’s Resolution or tried to break or start a habit, you know how hard it is to change your routine. This is basically what you’re asking people to do when you ask them to try out a new collaborative tool–to make it a habit. It’s okay if people lapse. Just help them start again. One way to help is by identifying some behaviors people want to change, such as replacing e-mailed attachments with uploads to a team workspace. When you see the old behavior, remind people (gently! =) ) about the new behavior. Reinforce this by helping them see the benefits they’ve personally experienced. If the new tool is a good fit for people, they’ll eventually make it part of their habits.

Next: Sowing seeds: Five methods

Canada and Web 2.0 conferences

July 9, 2008 - Categories: canada, web2.0

A colleague asked me about Web 2.0 and social networking conferences in Canada, so I figured I’d post it here too. Here are the big ones I know about:

Any really cool ones I missed?

Check out my parents =)

July 9, 2008 - Categories: family

My dad and my mom know how to make things happen.

My dad often comes up with wild ideas, such as creating a cultural tradition (he’s been immortalized in one of the tribal epic poems), flying an ultralight across the Philippine archipelago, or organizing large photography trips up to the rice terraces of Banaue. Sometimes these ideas start with “Wouldn’t it be fun if…”. Other times, my dad sees a need and responds to it. My mom helps my dad make those ideas reality by connecting with different groups, helping my dad inspire them with his vision, and organizing the logistics.

Growing up watching them move mountains, I learned the power of having a vision and bringing people together. I saw how my parents’ initiatives weren’t just about doing what they wanted to do, but also making it possible for other people to do what they wanted but never dared to do before. People appreciated the opportunity to make a difference, to join in making things happen.

If you like what I’m learning about and talking about, you’d probably really like learning from my mom (http://daysstories.blogspot.com, http://adphoto.com.ph/business/) and my dad (http://www.pinoyphotography.org/forum/index.php?topic=2922.0 – my dad is MagicEye, check the thread for lots of stories). They rock! =)

To dream the impersonal dream

July 10, 2008 - Categories: entrepreneurship, passion

I’ve been trying to find words to explain what it’s like wanting to make things happen, how it’s not about me but rather about the possibilities I see. One of the books I just picked up from a library has a good quote about it:

Entrepreneurship is nothing about the one who creates a thing and everything about the one who consumes the thing. Entrepreneurs don’t care about the thing they create, in and of itself (as much as they may love what they produce or do). They care about creating it because of the impact it can have on someone else. It’s about that thing as an answer to a question others have long ago stopped asking, or long before they even consider the possibility of it changing for them. (p.50)

And another snippet:

Unless your idea for a business exceeds anything you have ever imagined doing before, is bigger than anything you have believed yourself capable of before this moment, has the potential of transforming a large enough number of people’s lives in the world to make a huge difference in how the world works, and challenges you sufficiently to risk everything you have to make it a reality, don’t do it.

Just don’t do it, dear reader, because it will likely disappoint you in too many ways to mention.  Don’t do it unless you’re ready to rumble.  Don’t do it unless you can put all your fears behind you. Don’t do it unless the pain of not doing it will exceed the probable pain of doing it by a factor of ten.  Don’t to it, because it’s not a game one plays casually.  Don’t do it, because it will confound you, confuse you, threaten to overwhelm you, every single dangerous step of the way. (p.104)

Awakening the Entrepreneur Within: How Ordinary People Can Create Extraordinary Companies
by Michael E. Gerber

Read more about this book…

Here’s what I care about at work:

So I guess I’m a bit of an intrapreneur after all. Technology evangelism around Web 2.0 and emerging technologies is officially part of my job, but all of these things are things I do because I have to do them, because I can’t imagine not doing them. =) I’m going to need a lot of help, but there are a lot of people who are glad to help out because these are their visions too. (I like to think that I’m the one helping them!)

Let’s find out how wonderful it can be. =)

What’s your dream?

Ruby code to quickly convert titles to ISBNs

July 10, 2008 - Categories: book, library, reading, ruby

I love the Toronto Public Library system. I can’t say that enough. I particularly love how I can go on a reading spree, place holds on a gazillion books, and have them delivered to the library branch that’s about three blocks away from the house.

Ideally, of course, these books would arrive suitably spaced apart so that a new batch arrives just as I’ve finished another. This happens when I request popular books. Most of the time, though, the books that I want to read fall in the Long Tail–obscure titles, books that have fallen off the New York Times bestseller lists, and the occasional random find.

All of these books tend to descend on the unsuspecting library branch at the same time.

There were 27 books waiting for me earlier. The librarian thanked me for clearing the shelf. J- greatly enjoyed piling them into the shopping cart we had the foresight to bring. Yes, I’ve got presentations to prepare and things to do–but reading is fun, and I’m somehow going to find time to read all those books before my three-week loan period is up. I’ll probably be able to renew them, but hey, might as well try.

So I decided I might as well try tracking them on LibraryThing. Instead of typing in all the details manually, I grabbed the list of titles from my account on LibraryElf (good reminder system for books), used ISBNdb to convert the titles into ISBNs (best guess), and imported the list of ISBNs into LibraryThing. Now my profile lists 163 books–a small fraction of the books that have passed through my hands, but it’s better than nothing. Someday I might even get myself a barcode scanner so that I can just pick up the ISBNs from the book jackets.

Anyway, I promised the Ruby code I’d quickly written to convert the titles to ISBNs:

require 'net/http'
require 'CGI'
require 'open-uri'
require 'rexml/document' 

access_key = 'YOURACCESSKEYHERE'
while (s = gets)
  s.chomp!
  url = "http://isbndb.com/api/books.xml?access_key=" + access_key + "&index1=title&value1=" + CGI::escape(s)
  xml = REXML::Document.new(open(url).read)
  if (xml.elements["ISBNdb/BookList/BookData"])
    puts xml.elements["ISBNdb/BookList/BookData"].attributes["isbn"]
  end
end

Takes titles as standard input, prints out ISBNs. Enjoy!

Weekly report: week ending July 11, 2008

July 11, 2008 - Categories: weekly

Lots of progress and lots of connection – good week!

Next week is another presentation gauntlet: four unique presentations given a total of eight times! Yikes! I hope to not only survive this gauntlet, but to do it in style. After all, it’s fantastic that I have all these opportunities to share what I’m learning. It’ll be a challenge to maintain my enthusiasm and passion throughout the four repeats of a single presentation, but if I can do that, then I’ll be ready for a whole lot more.

Stay tuned!

Hello, I’m Sacha Chua! (Self-introduction and sitemap in verse)

July 12, 2008 - Categories: sketches

Inspired by Dr. Doolittle, Animaniacs, and the Slideshare World’s Best Presentation Contest, I present to you my self-introduction/sitemap… in verse! =) It was fun to make, and I hope it makes you smile. =)

Like it? Please vote for it!

World’s Best Presentation Contest
I’d love to see how far this… err… sketchy style of presentations can go. =)

Here’s the text:

Hello, I’m Sacha Chua and I’m really pleased to meet ya.
How can I assist ya? I would love to find out how.

So what can I connect you to? Ideas that would help you through?
Some tools, perhaps, to help you do the thing you’re working on right now?

Are you changing your bulletin boards and stickies, your e-mail and Notes twisties
for bookmarks, blogs, and wikis? I can help you strategize.

Are you looking for a presentation ’bout Web 2.0 and my generation?
(It has caused a small sensation–all this interest in Gen Ys!)

If you’re also into Drupal and you’re searching for something useful,
then I hope, my fellow pupil, that I’ve written what you need.

Are you an Emacs fan at home with M-x plan
and all that Emacs can? You’ll like my Emacs feed.

Are you looking for a book that’s worth a second look
and some time in a nook? We might see eye-to-eye.

Can I teach you what I learned from the pancakes that I burned?
(Too late the things were turned!) For my notes, read CookOrDie.

I’m a person full of passion (and a hacker of some fashion).
I reflect and I take action, and it’s all there on my page.

There are few things I’ve not written (even times that I’ve been smitten,
and my darling psycho kitten) because all the world’s a stage.

There’s more in my six years of blogging hopes and fears
and laughter, anger, tears–and there’ll be more to come!

I’d love to hear from you, your thoughts–and comments too.
Thanks for clicking through. I hope you’ve had some fun!

GBS Learning Week: First set

July 13, 2008 - Categories: conference, ibm, presentation, speaking

I think it’s amazing that I get to talk about my favorite tools and encourage people to try things out. I’m at the GBS Learning Week in Niagara-on-the-Lake in order to present "The Top Ten Web 2.0 Tools Every IBM Consultant Should Try," and I’m scheduled to do it four times over two days. I’m also giving part of the keynote presentation–a short segment on the demographic revolution, given twice over two days. Oh, and I’ve got an early-morning presentation on Tuesday, an unconference session to facilitate, and another Web 2.0 teleconference workshop on Friday.

I am so going to earn that massage.

I did the first set of presentations today. About thirty people attended the first session, and about fifteen people attended the second.

Back-to-back sessions are tough. I felt more comfortable with the first session because I could chat with the audience before starting. The second was a bit more difficult because I didn’t want to wait too long, but that meant that people filtered in during the start of the presentation. Next time, I’m going to give myself more time between presentations so that I can grab a drink of water, chat with people, and reset myself.

Good stuff, though. I’m tempted to radically restructure the presentation as a story. Might be worth trying–and it’ll be fun! I should ask the organizers if I can get the feedback forms from the first day separate from the feedback forms from the second day. After all, how many times will I get to test presentation styles with the same layout, same type of audience, same timeslot, and things like that? =)

Ooh, this will be fun.

Notes from GBS Learning Week

July 17, 2008 - Categories: conference, connecting, weekly

I just got back from the GBS Learning Week conference held at White Oaks (Niagara-on-the-Lake), and I wanted to write down my notes before plunging back into e-mail and the daily routine. Here’s a brain-dump just so that I get everything out there. I’ll refine some points into blog posts later.

Ideas for improving networking at conferences:

Main tent, second time: (~200 people)

Web 2.0 tools, third and fourth times: (~15 + 10)

Main tent, first time: (~ 200)

Web 2.0 tools, first and second times: (~ 30 + 15)

Sowing Seeds: A Technology Evangelist’s Guide to Grassroots Adoption (~20)

Ideation:

Miscellaneous:

Managing interruptions

July 17, 2008 - Categories: productivity

W- asked me if I could recommend any self-help books or tips on how to manage interruptions and get back on task. I thought it was funny because I’m usually the one who has problems staying on task. (Dishwasher partially full, laundry sitting in the washing machine, un-sipped tea, things like that…) =) Then again, I think I get fewer computer-based interruptions than he does.

I told him that David Allen’s book on Getting Things Done is popular among geeks who deal with frequent interruptions. The key ideas that help are to write down all the tasks in a trusted system, and not to switch tasks unless it’s really urgent and important.

He’s also checking out LeechBlock, a Firefox extension that makes it just a bit easier to focus on your real work instead of going to your favorite time-wasting sites. =)

One sentence – microfiction, microlife

July 17, 2008 - Categories: writing

Microblogging done beautifully: onesentence.org. Someday I hope to be able to write like that. =)

Reflecting on time and overtime

July 18, 2008 - Categories: career, life, reflection, sketches, work

080718-21.49.23 

This week gave me an opportunity to think about time, work, and money.

I had spent much of Sunday and my evenings on conference-related work. As much as I enjoyed the opportunity to reach out and touch people I wouldn’t ordinarily get to meet, I also realized that it was time I took away from my personal projects and my other relationships. By the time the conference wrapped up on Wednesday, I was looking forward to a quiet day working at home.

Although I’d already worked the typical number of hours for the week, I still felt that I needed to keep working on Thursday and Friday. I wanted to make some more progress on my main billable project, and I was also helping a number of volunteer efforts get off the ground. I put in a full day of work on Thursday, and I headed into the office on Friday.

After I did some more work on my main billable project, demonstrated some of our internal Web 2.0 tools, and replied to my e-mail, I looked into the process for filing overtime. I had given the company my personal time because the company wanted the value I could create, so I figured that I should be able to get some of that value back. I knew I could be compensated in either money or time, but I needed to do some paperwork.

Catching myself getting frustrated by the process for filing overtime, I decided to put off the paperwork until next week and enjoy some of the time that I had earned.

Don’t get me wrong–I love the opportunities I have to grow and work with such wonderful people. I just want to make sure that I’m living the values that I want to live, because I won’t be effective if I’m not authentic. This doesn’t mean that I don’t love my work. This means I love it enough to want to always love it, instead of coming to resent it or losing touch with myself.

During my commute back, I looked at the options of no overtime, overtime for money, overtime for time, and free overtime, thinking about their effects on my happiness, relationships, increased opportunities to help, career progress, and bank balance. This is the chart I sketched on the subway ride home.080718-21.49.23

VALUES: Personal happiness and relationships are very important to me. I enjoy opportunities to help, but I’m not too worried about it because there are more than enough awesome opportunities to reach out and make a difference, both inside and outside work. I think about but am not overly concerned with career growth, because that tends to follow opportunities to help. Money is flexible. I don’t mind growing wealth and I’d like to share in the value I create, but because I enjoy being frugal and I don’t have many financial demands, I’m not driven to earn more and more.

OPTIONS:

No overtime: If I try my best to stay within the 40-44 hours that forms a "typical" work week, I think this will have a terrific effect on my happiness and my relationships. I’ll be able to explore other areas, exercise my creativity, and keep myself from going overboard. I’ll miss out on some opportunities to help at work and my career won’t progress as quickly as other people’s might, but I’ll have more opportunities to help outside work and those opportunities may turn into things that can make money for me, too. This doesn’t stop me from volunteering on things I love about work during my free time (but only the things I love!). =) What will I do with the rest of the time? Experience new things, think, learn, write, dream, doodle, listen, share, grow…

Overtime compensated by money: Ideally it would be overtime for something I really enjoy and would be doing anyway, but even in that case, I’d still have to deal with the paperwork. Once I sort out the paperwork, though, this will be less stressful. (I should revise this chart after I complete the process a number of times.) On the downside, I might find myself doing overtime on things I don’t particularly care about, in which case I’ll probably feel the strain of not enough rest, reflection, or creative randomness. I may also end up finding it easier to focus on work than on relationships, so that’s not too good either. In addition, money is flexible, but time is irreplaceable. On the upside, it’ll open up more opportunities to help at work, it would be good for my career (particularly that utilization target), and it would grow my bank balance (well, after taxes). It’s also a good way of making sure that I spend time on things that other people will find valuable.

Overtime compensated by time later on: This depends on the circumstances. I would need to fill out paperwork and coordinate with my team members, which will take effort. On the other hand, if this allows me to move time around so that I can have more chunks of free time, then that can work out well for personal happiness and relationships. If I can put in work when demand is high and take time for myself when demand is low, then my opportunities and career would probably be positively affected. On the other hand, there will probably always be demand, and it’s hard to take a break when other people are working hard.

Free overtime: I can skip the paperwork, but that doesn’t solve the problem of being more stressed because I give up time spent on rest, reflection, learning, or relationships. It’s good for opportunities and career, and has a neutral effect on money.

SUMMARY: My intuition tells me that the no overtime case gets me closest to living my values without too much stress, and even if that might limit my career advancement, it opens so much more of life to me. Overtime for money and overtime for time are pretty much tied, but it’ll be a moot point because overtime is going to be phased out for my job category next year. Free overtime is good for the company, but it doesn’t help me confront and try to live my values, and it’s too easy to get sucked into work.

I’m going to work on the paperwork so that I can get what I’m eligible for and so that I can understand the process. After that, I’ll avoid working overtime unless the company really really needs it, and then I’ll see if I can either take that as time off (preferably) or as money.

I think it’s good to think out loud about things like this. I’ve learned more about my tradeoffs, and I’d love to hear your insights. If my employer disagrees with the way I currently think, I’d rather hear about it now (and maybe work out a different view?) than later. It doesn’t mean that I don’t love my work. Again: all this means I love it enough to want to always love it, instead of coming to resent it. I hope that by thinking about my values and decisions, I can make the fit better and better.

What teachers make

July 18, 2008 - Categories: speaking, teaching

Someday I’m going to be able to speak truth like that.

Emacs Org Google Tech Talk

July 18, 2008 - Categories: emacs, geek

I’m so envious! Time to get working on that book…

Link from minor emacs wizardry

Learning how to drive is about starting even after you stall

July 19, 2008 - Categories: life

080720-02.10.23

I’m still learning how to drive.

It seems that most teenagers anxiously waited for the birthday that let them get a learner’s permit and get on the road. I didn’t. Between carpools, public transit, and other people driving, I never needed to drive. Besides, jeepneys, buses and tricycles made driving in downtown Manila a harrowing spectacle. In Toronto, public transit can get me nearly everywhere I need to go. I’d like to stay car-free as long as possible, as I’ve seen how owning a car can be an expensive proposition.

Still, there’s no getting around the fact that driving is a useful skill, so I’m learning. It’s difficult to learn something that other people already take for granted. I feel frustrated whenever I have to do so much back and forth in parking or when I make the wrong decision when it comes to navigating. I learn so slowly!

I’m lucky that W- can put up with my mistakes patiently, and he even tells me not to be so hard on myself. It’s difficult not to berate myself for mistakes like stalling the car in the middle of the road and then grinding the starter in my panic. One of the things I’m learning from all of this is that even when I feel like a failure and all I want to do is make the stress stop, I need to relax and reset my mood if I’m going to be able to do better. I need to make an effort to switch my mental track from:

“Why can’t I get this? Teenagers pick this up quickly.”

to

“Everyone’s alive? Good. Anything else can be taken care of. Now, how can I do things better next time?”

If I don’t make that mental switch, I end up making more and more mistakes. If I do, then I might stand a chance of making it home without making W-’s knuckles white.

One of the things that I’ve noticed is that I have a hard time navigating. We’ve passed through those roads countless times, but even when W- asks me what looks familiar, I find it hard to distinguish between the different reasons that different things look familiar. So after driving practice today, I finally looked up all of these places on Google Maps. I couldn’t figure out how they were related just driving along, because I couldn’t focus on anything aside from not getting into an accident. Seeing the map in my head might make navigation easier for me.

Learning how to drive is not fun, but I know I need to learn. The only thing to do whenever I stall is to start again. (Preferably without grinding the starter.)

Keeping things fresh; Analyzing session feedback

July 19, 2008 - Categories: conference, presentation, speaking

One of the best ways to keep yourself enthusiastic and engaged when you’re presenting a topic that you’ve talked about a number of times before is to keep changing it, whether it’s by tweaking the content of your presentation or opening it up for more discussion. For my four GBS Learning Week sessions on “The Top 10 Web 2.0 Tools Every IBM Consultant Should Try” (available on the IBM intranet on Pass It Along), I decided to vary the structure. The first two times I presented it, I added a new tool to the list and consolidated two other items. For the third and fourth times, I presented it as a survey or quiz instead of a straight list of recommendations.

The third and fourth times felt a lot more effective for me because the new structure made it easier for people to reflect on their current practices and see the potential benefits of these new tools and new ways of working. I made sure that the session feedback for the third and fourth sessions were kept separately, so I could look for any differences.

Then it was time to put on my (very small) stats geek hat. The quantitative feedback didn’t show any statistically significant differences, which I didn’t mind because my average satisfaction rating was around 3.5 out of 4 (midway between “satisfied” and “very satisfied”).

How satisfied were you with this session? (4 – very satisfied, satisfied, neutral, dissatisfied – 1)

  1st/2nd 3rd/4th
Mean 3.49 3.73
SD 0.60 0.46
SEM 0.10 0.12
N 39 15

I got practically the same ratings for the question: How relevant was this topic to your current role and/or interest for your career development?

The comments were:

I also changed the follow-up strategy for the third and fourth sessions, promising to e-mail people afterwards instead of just directing them to where they can download the presentation. We’ll see how well that works. I might yet see significant differences in adoption and retention. =)

Speaking of session feedback, I’ve been meaning to post my speech feedback from the Technical Leadership Exchange session I gave on I.B.Millennials: The Net Generation and Those Who Recruit, Hire, Manage, Work With, and Sell to Us.

NSI Rating Scale:

Excellent: 85 – 100
Good: 75 – 84
Fair: 65 – 74
Poor: 55 – 64
Severe Problem: below 55

The value of the content       
Total Responses: 43    NSI Rating: 87.21 (Excellent)   Ranking: 64 of 317
The speaker’s ability to deliver the material       
Total Responses: 42    NSI Rating: 92.86 (Excellent)   Ranking: 47 of 317
Your ability to apply what you learned       
Total Responses: 43    NSI Rating: 70.93 (Fair)   Ranking: 115 of 317
This session will help me achieve my business goals       
Total Responses: 43    NSI Rating: 63.37 (Poor)   Ranking: 164 of 317

Comments were:

I’ve got the “interesting and engaging overview” part down pat, and it would be even more effective if I can directly link it to people’s next actions and business goals. That particular presentation was more about talking about issues and setting the stage for a discussion rather than helping people make immediate changes in terms of recruiting/hiring/managing/collaborating with/selling to Generation Y, though, so that’s understandable. Presentations like “Top 10 Web 2.0 Tools ___ Should Try” are much more focused on next actions, and those seem to be okay.

So what’s the next step from here? On the “building on your strengths” side, I’m working on more visual communication. You can check out my attempts on my Slideshare page. Three of my six public presentations have been featured on Slideshare Presentation of the Day, so I must be on to something here. =) On the “shoring up your weaknesses” side, I’ve been thinking about presentation topics that can lead to immediate next actions. I didn’t feel that “Sowing Seeds: A Technology Evangelist’s Guide to Grassroots Adoption” was as effective as it could’ve been. Reminds me of this:

Zander goes on to say “…if the eyes are not shining you have to ask yourself a question: who am I being that my player’s eyes are not shining?” This goes for our children, students, audience members, and so on. For me that’s the greatest takeaway question: who am I being when I am not seeing a connection in the eyes of others?

“Benjamin Zander: Who are we being?” Garr Reynolds, Presentation Zen

Kaizen: relentless improvement. I want to learn how to help people’s eyes shine with possibility.

Emacs: BBDB: Modifying the record creation process

July 20, 2008 - Categories: bbdb, emacs

You might want to add fields to the record creation process in M-x bbdb-create. In addition to asking for name, company, e-mail address, addresses, phone numbers, and notes, you may want to make sure you remember to put in birthdates or other information. If you want to prompt for custom fields after the regular BBDB creation form, modify this simple example to suit your needs:

(defadvice bbdb-read-new-record (after wicked activate)
  "Prompt for the birthdate as well."
  (bbdb-record-putprop ad-return-value 'birthdate
		       (bbdb-read-string "Birthdate (YYYY.MM.DD): ")))

Thanks to Kaleb Yilma for the question!

Emacs: Smarter interactive prompts with Org remember templates

July 20, 2008 - Categories: emacs, org

Paul Lussier wanted to know how to interactively prompt for a value and use that value multiple times in org-remember-templates. His example is:

(setq org-link-abbrev-alist
      '(("RT" . "https://rt/Ticket/Display.html?id=")))

(setq org-remember-templates
      '(("Tasks" ?t "* TODO %?\n  %i\n  %a"            "~/organizer.org")
        ("Appts" ?a "* Appointment: %?\n%^T\n%i\n  %a" "~/organizer.org")
        ("RT"    ?R "* [[RT:%^{Number}][%^{Number}/%^{Description}]]" "~/org/rt.org")))

The version of Org on my system prompts for Number twice. We want to store the value in an associative list somewhere so that if Org encounters another prompt with the same text, it’ll use the stored value. Here’s a diff that’ll do the trick.

diff -u /home/sachac/elisp/org/org.el /tmp/buffer-content-4571Oz1
--- /home/sachac/elisp/org/org.el	2008-07-20 11:28:54.000000000 -0400
+++ /tmp/buffer-content-4571Oz1	2008-07-20 11:42:06.000000000 -0400
@@ -12822,38 +12822,52 @@
 	    (org-set-local 'org-remember-default-headline headline))
 	;; Interactive template entries
 	(goto-char (point-min))
-	(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([guUtT]\\)?" nil t)
-	  (setq char (if (match-end 3) (match-string 3))
-		prompt (if (match-end 2) (match-string 2)))
-	  (goto-char (match-beginning 0))
-	  (replace-match "")
-	  (cond
-	   ((member char '("G" "g"))
-	    (let* ((org-last-tags-completion-table
-		    (org-global-tags-completion-table
-		     (if (equal char "G") (org-agenda-files) (and file (list file)))))
-		   (org-add-colon-after-tag-completion t)
-		   (ins (completing-read
-			 (if prompt (concat prompt ": ") "Tags: ")
-			 'org-tags-completion-function nil nil nil
-			 'org-tags-history)))
-	      (setq ins (mapconcat 'identity
-				  (org-split-string ins (org-re "[^[:alnum:]]+"))
-				  ":"))
-	      (when (string-match "\\S-" ins)
+	(let (interactive-entries lookup)
+	  (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([guUtT]\\)?" nil t)
+	    (setq char (if (match-end 3) (match-string 3))
+		  prompt (if (match-end 2) (match-string 2))
+		  lookup (assoc prompt interactive-entries))
+	    (goto-char (match-beginning 0))
+	    (replace-match "")
+	    (cond
+	     ((member char '("G" "g"))
+	      (let* ((org-last-tags-completion-table
+		      (org-global-tags-completion-table
+		       (if (equal char "G") (org-agenda-files) (and file (list file)))))
+		     (org-add-colon-after-tag-completion t)
+		     (ins (if lookup
+			      (cdr lookup)
+			    (completing-read
+			     (if prompt (concat prompt ": ") "Tags: ")
+			     'org-tags-completion-function nil nil nil
+			     'org-tags-history))))
+		(if (null lookup)
+		    (setq interactive-entries (cons (cons prompt ins) interactive-entries)))
+		(setq ins (mapconcat 'identity
+				     (org-split-string ins (org-re "[^[:alnum:]]+"))
+				     ":"))
+		(when (string-match "\\S-" ins)
 		(or (equal (char-before) ?:) (insert ":"))
 		(insert ins)
 		(or (equal (char-after) ?:) (insert ":")))))
-	   (char
-	    (setq org-time-was-given (equal (upcase char) char))
-	    (setq time (org-read-date (equal (upcase char) "U") t nil
-				      prompt))
-	    (org-insert-time-stamp time org-time-was-given
-				   (member char '("u" "U"))
-				   nil nil (list org-end-time-was-given)))
-	   (t
-	    (insert (read-string
-		     (if prompt (concat prompt ": ") "Enter string"))))))
+	     (char
+	      (setq org-time-was-given (equal (upcase char) char))
+	      (setq time (if lookup (cdr lookup) (org-read-date (equal (upcase char) "U") t nil
+								prompt)))
+	      (if (null lookup)
+		  (setq interactive-entries (cons (cons prompt time) interactive-entries))
+		(org-insert-time-stamp time org-time-was-given
+				       (member char '("u" "U"))
+				       nil nil (list org-end-time-was-given))))
+	     (t
+	      (let ((text
+		     (if lookup
+			 (cdr lookup)
+		       (read-string
+			(if prompt (concat prompt ": ") "Enter string")))))
+		(insert (or text ""))
+		(if (null lookup)
+		    (setq interactive-entries (cons (cons prompt text) interactive-entries))))))))
 	(goto-char (point-min))
 	(if (re-search-forward "%\\?" nil t)
 	    (replace-match "")

Have fun!

Drupal: Testing multisite/domain-access Drupal locally and on a testing server

July 22, 2008 - Categories: drupal

We’re using Domain Access to manage a number of related subdomains on a single server. I prefer to develop and test locallly, then push my changes out to a testing server so that other people can try the system. I use the same domain names on my computer and on the test server so that I don’t have to make any changes in the database. To switch between them, I comment or uncomment a line like

127.0.0.1 example.com sub1.example.com sub2.example.com

in my /etc/hosts file.

However, Firefox caches the domain name information, and it can be confusing to figure out which server I’m on. The following setup makes this much easier:

  1. Install Domain Details to show the IP address of the server in your status bar. Good for a quick check – am I on 127.0.0.1 or elsewhere? (NOTE: I started with ShowIP, but it looks like ShowIP caches the information.)
  2. Install the Clear Cache Button extension.
  3. Restart your browser and customize your toolbar. Add the Clear Cache button. Click on this before switching sites.

In an ideal world, I’ll have a plugin that automatically twiddles my DNS entries, too. =)

Weekly review: week ending July 20, 2008

July 22, 2008 - Categories: weekly

Oops. I’m a bit late. =)
.
There wasn’t much else to report besides the GBS Learning Week and my feedback from it. Worked a lot during those four days, ended up slightly frazzled on Thursday and thinking about overtime. Survived making seven presentations in one week! Also, got some practice in driving, came across a few cool videos, such as What teachers make (inspiring) and the Emacs Org Google tech talk (geeky), and worked on some more Drupal stuff. Had nice chat with Mom.

Goals for this week:

Drupal: Adding a footer to all of your system e-mail

July 23, 2008 - Categories: drupal

Drupal’s hook system is making me almost as happy as Emacs’ hook system does. =)

There’s a hook_mail_alter function that allows you to modify any message your system sends. Example:

function mymodule_mail_alter($mailkey, &$to, &$subject, &$body, &$from, &$headers) {
   $body .= "\n\n" . t('This is a system-generated email, please do not reply to this message');
}

You gotta love developers who plan for extensibility and put all sorts of hooks into the code…

Please vote for my about-me/sitemap slideshow on Slideshare!

July 25, 2008 - Categories: drupal, emacs, sketches

Only 7 days left for the Slideshare World’s Best Presentation Contest, and I’d love it if y’all came out and voted for my about-me presentation–if only because I found a way to fit both Drupal and Emacs into my rhyming self-introduction! =)

It’s only one minute and 25 seconds, and it’ll probably make you smile. Plus, it’s a (mostly) working sitemap, and how cool is that? ;) The prize for this category is an iPod Touch, which (if I win it) I will promptly put to good use. After all, if I used my Nintendo DS to make a presentation, what might I do with something like the iPod Touch? ;)

Honorable mention would get me a copy of Presentation Zen book, which I liked so much I bought it already, so I’d be happy to raffle it off and keep just the warm and fuzzy feelings that my fledgling sketching and writing skills got noticed. Want it? Leave a comment on this entry (just one comment is fine), and I’ll pick a random commenter if I win the book.

In addition to either blog posts about doing interesting things with the iPod Touch or a chance at winning a free book, you’ll also get the satisfaction of supporting a geek in an area dominated by graphic designers. =) (Not that graphic designers can’t be geeks, of course.)

Anyway, please vote for my presentation! =) Voting ends on July 31, 2008.


World’s Best Presentation Contest

Weekly report – week ending July 25, 2008

July 25, 2008 - Categories: weekly

After putting in some work over the weekend, W- and I headed to Ottawa. He’s here for the Ottawa Linux Symposium, and I’m here to hang out with a few Linux geeks I know – or at least I would’ve been, had the two people I was looking forward to meet actually decided to come this year. (They both had very good reasons, though.)

Telecommuting worked out mostly okay. I finished the items on my list and joined all the relevant calls. Voice over IP occasionally flaked out on me, but we worked around it. I tried rebooting to Microsoft Windows a few times in order to use the VoIP plugin I’ve got in the mail client, but I sometimes encountered system problems. Still, none of that stopped me from getting my bug list down to zero, and I’m looking forward to the next phase of development in this Drupal project. Hooray! Maybe I’ll try to switch my development environment to Emacs during the break – that’ll encourage me to keep working on the book.

In other news, I now have tentative trips to Washington (September?), Berlin (October?), and Montreal (October?), all because of Web 2.0 stuff. Hooray!

I’m simplifying my wardrobe while adding some flair, too. ;) I used to be quite fond of dresses with matching bags when I was eight or so, and then (if you believe my sister) I promptly lost all sense of fashion. I’m slowly working out my style, my “uniform” – a white blouse, a black skirt or pair of slacks, and a scarf. I replaced my handbag with a medium-sized one with loops for a scarf, and I find a certain odd pleasure in having matched the scarf around my waist with the scarf tied (neatly) around the rim of my bag. It reminds me of fractals. I’ve also made progress on my quest for decent flat shoes I can wear to the office, having decided that life would probably be better without high heels. It might be unfashionable, but it’ll save me back pain in the long run.

Next week, my plans are to:

Emacs: Someone who’s even geekier about BBDB!

July 25, 2008 - Categories: bbdb, emacs

Remember all those tweaks I posted for working with contacts using Emacs’ Big Brother Database? John Sturdy has even cooler stuff. Check out his BBDB extensions. His bbdb-export-lists.el can divide people into different phone and address lists, and his bbdb-human-names.el will even try to address people properly. Clearly, I don’t talk to enough Reverend Doctors to require code like this. (And shouldn’t there be “Right Honorables” and “His Grace”s in there, too? ;) )

Things I can do to make progress on my book

July 26, 2008 - Categories: emacs, wickedcoolemacs, writing

Yet another snippet mode for Emacs

July 26, 2008 - Categories: emacs

While reading gnu.emacs.help, I came across yasnippet (yet another snippet extension for Emacs). It provides interactive templates for text or code entry. It’s similar to SkeletonMode, but with TextMate-type syntax, simpler prompting for information, and more focus on expanding mode-sensitive text in the buffer.

Here’s what I did to get started with it on my system:

  1. Download http://yasnippet.googlecode.com/files/yasnippet-0.5.5.tar.bz2 and unpack it as ~/elisp/snippets.
  2. Download http://yasnippet.googlecode.com/files/yasnippet-bundle-0.5.5.el.tgz and unpack it as ~/elisp/yasnippet-bundle.el .
  3. Symlink lisp-interaction-mode to emacs-lisp-mode with the command
    ln -s ~/elisp/snippets/emacs-lisp-mode ~/elisp/snippets/lisp-interaction-mode
    
  4. Add the following lines to ~/.emacs
    (require 'yasnippet-bundle)
    (yas/initialize)
    (yas/load-directory "~/elisp/snippets")
    ;; I don't like using partial words for completion
    (setq yas/key-syntaxes '("w_" "w_." "^ "))
    

So far, so good. M-x yas/minor-mode lets me use TAB as the completion key, and I can use TAB and S-TAB to navigate between the fields of a snippet as well. I think it’s a decent snippets mode if you don’t need the complexity of skeleton.el.

After some experimentation, I see how this might make me even happier working on Drupal. I’ve put together this first try at a template for Drupal modules. Drupal code has a lot of repetitive typing and/or search-and-replacing because all the hook functions need to start with the module name. With yasnippet, I can type in the module name once, and all the other functions will be updated. I often find myself looking up the argument lists for the hook functions, too, and the template includes the hooks I tend to use. I think this snippet will save me a lot of start-up time.

You know what would be even cooler? If I could create snippets that dynamically calculate values using Emacs Lisp. Then I could create, for example, a hook_user abbreviation that automatically picked up the module name from the filename or from the other functions. Wouldn’t that be cool?

UPDATE: Putting Emacs Lisp in templates is awesome. With this function in my ~/.emacs:

(defun sacha/drupal-module-name ()
  "Return the Drupal module name for .module and .install files."
  (file-name-sans-extension (file-name-nondirectory (buffer-file-name))))

I can make templates like this one for hook_user. Sweet!

Want to subscribe to a subset of my blog?

July 26, 2008 - Categories: blogging

I write a lot about Emacs. I also write a fair bit about Drupal. Both are rather geeky topics that may not interest you, or they might be the only things you want to read about. If all the posts you want to read fall into a specific category (example: emacs, drupal, sketches), you go to the category page and subscribe to just that category in your feed reader. If you want to exclude posts in a specific category, here are six ways to filter RSS feeds. Try out http://www.feedrinse.com.

I might occasionally go into firehose-mode, but at least you’ve got a way to control it! =)

Emacs is not just for computer geeks; also, these are the things that keep me going

July 26, 2008 - Categories: emacs, goodkarma

Reposted with permission because (a) it shows that people who aren’t computer geeks can also love Emacs, and (b) it gave me a warm and fuzzy feeling and encouraged me to keep writing, so I want to keep it around just in case I get in a rut again.

Sacha,

I’m an emacs newbie who’s trying to both simplify and empower my computing life, and I’ve chosen emacs as the tool to do that. I’m pretty excited about that, and overwhelmed, too.

Actually, a little background might help: I’m a PhD student in early modern (read: renaissance) English literature. Yeah, I’m a Shakespeare guy. I work in a field in which computers are, to most folks, MS Word, MS Entourage, and MS Explorer. I’m a nut who actually plays with stuff. (Actually, I don’t tell my colleagues about it. It could honestly damage my career. I know, it’s disturbing.) I also have some tech chops, being a refugee from the heady late 1990s tech boom where I co-founded a small company that made some money before it collapsed. I’ve been able to do the basics in emacs for years. The basics, but nothing more.

My introduction this time was a rather circuitous route: I moved from Mellel (on the Mac), to Scrivener where I discovered the wonders of MultiMarkdown. Happily I discovered that I could use MMD and TextMate to create LaTeX files without having to look at a bunch of distracting LaTeX markup. I could write plain text and, with a couple of handy keystrokes, create beautiful PDF files that my committee would appreciate. The plain text files took up no space and could be edited anywhere. I could fit a bazillion of them on my USB drive and carry loads of research with me to my office on campus (where I got a hand-me-down Dell running XP v.e.r.y.s.l.o.w.l.y) and on my much speedier Mac at home and even in Linux. Neat. Still, MMD felt hack-y and was only supported by one guy and I wondered if there was anything else like it out there.

Which lead me to muse-mode. From there you can guess my path of discovery: org-mode, planner-mode, remember: oh my!

For a prose writer like myself, the ability to have the cursor jump forward and backward by letter, word, line, and paragraph was nothing new, but M-a and M-e have changed my life. Why don’t all word/text processors understand that the sentence is the fundamental unit of prose writing? Why don’t they all allow me to navigate using units that make logical sense?

Whoever said that emacs was for programmers only surely isn’t a writer.

(This is becoming much longer than I had anticipated, sorry.) My point in writing is to tell you how invaluable I have found your two public chapters (I think they’re 7 and 8) have been for me. The whole idea of writing a book about emacs as cool (as opposed to just highly functional) is both obvious and revolutionary. Know that I would buy a copy today if only it were available.

I noticed in your blog that you felt you had lost some steam on the book. Please don’t. My life is better, my writing is better, my research is better, and, much to the joy of my wife, my progress toward a completed PhD is better, all thanks to emacs which, based on the tools I’m using, is also in thanks to you.

So thank you, and keep writing. I, for one, and hungry for more. I’m sure others are, too.

Jeffrey Windsor

Emacs: Keyboard shortcuts for navigating code

July 27, 2008 - Categories: development, emacs

UPDATE 2014-01-21: Add regexp-quote around current-word.

One of the lines on my list of things I can do in order to make progress on my book is to move my Drupal development environment from Eclipse to Emacs, as immersion would no doubt give me plenty of things to tweak and describe. When you use something every day, you notice the rough edges. With Emacs, you can sand those edges down. I already use Emacs every day, but I had been doing most of my development work in Eclipse because Eclipse packaged a number of useful features I wanted. If I can move my environment to Emacs, though, I’ll be able to customize it a lot more freely.

Take something as simple as navigation, for example. In Eclipse, I can hit Ctrl+K to search for the next instance of the current word, which is a handy way to look for function calls or definitions in the same file. How would you do that in Emacs? The built-in search functions allow me to take text from the buffer, but I wanted something even faster. Here are some of the ways you can tweak navigation, too.

If you haven’t tried it yet, you’ll probably like interactive search (C-s) because you can modify the search and see the results as you type. All you need to do to make it better than Eclipse’s Ctrl+K is to add a function to grab the current word, even if the point in the middle of the word. Add the following code to your ~/.emacs:

(defun sacha/isearch-yank-current-word ()
  "Pull current word from buffer into search string."
  (interactive)
  (save-excursion
    (skip-syntax-backward "w_")
    (isearch-yank-internal
     (lambda ()
       (skip-syntax-forward "w_")
       (point)))))
(define-key isearch-mode-map (kbd "C-x") 'sacha/isearch-yank-current-word)

Type C-s (isearch-forward) to start interactively searching forward, and type C-x to get the current word. Use C-s and C-r to search forward and backward. You can modify your search, too.

Want to make it even faster? Use these functions to bind similar searches to shortcut keys:

(defun sacha/search-word-backward ()
  "Find the previous occurrence of the current word."
  (interactive)
  (let ((cur (point)))
    (skip-syntax-backward "w_")
    (goto-char
     (if (re-search-backward (concat "\\_<" (regexp-quote (current-word)) "\\_>") nil t)
	 (match-beginning 0)
       cur))))

(defun sacha/search-word-forward ()
  "Find the next occurrance of the current word."
  (interactive)
  (let ((cur (point)))
    (skip-syntax-forward "w_")
    (goto-char
     (if (re-search-forward (concat "\\_<" (regexp-quote (current-word)) "\\_>") nil t)
	 (match-beginning 0)
       cur))))
(global-set-key '[M-up] 'sacha/search-word-backward)
(global-set-key '[M-down] 'sacha/search-word-forward)

Feel free to change the keybindings or otherwise improve the code. =) Good luck and have fun!

Morning pages from Ottawa

July 27, 2008 - Categories: life

In one of her books, Julia Cameron suggested writing morning pages as a way to get one’s creative juices flowing – at least three pages of writing about whatever comes to mind. I still don’t know exactly how pages translate into blog posts, but I thought it would be nice to break up a string of Emacs-related posts with proof that I do, too, have a life. ;) (Well, a life outside Emacs, at least.)

That statement would probably have been more powerful had W- and I not chosen to skip the Ottawa Linux Symposium’s closing party in favor of working on our computers. He’s been trying to figure out how to get kubuntu up and running with all the usual IBM stuff, and I’ve been trying to figure out how to give Emacs all the features I like in Eclipse and more. So yes, that was what we were doing on a Saturday night: learning more about our tools while sharing a Killaloe sunrise beavertail. (No actual beavers harmed; it’s fried dough.)

We’re heading back to Toronto today. I’m looking forward to having oatmeal for breakfast and preparing a simple, Sacha-sized meal for lunch and dinner. A full week of eating out for every single meal has left me craving the kitchen. Yes, cooking takes more time, but I don’t have to decide between feeling guilty about leaving food on my plate and feeling satiated, I don’t have to take a chance on whether or not the restaurant will be closed (as was the case with many of our choices on Saturday evening), and I learn a lot more in the process. This is one of the reasons why I don’t like traveling for an extended period of time. I miss the kitchen. I miss turning meals from just fuel or explorations of tastes into experiments that’ll teach me something interesting along the way.

And yes, I’m also looking forward to getting back to the gym. It’s funny how you miss it. I’ve been making up with lots of walking, but still. I miss what I feel like after a good workout: bedraggled but triumphant.

I’ve enjoyed my brief stay in Ottawa, though. I didn’t get to meet the people I had been looking forward to seeing, but I did go to some of the birds-of-a-feather get-togethers. I checked out the Sparks pedestrian mall, the Rideau Centre, the Bytown museum, and I saw the cat sanctuary near Parliament (awwww!). I figured out some of the pieces that I’ll need to improve if I want to telecommute effectively from the Philippines. VOIP is a big one, and a backup calling card won’t hurt, either. I also need to figure out the timezone thing. =)

It’s been a good trip.

Eclipse to Emacs: Navigating your source tree

July 27, 2008 - Categories: emacs

Two other things I like about the Eclipse development environment are the ability to jump to a function definition and the ability to open any resource in the workspace. Fortunately, these shortcuts are easy to duplicate in Emacs.

Exuberant Ctags is a utility that builds an index of the function definitions in your source code. You can use this index to jump to any function definition using editors such as vi or emacs. To index your Drupal source code, for example, go to the root of your source directory and use a command like this:

find . -name \*.module -o -name \*.php -o -name \*.inc -o -name \*.install -o -name \*.engine -o -name \*.profile | etags -l php -

To use this index in Emacs, add the following code to your ~/.emacs, changing drupal-project-path as necessary:

(defvar drupal-project-path "~/proj/example" "*Base path for your project")

(require 'etags)
(setq tags-file-name (expand-file-name "TAGS" drupal-project-path))

Evaluate the code. You can then use M-. (find-tag) to jump to the declaration of a function in your project.

To open any resource in your source tree with a few keystrokes, index the files with filecache and use ido to open the file. Ido is well worth learning how to use. Here’s the code I use, taken almost directly from the filecache documentation:

(require 'filecache)
(require 'ido)
(defun file-cache-ido-find-file (file)
  "Using ido, interactively open file from file cache'.
First select a file, matched using ido-switch-buffer against the contents
in `file-cache-alist'. If the file exist in more than one
directory, select directory. Lastly the file is opened."
  (interactive (list (file-cache-ido-read "File: "
                                          (mapcar
                                           (lambda (x)
                                             (car x))
                                           file-cache-alist))))
  (let* ((record (assoc file file-cache-alist)))
    (find-file
     (expand-file-name
      file
      (if (= (length record) 2)
          (car (cdr record))
        (file-cache-ido-read
         (format "Find %s in dir: " file) (cdr record)))))))

(defun file-cache-ido-read (prompt choices)
  (let ((ido-make-buffer-list-hook
	 (lambda ()
	   (setq ido-temp-list choices))))
    (ido-read-buffer prompt)))

(ido-mode t)
;; Change this to filter out your version control files
(add-to-list 'file-cache-filter-regexps "\\.svn-base$")
(if drupal-project-path
    (file-cache-add-directory-using-find drupal-project-path))

(global-set-key (kbd "ESC ESC f") 'file-cache-ido-find-file)

This turns ESC ESC f into a handy shortcut for finding files anywhere in your project tree. Read the source code (ido.el) for more information on ido shortcuts.

Good luck and have fun!

(UPDATE: Added “.” to the find command – two people suggested it! =) )
(UPDATE: Forced etags to detect files as php and added .engine and .profile to the list of extensions)
(UPDATE: Added version control filter for file-cache)

Emacs, Remember, and GTD

July 28, 2008 - Categories: emacs

Charles Cave has written an excellent Remember Mode Tutorial with useful templates for notes, receipts, books read, daily reviews, and all sorts of other good stuff. Check it out!

Kaizen: What would make our Drupal lives better?

July 28, 2008 - Categories: drupal, kaizen

Kaizen: relentless improvement.

We’re getting ready for the next phase of our Drupal project, and it’s a good time to think about how we can make our process better.

What worked well:

Drupal: Patching simpletest for Drupal 5 to understand the Location header

July 28, 2008 - Categories: drupal

Automated testing is part of good programmer hygiene. I wanted to write tests for both functions and Web-based interfaces in our Drupal project, but one of the tests I wrote was always failing. Many prints and var_debugs later, I found out that it was because simpletest didn’t do anything with Location: headers, which happen when you drupal_goto an external site. Here’s a first pass at fixing that behavior – patch sites/all/modules/simpletest/simpletest/browser.php:

Index: browser.php
===================================================================
--- browser.php	(revision 753)
+++ browser.php	(working copy)
@@ -321,6 +321,22 @@

         $this->_history->recordEntry(
                 $this->_page->getUrl(),
                 $this->_page->getRequestData());
+        $counter = 0;
+        $url = $this->_page->_headers->_location;
+        if ($url) {
+          $url = &new SimpleURL($url);
+        }
+        while ($url && $counter < 10) {
+          $this->_page = &$this->_fetch($url, $parameters);
+          $this->_history->recordEntry(
+            $this->_page->getUrl(),
+            $this->_page->getRequestData());
+          $url = $this->_page->_headers->_location;
+          if ($url) {
+            $url = &new SimpleURL($url);
+          }
+          $counter++;
+        }
         return $this->_page->getRaw();
     }

(update: okay, let’s try diff syntax highlighting with wp-syntax…)

From Eclipse to Emacs: Drupal development with Subversion, tags, templates, and xdebug

July 29, 2008 - Categories: drupal, emacs

Yesterday, I started working on my Drupal project in Emacs. I can’t believe I hadn’t moved to Emacs earlier. =)

I really like being able to diff a file with C-x v = (vc-diff) and check in a file with C-x v v (vc-next-action). I also like the way that svn-status (from psvn.el) lets me examine a directory tree, mark a set of files, and commit them–all without using the mouse. I probably should’ve set up keyboard shortcuts for these in Eclipse, but Eclipse made it too easy to just use the mouse. Emacs encourages you to use the keyboard, and it’s easy to customize any keyboard shortcut.

php-mode’s C-c . (php-show-arglist) works beautifully with the TAGS file that I’d set up using Exuberant Ctags, so I don’t need to do anything special in order to get function definitions. Definition functions for PHP functions would be nice. In the meantime, there’s C-c C-f (php-search-documentation).

The yasnippet template engine came in handy when I was writing test cases. I updated my module template to include the simpletest hook, added a test case template, and added a template for the simpletest hook as well. Yay dynamic templates!

And I just got Xdebug working with PhpMode and Geben… Sweet!

Development kaizen: Deployment and testing

July 29, 2008 - Categories: drupal, kaizen

I got back yesterday to a still-empty defect list, so I decided to spend the day working on some infrastructure to help my team work more effectively.

Thinking about what could make the most difference in the other developers’ productivity, I decided to invest time into making it easier for them to deploy code to the testing server. I had written a Makefile target that efficiently transferred only the updated files, but the other developers worked on Microsoft Windows and did not have all the necessary tools. I spent the morning writing a web-based interface for them: a password-protected PHP script that displayed a list of recent revisions and allowed people to deploy a selected revision to a separate server. Behind the scenes, it was a mess of bubblegum and string. To work around various limitations, I strung together sudo and suid and rsync and ssh key-based authentication. It wasn’t pretty, but it worked. I e-mailed instructions to my team members, and they started using it right away.

After solving that problem, I focused on improving our tests. Fixing one bug often led to creating or recreating another, and these regression errors resulted in back-and-forth communication and wasted time. I explored the Simpletest automated testing framework for Drupal, and found out that I could write both unit tests and Web-based tests using the framework. However, I had a hard time figuring out why several of my Web-based tests consistently failed. I found out that the latest version of Simpletest for Drupal 5 did not understand the Location: header, which we use extensively in order to direct people to different subdomains and external sites. I fixed it and wrote a number of tests for one of our key modules. By the time I was ready to pack up and go home, I’d gotten into the swing of writing test cases.

Easier deployment and automated testing go a long way towards making a project almost a joy to work on. I’m glad I spent some time paving the way for my team and for other projects to come. =) Kaizen: relentless improvement.

Emacs and PHP: There’s more than one way to do it, of course

July 30, 2008 - Categories: emacs

The PhpMode page on EmacsWiki lists five options for developing PHP in Emacs. I’m currently using the php-mode maintained by Aaron Hawley, and I’m quite happy with it. I’m curious about the php-mode maintained by Ahmet Usal, though, as it has extensive templating support and electric behavior. It seems to have abbreviations and argument lists for every PHP function, and I might borrow the code and convert it to a yasnippet file if I don’t end up using this. I’ll switch to Ahmet Usal’s php-mode today, see what it feels like, and post my notes. Has anyone else tried both?

Emacs and PHP tutorial: php-mode

July 30, 2008 - Categories: emacs, wickedcoolemacs

php-mode is responsible for syntax highlighting, indentation, and other major PHP-specific modifications to your editing environment. There are a number of PHP modes available for Emacs. In this project, you’ll learn how to set up the php-mode available from http://sourceforge.net/projects/php-mode/ . At the time of this writing, the current version is 1.4.0 and the maintainer is Aaron Hawley.

Download the latest php-mode.el from http://php-mode.sourceforge.net/ and save it to a directory in your load-path. I like to organize my Emacs Lisp files in a directory called ~/elisp. To add PHP support to your Emacs, add the following lines to your ~/.emacs:

 (add-to-list 'load-path "~/elisp")
 (require 'php-mode)

This configures Emacs to automatically recognize files ending in “.php”, “.phps”, “.php3″, “.php4″, “.phtml”, and “.inc” as PHP files. To associate more extensions with PHP files, add lines like this example to your ~/.emacs:

 (add-to-list 'auto-mode-alist '("\\.module$" . php-mode))
 (add-to-list 'auto-mode-alist '("\\.inc$" . php-mode))
 (add-to-list 'auto-mode-alist '("\\.install$" . php-mode))
 (add-to-list 'auto-mode-alist '("\\.engine$" . php-mode))

This associates php-mode with the extensions used by Drupal, a PHP framework. When you open a file with the specified extension, it should be highlighted according to PHP syntax.

Here are some useful commands:

TAB c-indent-command Indent the current line
M-; comment-dwim Add a line comment, comments or uncomments the currently-selected region, or does other smart comment-related actions
C-c C-f php-search-documentation Search the online PHP manual for the current word
C-c RET php-browse-manual View the online PHP manual
C-c . c-set-style Change coding style
C-M-a, C-M-e c-beginning-of-defun, c-end-of-defun Go to the beginning or end of the current function
C-M-h c-mark-function Select the current function
M-a, M-e c-beginning-of-statement, c-end-of-statement Go to the beginning or end of the current statement

Here are some variables you may wish to customize:

indent-tabs-mode Set this to nil if you want to insert spaces instead of tabs
case-fold-search Set this to t if you want case-insensitive search.
c-basic-offset Set your tab size or number of spaces used as a basis for indentation

You can either customize these variables globally with M-x customize or set them for php-mode. Here’s an example that sets up a buffer with the coding style recommended for Drupal:

 (defun wicked/php-mode-init ()
   "Set some buffer-local variables."
   (setq case-fold-search t) 
   (setq indent-tabs-mode nil)
   (setq fill-column 78)
   (setq c-basic-offset 2)
   (c-set-offset 'arglist-cont 0)
   (c-set-offset 'arglist-intro '+)
   (c-set-offset 'case-label 2)
   (c-set-offset 'arglist-close 0))
 (add-hook 'php-mode-hook 'wicked/php-mode-init)

You can further customize the indentation by moving the point to where the indentation needs improvement and typing C-c C-o (c-set-offset).

To try automatic indentation, press C-j (newline-and-indent). If you like that behavior, you can make it the default in php-mode by adding the following line in ~/.emacs:

(define-key php-mode-map (kbd “RET”) ‘newline-and-indent)

You may also be interested in M-x show-paren-mode, which shows the matching parenthesis, bracket or brace for the character at point. You can enable it automatically by adding the following line to your ~/.emacs:

   (setq show-paren-mode t)

It’s a good idea to separate PHP and HTML code. This is not only better coding practice, but it also makes developing in Emacs much easier. php-mode focuses on PHP-specific behavior and does not have special support for HTML. Emacs has a number of packages that allow you to work with multiple modes like php-mode and html-helper-mode in a single buffer, but they don’t always work, and indentation can be confusing. If you must work with large segments of both PHP and HTML in the same file, check out MultipleModes (http://www.emacswiki.org/cgi-bin/wiki/MultipleModes) for tips.

Kaizen: Moving time around

July 31, 2008 - Categories: kaizen, life, productivity

I recently (re)discovered that writing is much easier and more enjoyable in the early morning when I’m fresh and focused than late at night when I’m thinking more about what I’m doing at work. To take advantage of this, I’ve been slowly moving my waking time earlier and earlier. Yesterday, I went to bed at 9 after tidying up and preparing for the next day. Today, I got up at 5:15. It was fifteen minutes later than I’d set the alarm clock for, but I realized that the dream I was dreaming wasn’t all that interesting compared to what I might learn if I started writing.

Moving tasks to the night before can support this early-morning writing by freeing up more time. The more I can do the night before, the less I need to do the morning after – and it pays off even when the exchange isn’t 1:1. For example, moving the half-hour I used to spend cooking steel-cut oats for breakfast from morning to evening means that I spend just a few minutes heating up a breakfast with much more texture than instant oatmeal. I packed my lunch last night, so I just need to grab it from the fridge and head out the door. I checked my purse for my keys and badge, too. Doing these little things the night before helps me streamline my morning routine.

What else can I do to free up time? I might try watering the plants in the late afternoon or try outlining in the evenings. OpenLoops has good tips for making the most of these early morning hours, and I’m sure I’ll discover more along the way.

I’d also like to look into freeing up weekend time. I used to save laundry loads and library runs for the weekend, but if I can use my weekday evenings to take care of these things, then that frees up a larger block of uninterrupted time.

Emacs and PHP: On-the-fly syntax checking with Flymake

July 31, 2008 - Categories: emacs

The dreaded white screen of nothingness usually means that I’ve misplaced a quotation mark or brace somewhere in my PHP code. On-the-fly syntax checking in Eclipse helped me find those errors quickly because I could scan the right scrollbar for areas marked with red. I knew that shifting to Emacs wouldn’t automatically cure me of the propensity to mismatch my parentheses. If I could get on-the-fly syntax checking working in Emacs, I’d save myself a lot of time.

It took me a while to sort out various configuration problems. Most were due to the fact that PHP didn’t report parse errors with my original configuration, even though I had uncommented the line after “Show only errors”. As it turned out, the error_reporting option in php.ini needs to include E_PARSE in order for php to report parsing error details. Here’s the value I’m currently using in /etc/php.ini:

error_reporting = E_ERROR|E_COMPILE_ERROR|E_CORE_ERROR|E_PARSE

Flymake is the package responsible for on-the-fly syntax checking in Emacs. Out of the box, it supports C, C++, XML, XHTML, Perl, Java, TeX, and IDL. To load Flymake and add support for PHP, add the following to your ~/.emacs:

(require 'flymake)

(defun flymake-php-init ()
  "Use php to check the syntax of the current file."
  (let* ((temp (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))
	 (local (file-relative-name temp (file-name-directory buffer-file-name))))
    (list "php" (list "-f" local "-l"))))

(add-to-list 'flymake-err-line-patterns 
  '("\\(Parse\\|Fatal\\) error: +\\(.*?\\) in \\(.*?\\) on line \\([0-9]+\\)$" 3 4 nil 2))

(add-to-list 'flymake-allowed-file-name-masks '("\\.php$" flymake-php-init))

;; Drupal-type extensions
(add-to-list 'flymake-allowed-file-name-masks '("\\.module$" flymake-php-init))
(add-to-list 'flymake-allowed-file-name-masks '("\\.install$" flymake-php-init))
(add-to-list 'flymake-allowed-file-name-masks '("\\.inc$" flymake-php-init))
(add-to-list 'flymake-allowed-file-name-masks '("\\.engine$" flymake-php-init))

(add-hook 'php-mode-hook (lambda () (flymake-mode 1)))
(define-key php-mode-map '[M-S-up] 'flymake-goto-prev-error)
(define-key php-mode-map '[M-S-down] 'flymake-goto-next-error)

Evaluate that code, open one of your PHP files, and intentionally break it. The syntax error should be highlighted. To change the highlighting, move your point to the error and type M-x customize-face. Accept the default (flymake-errline), then customize it as desired. Don’t forget to save your customizations for future sessions.

If your syntax errors are not highlighted and you get a message like this:

Configuration error occured while running (php -f test_flymake.php -l). flymake will be switched OFF

double-check your /etc/php.ini to make sure that E_PARSE is included as one of the options for error_reporting. You can check the output by running php -f yourfile.php -l. You should see the line number of the parse error. Make sure that this matches the regular expression added to flymake-err-line-patterns in your ~/.emacs. If your PHP returns a slightly different message, modify your flymake-err-line-patterns accordingly.

Flymake can save you a lot of programmer frustration for the cost of a little CPU time. Use it to check for errors before you save files or commit them to your source code control repository, and you and other developers will be much happier.

(UPDATE: Fixed typo in flymake-php-init)