Tuesday, March 27, 2007

aps as basic proxy authenticator

You can use aps as an authenticator for both ntlm and basic proxies. Download this unofficial bug-fix release which supports both ntlm and basic proxies



aps098.zip

Note that the official aps page still has the bugs that is fixed in the version that I released. To use the official version, you need to replace the config file and the lib/basic_auth.py files from the original aps with my bug-fix release.

Tuesday, March 20, 2007

These are a few desires that just poped into my mind a few days ago:


  1. Get a macpro with at least 4GB RAM, 250GB hard disk and 24inch monitor.

  2. Contribute to the linux kernel.

  3. Work at Apple for at least a year to see how great products are built.



I have no idea how childish I will think these are when I'm older. And hence I have no idea how long this post will remain.

command-on-buffer

After reading the article on javascript bookmarklets in daringfireball.net, I wanted to make emacs do something that BBEdit and TextWrangler do: Take the buffer and give it to the shell command and replace the buffer's contents with its output.

I didn't know if it was implemented in emacs and got to working on it and one hour later I produced this emacs lisp script:


(defun command-on-buffer (command)
(interactive "MEnter command: ")
(shell-command-on-region (point-min) (point-max) command (current-buffer)))

(global-set-key "\C-c\C-s" 'command-on-buffer)


I was initially bent on using call-process-region but somehow it gave errors when I was running interpreted python or perl code. I remember the python code giving syntax error at reading stdin. I don't know whether it thought there was no stdin at all or if it was empty. However normal commands like "cat" worked without any problems.

So, I was looking for other programs which used call-process-region and since I was editing a python file (which was what I was testing the elisp function on), I recognized that the python-mode must use something like that for sending the buffer to the python shell.

I grep'd for a while in python-mode files and found out that shell-command-on-region is like call-process-region but it could execute shell commands and looked for its documentation (in emacs itself - it IS the best editor in the world after all). And yes, it did exactly what I wanted - it gave arbitrary text in the buffer to the shell command and could put the output in any buffer I chose. Writing the function then was very simple as you can see.

It doesn't give selected text to the command yet. I do plan to implement that too - but only when I have a real need or inspiration and if I find that emacs indeed doesn't have any functions to do what I want. For that I need a way to see if any text is selected, get the selected text and then ask shell-command-on-region to replace only the selected text. I don't think shell-command-on-region does that and if that is the case, I'll have to put that in a buffer and insert its contents into the selected region.