Oct 9, 2008

emacs and stuff

I am sick with cold. It is probably flu, as the whole body hurts. I am in bed and don't feel like doing anything else. So I thought I'll type up a blog post.

I will try to keep this post to be about what I did and what I am doing, while avoiding what I plan to do. By now most of you are pissed about my grandiose plans that I blog about and don't follow up on.

One on the most productive things that I did was to learn the text-editor-slash-operating-system emacs. I was using vim to edit files in my remote webserver instances. I promise you that emacs kicks ass. Seriously. It is a joy to use it. I has so much fun tinkering with my .emacs file. Of course I've barely scratched the surface but it gives my such a happy feeling when I get a boring task done in a blink with keyboard macros.

For example, I am on-call this week at my day job. I got called in the middle of the night to rerun a set of programs. I had to write dumb code like this:

For list of jobs:
somepgm25
somepgm33
somepgm04
somepgm11

Create:
JOB SOMEPGM25
RUN OCT 9 2008
ENDJOB

JOB SOMEPGM33
RUN OCT 9 2008
AFTER somepgm25
ENDJOB

JOB SOMEPGM04
RUN OCT 9 2008
AFTER somepgm33
ENDJOB

JOB SOMEPGM11
RUN OCT 9 2008
AFTER somepgm04
ENDJOB

But I had to do this crap work more than 30 programs.

Here is the macro that I recorded:

M-d ;; kill-word
JOB ;; self-insert-command * 3
SPC ;; self-insert-command
S-C-y
M-B
M-U
RET ;; newline
2*SPC ;; self-insert-command
RUN ;; self-insert-command * 3
SPC ;; self-insert-command
OCT ;; self-insert-command * 3
SPC ;; self-insert-command
9 ;; self-insert-command
SPC ;; self-insert-command
2008 ;; self-insert-command * 4
RET ;; newline
TAB ;; indent-for-tab-command
AFE ;; self-insert-command * 3
DEL ;; delete-backward-char
TER ;; self-insert-command * 3
SPC ;; self-insert-command
S-C-y
M-Y
RET ;; newline
ENDJOB ;; self-insert-command * 6
RET ;; newline

It probably looks complex if you have never used emacs, but it is ridiculously simple. It is just a matter of starting the recording process and doing what you would do anyway.

So, my point is: though it is in no way earth shattering, it came in handy in the middle of the night and it made a guy smile who would have been cursing otherwise.

My thought is that you can make most of the dull tasks interesting. I am specifically saying "most" for a reason. You are out of luck if you have a micromanaging mofo for a manager.

I am typing this post in emacs of course! What did you think?

Not only this, I love how I can ssh to my instance on AWS and run emacs there. Coding is fun again. Especially because I am discovering emacs tricks everyday. I feel like how I felt when I discovered MSExcel macros when I first started working.

I was going to write about how I -- climbed the Seattle Columbia tower, ran a half-marathon across the 520 floating bridge, flew in a hot air balloon, flew a glider myself, revamped IWS with what I am learning from "Don't Make Me Think", enjoyed reading 'The Day Of The Jackal' etc but I'll blog about them later. I've rambled too much today. Also I'll blog about how Stevey is awesome.

No comments: