Showing posts from March 6, 2011

Programing Style: Variable Naming: English Words Considered Harmful

Perm url with updates: Style: Variable Naming: English Words Considered HarmfulXah Lee, 2011-03-11This page is some thoughts on variable naming in writing computer programs.In emacs lisp, i usually use camelCase for my local variables. Here's a example: (defunread-lines (filePath) "Return a list of lines of a file at FILEPATH." (with-temp-buffer (insert-file-contents filePath) (split-string (buffer-string) "\n" t))) Some lisp coder question the use of camelCase, because it is not standard elisp style. Here's the reason why i'm using camelCase, and some thoughts about naming of variables.Distinction from Language KeywordsIt provides a easy way to distinguish variables from built-in symbols. Particularly because of the fact that emacs-lisp-mode's coloring scheme is not full. (See: Emacs Lisp Mode Syntax Coloring Problem.)In particular, all my local variables are in camelC…


palimpsestDay by day and almost minute by minute the past was brought up to date. In this way every prediction made by the Party could be shown by documentary evidence to have been correct, nor was any item of news, or any expression of opinion, which conflicted with the needs of the moment, ever allowed to remain on record. All history was a palimpsest, scraped clean and reinscribed exactly as often as was necessary. — 1984, George Orwell Deleting History: Why Governments Demand Google Censor the Truth (2011-03-11) By Lauren Weinstein. @ Source

emacs lisp: unicode to ascii words

Perm url with updates:'s a more polished solution. The “asciify-word-or-selection” is a command. It works on current word or text selection. (defunasciify-string (inputstr) "Make Unicode string into equivalent ASCII ones. For example, “passé” becomes “passe”. This function works on chars in European languages, and does not transcode arbitrary unicode chars (such as Greek). Un-transformed unicode char remains in the string." (let () (setq inputstr (replace-regexp-in-string "á\\|à\\|â\\|ä\\|ã\\|å""a" inputstr)) (setq inputstr (replace-regexp-in-string "é\\|è\\|ê\\|ë""e" inputstr)) (setq inputstr (replace-regexp-in-string "í\\|ì\\|î\\|ï""i" inputstr)) (setq inputstr (replace-regexp-in-string "ó\\|ò\\|ô\\|ö\\|õ\\|ø""o" inputstr)) (setq inputstr (replace-regexp-in-string "ú\\|ù\\|û\\|ü""u" inputstr)) (setq …

GNU Emacs Default Keybinding

Perm url with updates: Curious Look at GNU Emacs's 1000+ Default KeybindingXah Lee, 2011-03-10 In Emacs, there's a command “describe-bindings” 【F1b】. By default, there are a total of 1353 bindings. In this page, let's look at what they are. (you can get the list by calling “describe-bindings” in emacs, or see this file: gnu_emacs_keybinding.txt.)(A bit tech detail: “describe-bindings” lists all keyboard shortcuts that's available to you in your current setup. The exact result depends on the current major mode, minor modes, and your custom keybinding.)The Space-cadet keyboardMany of the bindings refer to keys on lisp machine keyboard. So, here's a photo of lisp keyboard for reference. The Space-cadet keyboard, one of the early Lisp Machine keyboards. Source (For more lisp machine keyboard photos, see: lisp keyboard photos.) Alt KeyIt has 137 bindings starting with the notation A-. A-/ Prefix Comman…

How I lost my faith in Lisp

Perm url with updates: I lost my faith [in lisp], Ron GarretA old comp.lang.lisp newsgroup post has been dug up by Hacker News. The post is: How I lost my faith (2002-02-19) By Erann Gat. @ Source read it at the time it was posted, and just read it again. Note that its author, Erann Gat (aka Ron Garret), is somewhat a controversial figure in comp.lang.lisp. I think primarily having to do with the nasty fight between him and Erik Naggum. Also, i don't know the details, but he also doesn't get alone with another lisp regular Kenny Tilton. Over all, i'll say i agree with his post there, that lisp isn't that great a language today, as i've expressed many times in the past years. My path to lisp is similar. For me, lisp started in 1998. First, there's awful amount of admiration and respect from me, even just for the association with the phrase “artificial intelligence”. Though, i never really got to the lisp-l…

Unicode Char Equivalence Support in Browsers

Perm url with updates: Char Equivalence Support in BrowsersXah Lee, 2011-03-09It's very nice, in Google Chrome and Safari, that if you type 3 dots “...” in the find box 【Ctrl+f】, it'll find the unicode character ellipsis “…”. Here's some other equivalences:e ⟺ éa ⟺ ài ⟺ în ⟺ ñu ⟺ üothers accented letters e.g. ÀÁÂÃÄÅÆ Ç ÈÉÊË ÌÍÎÏ ÐÑ ÒÓÔÕÖ ØÙÚÛÜÝÞß àáâãäåæç èéêë ìíîï ðñòóôõö øùúûüýþÿstraight double quote ⟺ curly double quote 1 ⟺ ①2 ⟺ ②2 ⟺ ③... ⟺ …any char is equivalent to its fullwidth version. e.g. () [] {} vs () [] {}, and fullwidth forms of punctuations “, . ; ? !” etc.I think some of these are based on Unicode equivalence but not all.Note: Firefox, Opera, does not support this. It's funny that IE8 support some of them. If you type “1”, it'll find “①”, but if you type “e”, it won't find “é”. (all browsers tested are latest public versions as of 2011-03-09.) You can test by 【Ctrl+f】 right on this pa…

music video: Sugababes - round round

Perm url with updates: - Round RoundXah Lee, 2011-03-09A fantastic dance-pop eletronica song. Heard it first from a home recorded sex tape's background music. 〔〕Sugababes - Round Round. Title: Round Round Date: 2002 Singer: Mutya Buena, Heidi Range, Keisha Buchanan (Sugababes) Here's the lyrics. Round, round baby round, round Spend the night on me I don't need no man Got my kicks for free Realise the vibe gonna be down low (?) I don't need nobody got my honeys When I go round, baby round round Spend the night on me I don't need no man Got my kicks for free When you stare in my face You're messing with my brain If you're trying to convince me Then you better think again If you move to the music The music's got to give If its too complicated That's the way I want to live If you hate me I will show you How to break me Into …

Google js lib Closure

Discovered Google javascript library Closure Library. It's used by many of Google's services (e.g. gmail, maps, docs, sites, books, reader, blogger, picasa) Worth looking into. It's a heavy weight one. It even supports drag'n'drop. At other most popular js lib is jQuery. But in comparison, it's peanuts. See: jQuery Basics Tutorial.

emacs sgml-delete-tag bug

sgml-delete-tag bugdiscovered a bug in html-mode. If you have this: <p>some'</p> and your cursor is at the beginning of line, then press 【Ctrl+cCtrl+d】 (sgml-delete-tag), it'll also delete the apostrophe.This is “GNU Emacs 23.2.1 (i386-mingw-nt6.0.6002) of 2010-05-08 on G41R2F1”

some problems with emacs slowdown

Perm url with updates: some problems of slowdown (tabbar, font)Xah Lee, 2011-03-08Sometimes i noticed that emacs slows down. The problem is hard to track. Here's my experiences.tabbar-mode slowdown. I've noticed in past years that tabbar-mode slows down emacs. Just re-affirmed it today. In today's case, it significantly slows down your emacs if you have lots of files open. For example, i have 300 files open. (they are opened by batch Find & Replace (dired-do-query-replace-regexp)) Then, calling “M-x” (execute-extended-command) takes 3 seconds to show the prompt. Opening a file also take a few seconds. This is not always reproducible though. For example, right now i still have 300+ files open, but the problem went away.If you have desktop-save-mode on, and you have 300 files from last session. Starting emacs (with tabbar-mode one) can take a long time.Set Keyboard Repeat Rate to Test Slow Down. When slow down happens,…

google computer programing style guide

Perm url with updates: Google computer programing style guide. It has style guide for lang including: C++, JavaScript, Objective-C, Python, XML. At ones am interested are:javascript style guidepython style guidexml style guideI spent 30 min to read the js one. Haven't finished yet. Very good reading. If you are not a expert of the lang, you learn something about the lang too.I'll be reading them all.

Emacs: Zap Gremlins (UNICODE chars ⇒ ASCII)

Perm url with updates: Zap Gremlins (UNICODE chars ⇒ ASCII)Xah Lee, 2011-03-07This page shows a little function that changes unicode string into ASCII. For example “passé” becomes “passe”, “voilà” becomes “voila”.When refactoring my elisp code last week, i split out this little function. It turns unicode chars into roughly equivalent ASCII ones. I needed this because the open source dictionary will choke on words with unicode chars. (See: Emacs Dictionary LookupProblems of Open Source Dictionaries.) I remember, in the popular Mac editor BBEdit i used 10 years ago before emacs, there's such a command in the menu called “zap gremlins”. Though, i'm not aware there's one in emacs, but might be. Anyway, here's the code: (defunasciify-string (inputstr) "Make unicode string into equivalent ASCII ones. Todo: this command is not exhaustive." (let () (setq inputstr (replace-regexp-in-string "á\\|à\\|â…

Motorola TV Ad: Apple 1984

Perm url with updates: TV Ad: Apple 1984Xah Lee, 2011-03-06“Welcome to the new decade: Java is a restricted platform, Google is evil, Apple is a monopoly and Microsoft are the underdogs” — Phil Nash 2010-08-14This is just too good a commercial. Motorola pokes fun at Apple.“Motorola - Empower the People” Notice that ubiquitous white iPad earphone? That's Apple.Here's Apple's TV ad in 1984.Apple's 1984 commercial. In the 1980s, the Big Brother in computing industry alludes to IBM.Nineteen Eighty-Four is dystopian novel by a George Orwell. It brought us the term Big Brother — a government that practices total surveillance. For a short essay by Orwell, see: Politics and the English Language. A fantastic scifi movie that depicts Big Brother in a similar way is Brazil (film) (1985), directed by Terry Gilliam. amazon Is Microsoft a Monopoly?On Microsoft HatredSoftware Freedom is Free Speech or Free Beer?Sexual Consent …