How to attach to a remote emacs session

I was away from my workstation which was running an emacs with several open files (some potentially unsaved!) when I wanted to access some of those files.

My emacs is always configured to run the server process. This means I can start an emacs process and edit any file with `emacsclient $file`. Instead of a new emacs process, the file is opened by my original emacs.

I was curious if I could use emacsclient to connect remotely to a running frame: I can. By ssh’ing in I can run `emacsclient -nw` (no-window) and get a new frame of that emacs client in the terminal which has all my buffers open and ready to go.

Alternatively, if you’re forwarding X connections, using `ssh -X` for instance, `emacsclient -c` will fire up a new emacs frame on your local machine which shares the same emacs process.

More information: http://www.emacswiki.org/emacs/EmacsClient

Naive Programming

I think that may always be the case, especially when the resulting program is a function of what I’m asked to do! I was instead considering how, give experience in mathematical reasoning and programming, one writes increasingly concise code.

Because of the intense usefulness of Maths in programming, I cannot grok my fellow students’ disapproval of the subject. One of the major ways my code has grown less naive is in the borrowing of mathematical concepts.

Naive:

// print the sum of numbers x through y.
int sum(int x, int y) {
  int s = 0;
  for (int i = x; i <= y; i++)
    s += i;

  return s;
}

Insightful:

// print the sum of numbers x through y.
int sum(int x, int y) {
  return y*(y+1)/2 - x*(x+1)/2; 
}

I cannot remember a time when a working insightful function has been worse then the naive equivalent. Even in my contrived example above the naive_sum() has inputs which would yield undefined output such as the case where y <= x while the insightful_sum() would degrade more gracefully.

In the naive style, we’d have to add conditionals to validate inputs that the maths would accept, meaning increased line count, reduced legibility, increased chance of errors, and increased nativity. The only advantage I can see to the naive style is the reduction in mathematically cluttered code.

FreeBSD on the Desktop: How much are we giving up?

I’ve been running FreeBSD for awhile now. Looking back at my posts, it appears that I hammed up my Slackware installation right around the turn of the new year so near abouts three-and-a-half months.

FreeBSD on the desktop, if you’ve experienced it, is a learning experience. So much that at times I feel like I’m being punished for not knowing everything about my system.

To clarify on my desktop history you should know that a few months ago I switched to xmonad for my window management from Fluxbox. I went from an already minimal window-manager to an an even more minimal window-manager.

I don’t want my desktop to do everything for me all the time. On the other side of the coin, I don’t want to have to do everything for it.

I was reminded of this disconnect when I fired up Fedora 16 on a machine at home (it was running FreeBSD but I was sick of compiling packages from ports. Yes, I know I can get packages in binary but I can’t understand how to keep my binary packages and ports in sync for cherry picking every other source.) Everything just worked together.

After installing emacs and copying my global .emacs.d/ things are just working. After a `yum install xmonad` I am able to login under xmonad. I see they’ve even included a .xmonad/ in my home.

The Fedora developers must have a picture in mind of how the system should be and it appears that all packages have been designed with this picture in mind.

I don’t know what this means for FreeBSD. The craftsmanship of the FreeBSD project never ceases to amaze me. I love just setting my variables in rc.conf. However, it seems to me that more work needs to be done to integrate binary and source versions.

Some ports build against the kernel source. Why is my /usr/src not updated by freebsd-update? (Update: yes, it can update /usr/src.)

If FreeBSD could solve the Package vs Ports dilemma, and if packagers provided more apparent defaults for settings then FreeBSD would be a very strong desktop. I’m sorry that everything I plug in isn’t automagically configured, but doing that is complex and what is convenient for me may be inconvenient for the masses.

In the coming days, I do see myself spending some time contemplating the differences in experiences. FreeBSD truly is the unknown giant.

Mp3’s and blog posts.

Word on the street is that Morningsiders would like to embed MP3 files in their posts.

This sounds like a cool idea, so I’ve sat down and see that WordPress can already do something like this:

brobob

Sounds good. How to do it?

Step 1, have a mp3 file. =) That’s easy.

Step 2, choose “Upload/insert” from the post screen.
The Upload/Insert icon

Step 3, choose your mp3. Enter some details about it and select enter into post.

Step 4, enjoy.

Helping a little, old (rich) lady

One day, on the drive home from work, I witnessed an elderly lady in battered clothes struggling. Her wheelie basket, piled with laundry, had gotten stuck. In an unexpected and unprecendented pang of empathy, I stopped and offered assistance. Delighted to have me after, apparently, struggling for some time I was quickly able to pop the stuck wheel out of its prison (the sewer grate).

Preparing to leave, she stops me. “Before you leave, I have a reward to offer!”

She has my attention now. “I can give you 1,000,000 dollars or I can give you thirty daily payments starting today of one penny. I shall double each subsequent payment.”

To be kind, I offer the “lower” payment of a penny. I don’t need any old ladies millions of dollars. She gives me a penny and departs.

Sitting back in my office, I stop and think about what I’ve done. I realize that each day she pays me (for all thirty of them) I can expect 2^{day-1} cents. Considering it further, I begin to understand that the miracle of a doubling scheme such as this is that every subsequent day I will receive exactly one more cent than all the previous days combined.

A few weeks later, it now takes a rather large dump truck to deliver the little copper coins. Wondering how many dollars this all amounts to I quickly scribble on a pad of paper: \frac{2^{30}}{100} = \$10,737,418.

Just something to remember when you see an elderly lady in need.