Sunday, November 9, 2008

Microsoft and Evangelism

What does Microsoft have to do with Christian churches?

Nothing, except that they both exhibit a certain behaviour: aggressive evangelism. Both operate in ways that tend to reduce freedom of choice and make it hard for people to choose alternatives. Their behaviour on this count is similar because their motivations are similar. Both wish to monopolize society.

When Google became popular in search, Microsoft tried to beat Google at search. When Google began its mail service, Microsoft tried to beat Google at mail. When Google began getting into maps, books, Microsoft put some serious effort into the same fields. This is reminiscent of church planting in Indian villages.

When a Hindu temple undertakes a major activity that might get people interested (such as renovation of a temple or appointment of a new priest), Christian organizations often rush to plant a church and engage in a publicity and incentive blitz to attract villagers.

Microsoft has been doing the same thing in the tech domain. If there's any tech development that attracts people, Microsoft tries to enter it in a big way in order to attract customers to the Microsoft fold.

Both Microsoft and church have practically unlimited financial resources compared to their competitors, and both are extremely resistant to the existence of alternatives.

It's no secret that I'm on the side of Freedom here: freedom as in free software, and freedom of religion. Makes me wonder: do Microsoft vs. open source and evangelism vs. freedom of religion have the same solution?

Saturday, November 1, 2008

Automatically Inserting Matching Parentheses for LaTeX in Emacs

My use of emacs varies, but a good chunk of my time is spent writing in LaTeX for mathematical formulae. AuCTeX simplifies my life quite a bit, and whizzytex makes it awesome. But one feature that would really save me some typing is auto-completion of matching parenthetical symbols. In LaTeX, such matching delimiter pairs are $$, [], {}, \{\}, \left\{\right\}, \left(\right), etc. I found a major mode called Ultratex that does exactly this (and much more), but unfortunately it replaces AuCTeX rather than augment it, and isn't maintained any more.

Here's some trivial emacs lisp code for a minor mode that accomplishes this. You can easily modify it yourself to add or remove simple matching completions. You can put it directly in your .emacs file, or in a file called dlmins.el, and add the line

(load "/path/to/dlmins.el" t t)

to load it. If you want this to be activated every time LaTeX is fired up, put the following line in your .emacs file:

(add-hook 'LaTeX-mode-hook 'dlmins-mode)

To toggle the mode manually, use command M-x dlmins-mode. Here's the code for the minor mode.


;;; dlmins.el -- Trivial minor mode to insert matching LaTeX
;;; delimiters automatically.
;; Copyright (c) 2008 Rajeev Ayyagari

;; Author: Rajeev Ayyagari
;; Keywords: Parenthesis matching
;; Version: 0.01 of Sat Nov 1 11:22:44 EDT 2008

;; This file is not part of GNU Emacs.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Minor mode: dlmins-mode
;;
;; Entering a left-parenthetical symbol causes the corresponding
;; right-parenthetical symbol to be inserted automatically, and point
;; is positioned appropriately.
;;
;; To use, place this code in a file called dlmins.el and add the line
;;
;; (load "/path/to/dlmins.el" t t)
;;
;; to your .emacs. To make the mode start automatically when a latex
;; document is opened, add the line
;;
;; (add-hook 'LaTeX-mode-hook 'dlmins-mode)
;;
;; to your .emacs after the above "load" line. Manually toggle (enable
;; or disable) the mode using M-x dlmins-mode.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Set up keymaps and list of delimiter pairs.
(defun dlmins-setup ()
"Initialize delimiter auto-insertion."
(interactive)
;; Order matters in the list below!
;; The rule is if STR2 is a suffix of STR1, then STR2 should come
;; after STR1.
(setq dlmins-dlm-list
'(
("\\left\\{" "\\right\\}")
("\\{" "\\}")
("\\frac{" "}{}")
("{" "}")
("\\left(" "\\right)")
("(" ")")
("\\left\\|" "\\right\\|")
("\\|" "\\|")
("|" "|")
("\\left|" "\\right|")
("\\left[" "\\right]")
("[" "]")
("$" "$")
))
(define-key (current-local-map) (kbd "{") (lambda () (interactive) (insert "{") (dlmins-pair)))
(define-key (current-local-map) (kbd "[") (lambda () (interactive) (insert "[") (dlmins-pair)))
(define-key (current-local-map) (kbd "(") (lambda () (interactive) (insert "(") (dlmins-pair)))
(define-key (current-local-map) (kbd "$") (lambda () (interactive) (insert "$") (dlmins-pair)))
(define-key (current-local-map) (kbd "|") (lambda () (interactive) (insert "|") (dlmins-pair))))
;; Called when left delim is typed, finds and inserts appropriate
;; right delim.
(defun dlmins-pair ()
"This should be called as soon as an opening delimiter has been typed.
When called, looks backward to see which delimiter has just been typed.
It inserts the matching closing delimiter.
Eventually it will be smart enough to take care of \left and \right as well."
(interactive)
(catch 'getout
(mapcar
(lambda (dlm)
"If expression before point matches open dlm, insert close dlm."
(if (looking-back (regexp-quote (car dlm)))
(save-excursion
(insert (car (cdr dlm)))
(throw 'getout nil))))
dlmins-dlm-list)))
;; Toggle the parenthesis matching mode
(define-minor-mode dlmins-mode
"Minor mode LaTeX matching delimiter auto-insertion. use
\"dlmins-mode\" to toggle."
:init-value nil
:lighter " DlmIns"
:keymap '()
(dlmins-setup)
)

Sunday, October 12, 2008

Is User-Friendly the Way to Go?

Everything in the computer world: search, social networking, operating systems, even system administration, is going towards user-friendliness. User-friendliness is the carrot used by various manufacturers to lure consumers towards their products. It relies on humans' inherent laziness: if you can do something more easily, why do it the hard way?

That is also a good argument for user-friendliness: why expend effort (i.e. incur costs) learning how to do things the hard way when the same things can be done the easy way (i.e. at lower cost)?

But there is a hidden cost. It is hidden in the words "same things" above. I think there are things that cannot be done without using more sophisticated methods than the basic, user-friendly, point-and-click methods. How would you rename all files in your system with the extension ".bin" to ".exe" in a user-friendly fashion? This is just an example of a common task. If people could all write basic code, there would be a lot of advanced tasks that would become common. This would lead to greater complexity in the use of computers, and hence faster innovation.

As an analogy: It takes more effort to learn 5th grade math than to learn 1st grade math. 1st grade math is more user-friendly than 5th grade math. But you can do more with 5th grade math than with 1st grade math. Everyone should learn 5th grade math. However, only specialists need to learn masters-degree level math.

So the question is: where are consumer digital products currently poised? If they are poised at the 10th or 12th grade level, there is no need to educate people any more; only specialists need to learn anything more from this point on. If they are poised at the 1st or 5th grade level, people should be expected to learn more; that will lead to more effective use of digital resources.

Wednesday, October 8, 2008

Open Source versus Innovation?

I'm reading The World is Flat by Thomas Friedman, and he asks a question about open source that really made me think. What is the motivation for innovation if everybody gives their innovations away for free and nobody gets paid for their innovations, which is what open source seems to suggest?

I don't have a good answer, but it seems to work. As Friedman himself points out, many important innovations have come out of open source, including the Apache web browser. I would go so far as to say that most innovations in the field have come from not-for-profit efforts. Google's entire search infrastructure runs on Linux; Amazon's entire web presence runs on Apache. It's as real as it gets.

The question is tied to (and perhaps motivated by) statements from Microsoft bigwigs. Here is one that Friedman quotes (the inserts are his):
You need capitalism [to drive innovation.] To have [a movement] that says innovation does not deserve an economic reward is contrary to where the world is going. When I talk to the Chinese, they dream of starting a company. They are not thinking, 'I will be a barber during the day and do free software at night.'... When you have a security crisis in your [software] system, you don't want to say, `Where is the guy in the barbershop?' -- Bill Gates
But Bill Gates is hardly in a position to talk of innovation. Microsoft has not made any significant technical innovations in the last 10 years. Windows Vista's UI is (feature-wise) just a bloated version of Windows 95, with some bling. Microsoft's innovations are almost entirely on the business end: it has figured out effective ways to stifle innovation by competitors. So Bill Gates talking about what drives innovation is like a thief lecturing about honesty.

Gates' comment about security is even more perplexing in light of the extensively poor track record Microsoft has in security. Open source alternatives are far more secure in every way than anything Microsoft has. Maybe the reason you don't want the guy in the barbershop is if you know there's something wrong with the security, it's probably the Microsoft guy who's responsible.

But what Gates says is not really relevant here. None of this actually answers the question: how can you justify, theoretically, the claim that innovation can be sustainably executed within Open Source frameworks?

I don't have a good answer.

Friday, September 26, 2008

PGF and TikZ

I guess I'm just completely out of touch, but there's an excellent package that allows you to draw sophisticated graphics within LaTeX (using a graphics programming language) I hadn't heard of till recently.

It's called PGF, and the component you use in your LaTeX/TeX source code is called TikZ. You enter simple LaTeX-style commands to tell it what to draw, in an environment right in your (La)TeX code, and it does the job for you. The excellent user manual can be found here, including instructions for installing and a tutorial. (If you're a Ubuntu user, of course, there's already a package you can install with a few clicks.) Great examples can be found here. Wow! What a package.

Saturday, August 9, 2008

Emacs Word Wrap

Real word wrapping in emacs isn't automatic, but here's how it can be done. I found these instructions at http://lispy.wordpress.com/2007/07/12/dark-secrets-of-emacs-word-wrapping/. It's not perfect; despite the comments on that website, I don't yet know how to make word-wrap work after vertical splitting. First, get longlines.el and put it somewhere. Then, add the following lines to your .emacs:

(load "/path/to/longlines.el" t t)
(autoload 'longlines-mode "longlines.el" "Minor mode for editing long lines." t)
;; Uncomment the next line to wrap by default in text mode
;;(add-hook 'text-mode-hook 'longlines-mode)

To activate manually, do M-x longlines. More info at http://www.emacswiki.org/cgi-bin/wiki/LongLines.

Adding An Emacs Menu

Here's some template code for adding a menu item to the main emacs menu bar. I don't know hos this works; I just use it as a template!

;;;;;;; Add items to menu bar
(modify-frame-parameters (selected-frame) '((menu-bar-lines . 2)))
;; Make a menu keymap (with a prompt string)
;; and make it the menu bar item's definition.
(define-key global-map [menu-bar MyMenu] (cons "MyMenu" (make-sparse-keymap "MyMenu")))
;; Define specific subcommands in this menu.
(defun MyMenu-linkify() (interactive) (replace-regexp "^\\(.*\\)$" "\\1
"))
(define-key global-map
[menu-bar MyMenu linkify]
'("Linkify" . MyMenu-linkify))
(define-key global-map
[menu-bar MyMenu truncate]
'("Truncate em" . toggle-truncate-lines))

Sunday, August 3, 2008

Linux Brain Games

These involve the mind in some way... I like to do Blinken and Gnomine.

Chess. These engines are way too hard for me.
  1. Gnuchess
  2. Crafty
Memory
  1. Blinken
Quick Thinking
  1. Gnomine
  2. KSirtet
  3. Tetravex
  4. Gnome Sudoku
Uncategorized
  1. gtans (Tangrams)
  2. Code Breaker / Gnomermind (Mastermind clones)
  3. Klotski/Gnome Klotski
Free Online
  1. Happy Neuron free games
  2. MyBrainTrainer has a test and one free puzzle every month
Commercial
  1. The Amazing Brain Train (has a demo)

Wednesday, July 30, 2008

I Love Evince!

Evince, the Gnome document viewer under Ubuntu 7.10 and up, is simply a great piece of software. It has some simple features which enhance its usefulness for academic work.

Incremental search instead of boring-old-search make evince my favourite viewer for almost any type of document it supports.

The extra feature I use most often is "Open a Copy" in the File menu. This opens up another instance of evince displaying the same file, very useful when you need several different pages of the document open at the same time.

Another useful related feature is, if you click using the middle button while following a PDF link, the link opens up in a new window (just like in Firefox). That way you don't lose the original page.

Of course, evince could be made better. Here's my wish-list:
  1. Add a cycle-through-bookmarks feature for the cases when I want quick browsing in one window instead of many
  2. Add an "Open a Copy" toolbar button
  3. The version of evince I'm using on Ubuntu 7.10 doesn't work at all with the print server CUPS; maybe this is already fixed in the newer versions
  4. DVI files are blurred (or maybe over-antialiased)
  5. We need browser-style back and forward buttons in addition to the page back and page forward buttons, so we can follow links more easily
  6. Would be nice to be able to place two arbitrary (not just adjacent) pages side-by-side.
  7. Alternatively, allow left-right split window with synchronized scrolling made possible (i.e. scrolling one scrolls the other by the same amount)
  8. Add a "search for full word only" option to the incremental search
  9. More when I think of it!

Monday, July 28, 2008

Whizzytex on Ubuntu 7.10

Whizzytex is a pretty nifty application that updates a compiled TeX pane in real-time as you type into emacs. Under Ubuntu 7.10 it comes as a package in the repositories.

With my installation (on a Thinkpad t61) I've had an annoying problem: every few seconds, emacs will freeze completely for a 1-5 seconds (presumably doing a slice compilation or some such thing for whizzytex). This can happen right in the middle of a yank, and it can happen ten times a minute.

Here's my solution, though I can't explain why it works: put the line

(setq whizzy-load-factor 10)

in your .emacs file. The problem still occurs but very occasionally (once in 5-6 minutes, which I can live with). Whizzy is a lot more responsive now as well.

There is one downside: this really increases processor usage. My laptop runs hot and the battery doesn't last long when I have the load factor set high this way.

Wednesday, June 11, 2008

Backup (Part II)

I listed some requirements that I have for backup software for a single workstation in an earlier post. I seem to have found a solution that has many of those properties, though not all. It is called SBackup (for Simple Backup) and I am running it on Ubuntu 7.10. (I won't be shifting to 8.04 until all the kinks are worked out, or they invent hibernate for Linux.) It really is simple and runs very well in my situation.

Here's how SBackup satisfies my requirements:

  1. SBackup has a modicum of network awareness; it can backup over an SSH or FTP connection in addition to a local directory.
  2. SBackup can do incremental and full backups. By default every backup (except the first) in SBackup is an incremental backup. The administrator can specify a schedule for full backups, such as a full backup every 21 days.
  3. SBackup has pretty good scheduling. The frequency of full and incremental backups can be controlled. A purging schedule can also be set up, for example: keep all backups for the last week, keep one backup a month for the last year, keep one backup every 6 months for years before that.
  4. SBackup's backups are software independent. This was a major problem I had with DAR, which I was using before SBackup: DAR archives couldn't be read without DAR. SBackup just uses tarred, gzipped files. So I have no worries about how I'm going to access the files in backup if SBackup is discontinued or unavailable in the future.
  5. SBackup doesn't have encryption, but right now this is not crucially important to me.
In addition, SBackup really is very simple to configure, and it works silently behind the scenes.