CSS1 And CSS2 Differences

Perm url with updates: http://xahlee.org/js/css2.html

CSS1 And CSS2 Differences

Xah Lee, 2005-11, ..., 2010-08-21

This page shows the primary features in CSS2 not in CSS1. If you are not familiar with CSS, see: CSS Basics. If you know the basics and want a practical examples of css tag matching supported by all current versions of browsers, see: CSS Tag Matching (Selector) Syntax.

CSS1 is published in 1996. CSS2 is published in 1998. As of today, all major browsers supports pratically 99.9% of CSS2. CSS3 is in works but not out yet.

Note: there's no way to specify a CSS version number in your HTML markup. Just test with browsers if you must use new features.

Tag Matching

CSS2 provides more powerful ways to associate styles with tags.

“*” matches any tag.

/* make everything red */
* {color:red}

“>” means parent-child relationship.

/* p inside div of class header inside body */
body > div.header > p {color:red}

Space can be used to specify that a tag must have other tags as its ancestor.

/* make any div.x inside table red */
table div.x {color:red}

“+” can be used to specify some restriction on same level tags.

/* if p comes immediately after img, make the text red */
img + p {color:red}

Pseudo-class: link, hovering, focus, first child...

There are special syntax to match some mouse hovering, focusing, behaviors. (these “:xxx” forms are called pseudo-class.)

a:link {color:red}
a:visited {color:green}
a:hover {color:yellow}

div.myButtonX:hover {color:red}
div.myButtonX:active {color:green}
div.myButtonX:focus {color:yellow}

“:first-child” can be used to match a tag only if it is the first child.

/* make first line of list red */
li:first-child {color:red}

“:first-letter” and “:first-line” can be used. e.g.

p:first-letter {color:red}
p:first-line {color:blue}

For detail, see: CSS “first-letter” and “first-line” Example.

Matching Tags with Attributes

Existance of a Attribute

You can match the existance of a attribute, by the syntax “tagName[attributeName]”.

/* if a link has a “title” attribute, render the link red */
a[title] {color:red}

Matching Attribute Values

You can match a tag's attribute's value, using the syntax “tagName[attributeName="valueString"]”.

/* if a image's alt attribute is “icon”, set a red border */
img[alt="icon"] {border:solid thin red}

Matching a Word in the Attribute's Value

A word in the value of a attribute can be matched, by using the operator “~=”.

/* if a image's alt text has the word “house” in it, set a red border */
img[alt~="house"] {border:solid thin red}

Layout, Layers, Tabular Format, and Text Flow

A very important feature in CSS2 is the ability to do layout and with layers.

Layout and Layers

Layout is to specify the position of each item, in a absolute coordinate or relative to its parent. In HTML, It is often done in practice by using Table tag with width attribute.

In CSS2, layout are done with attributes “display” and “position”. The value fo “position” can be “absolute” or “relative”. There's also attributes “top”, “bottom”, “left”, “right”, and each's value is a length unit. Example:

AAA {display:block;}
BBB {display:block; position:absolute; top:300px, left:50px}
CCC {display:block; position:relative; left:100px}

Examples: CSS Layout and Layers

Example: Fixed Widget with Cascading Style Sheet

CSS2 allows one to specify which element should be displayed on top of another (hiding the one behind). This is done with the “z-index” attribute. The parameter for z-index are integers. The larger the integer, the more front it is.

BBB {display:block; position:absolute; top:300px; z-index:50}
CCC {display:block; position:absolute; top:300px; z-index:2}

Another useful directive is the “visibility” attribute. It can be set to “visible” or “hidden”, giving more control of CSS2's layout capabilities. This can be used in conjunction with javascript to fruitful effects. For example, if you have tabs on a page, clicking a tab can automatically make the main area content associated with that tab visible, while make all content associated with other tabs hidden.

The CSS2's layering and layout feature is used to implement pop-up tooltips.

Tabular Format

• CSS2 has the ability to specify a table format. This in conjunction with “position” and “z-index” can achieve may web-design effects. For example:

* {border: solid}
AAA {display: table}
BBB {display: table-row}
CCC {display: table-cell}
DDD {display: table-cell}

will render the following XML code:


like a table as in HTML:

<table border="1">

See a example here: Tabular Formatting with CSS2

“white-space” has a new behavior spec: nowrap. Example:

BBB {white-space: normal}
CCC {white-space: pre}
DDD {white-space: nowrap}

Example: CSS Text Wrapping.

Changing Content

Text can be inserted at the beginning or end of specified tag, using “:before” and “:after”. e.g.

AA:before {content:'Proof: '}
AA:after {content:'End of Proof.'}

for element such as:

<AA>because 1+1 is 2, therefore I win.</AA>

will become

<AA>Proof: because 1+1 is 2, therefore I win. End of Proof.</AA>

Example: css_before_after.html

Color, Background image, Tex decoration, Font

CSS2 supports color names of Browser's GUI. For Example:

A {color:AppWorkspace}
B {color:ButtonFace}
C {color: ButtonHighlight}
D {color:ButtonText}
E {color:CaptionText}
F {color:Highlight}
G {color:HighlightText}

Example: CSS2's System Colors.

Several features are new in CSS2 for background image. It can be repeated, or just horizontally or vertically. It can also be fixed, so that scrolling doesn't move it. Example:

AAA {background-image:url("some.gif")}
AAA {background-repeat:repeat-x}
AAA {background-position: top}
AAA {background-attachment: fixed}

A new tag text-shadow can have size and color.

BBB {text-shadow: 5px 12px red}

Font can now be specified based on Browser's setup. e.g.

AAA {font:caption}
BBB {font:small-caption}
CCC {font:status-bar}

Mouse Pointer or Cursor's shape can be specified. e.g.

AAA {cursor: crosshair}
BBB {cursor: pointer}
CCC {cursor: move}
DDD {cursor: e-resize}
EEE {cursor: text}
FFF {cursor: wait}
help {cursor: help}
uri {cursor: url(".../pointer.gif")}

Switching from Mac/Unix To PC/Windows

Perm url with updates: http://xahlee.org/mswin/switch_to_windows.html

Switching from Mac/Unix To PC/Windows

Xah Lee, 2009-05-26, 2009-06-20

I bought a PC with Windows today, and am switching to Windows from my 19 years of Mac experience with 10 years of professional unix computing. This page tells the story. This document is partly a blog documenting why i switch from Mac to PC.

Why I Switched

I have a aging Mac. It is a IMac G5 (iSight; MA063L/A) bought in late 2005. It is the last iMac using the PowerPC chip.

The machine is great, but is 3.5 years old. I needed a new machine. I went to local shop Fry's Electronics and was just gonna get the new Mac Mini that Apple just released this month. The cheapest Mac Mini is $600. Looking in the store, you find that a PCs for the same price has about 3 times the hardware power. Or, for the same hardware muscle, the PC is about half the price.

Mac vs PC
Mac mini (MB463LL/A)
PC (Campaq Persario SR5710F)
PC (HP Pavilion A6750F)
CPU2.0 GHz
Intel Core 2 Duo
(64 bits, dual-core)
2.3 GHz
AMD Athlon 64 X2 4450e+
(64 bits, dual-core)
2.3 GHz
AMD Phenom X4 9650
(64 bits, quad-core)
Hard Disk120 GB250 GB750 GB

By the above comparison, you can see that the Mac is shit, and they've been in that state in the past about 6 years. The Mac OS X was beginning to save Mac since 2002, together with the pretty and robust and inexpensive first IMac (“Bondi Blue”) that debuted in 1999. The Mac had a good time from about 1999 to 2003. But since the PowerPC slowness fiasco and hence the Intel "SWITCH". The gap of price/raw-power between Mac and PCs is getting wider and wider. Apple is too busy becoming a fashion and multimedia company with its iPod and iTune successes.

Software quality have always been a major part of Mac's selling point, especially in the early 1990s. The whole desktop publishing revolution. The classic Mac OS with its revolutionary graphical user interface, Photoshop, Freehand and Illustrator, PageMaker, laser printer, Hypercard, Mathematica, etc. However, these days Microsoft's software tech, in scale and quality, is quite ahead of Apple, witness the .NET, F# lang, PowerShell, Direct3D, Silverlight, etc, and the operating system itself is no worse than Mac's, starting with Windows NT in the late 1990s and its descendants 2000, XP, Vista. And, almost all of the best so-called Desktop Publishing software that started life on the Mac in the early 1990s have moved to Windows as their main platform in the past decade (e.g. Mathematica, Photoshop, Macromedia stuff, Bryce, several 3D modelers, DenebaDraw, FrameMaker, QuarkXpress ...). In fact, many no longer even produce Mac versions.

I'm tired of Mac being the second rate citizen for everything. Latest Java version comes 0.5 or 1 year later than Windows, similar for Google Chrome, Google Earth, Adobe Flash, Second Life ... often come in crippled version and late. All IM chat clients on Windows such as MSN, AOL, Yahoo, support voice or video chat, while most of these company's Mac versions still don't. This applies to just about any software. You are lucky if there is a Mac version. (For example, when i need to research virtual world technologies such as Entropia Universe, IMVU, There (internet service), Active Worlds, none have Mac versions. When i want to try some software synths, juggling simulation software, go board game networks... Mac user's options are severely limited.)

In general, not only Mac buys you less hardware muscle, but the Mac version of software is usually slower than Windows version running on similarly powered hardware, because the software gets less development time and less optimization. (e.g. Javascript, Java, Flash, etc.) Commercial websites often have problems when accessed with Mac browsers, since many of them only test it with Microsoft's Internet Explorer browser. (not Apple's fault, but fact of life.)

I have owned Macs since 1991, and was a DEDICATED fan all thru the 1990s. I started to use Windows at work for 8 hours a day from 1999 to 2002. I also own a fancy Windows labtop from about 2003 to 2005, besides owning more than 1 Apple computers. I'm pretty familiar with Windows as a user, but not as a programer or sys admin. However, since about 2006, i haven't touched Windows. I'm a unix sys admin professional and programer in web app and scientific computing fields. Even having used Windows for years in the past, but never did sys admin on Windows nor done any programing with Windows's technologies. I never cared to learn any Microsoft techs. (See: On Microsoft Hatred) With this switch today, i'm committed to dig into Microsoft Windows's technologies.

Graphics Card

Also bought: “BFG Tech NVIDIA GeForce 9800 GT 512 MB”, for about $120. amazon.

This is for playing Second Life, and my geometry 3D visualization needs. On the Mac, adding a graphics card is impossible unless you buy a Mac Pro, which starts at $2500. For the same hardware power and quality, a PC costs about $1000 less.


For display, i got “LG L227WTG 22-Inch Widescreen LCD Monitor”. amazonIt has pixel dimention of 1680x1050. Actually bought it in 2008-12-01.

Manufacturer home page: Source. Spec: L227WTG_spec_sheet.pdf.

My PC Specification

HP Pavilion a6750f Desktop PC spec: hp.com spec. Plain text: HP_Pavilion_A6750F_spec.txt, motherboard_Aspen-GL8E.txt.

BFG NVIDIA GeForce 9800 GT OC 512MB PCIe 2.0: bfgtech.com spec. Plain text: BFG_NVIDIA_GeForce_9800_GT.txt.

NVIDIA page of GeForce 9800 GT: nvidia geforce_9800gt.

Sergey Brin Lecture

Perm url with updates: http://xahlee.org/comp/Sergey_Brin_lecture.html

Sergey Brin Lecture

Xah Lee, 2008-09-16

(2005) - 40 minutes about Wikipedia, search engines, China, desktop software and more. (Sergey Brin is the founder of Google.)

More vid of Google is at: http://googlesystem.blogspot.com/2008/09/10-videos-about-google.html.

Neal Stephenson at Google Talk

Perm url with updates: http://xahlee.org/Periodic_dosage_dir/Neal_Stephenson.html

Neal Stephenson at Google Talk

Xah Lee, 2009-01-16

Was chatting on freenode's irc #rcirc channel out of boredom. I asked out in the open for suggestions on some sci-fi movies to watch. Sabetts (Shawn Betts, author of Ratpoison and Stumpwm) mentioned that Neal Stephenson has a google talk.

I watched the entire 58 min of it. In the beginning 5 or 10 min, you see this boring guy, humorless, self-absorbed, absent-minded nerd, going on monotonously. The entire talk is a emotionless monotone, somewhat demeaning and self-abasing too, entirely devoid of any high points, energy, constantly letting out a subdued sigh. Can't find a single gleam of a smile on his face thru the entire talk.

I've of course heard of him, first time in 1998 thru a colleague (Jon Frisby), who named his coding projects after his books. Neal is this sci-fi novel writer, famous for titles like Snow Crash, Cryptonomicon, etc, some kinda celebrity god among tech geekers. I watched to see what he have say, after all he's giving a talk at Google.

It turns out, i find him to be extremely intelligent. When he got asked about what he thinks of Wikipedia (~20:30 to 27:00), my ears perked up intently. I'm a Wikipedia expert, as far as what it is, the quality of it, its relation to the tech geekers, and to humanity at large, so his answers will be a high point for me to make a judgment of him. And then behold, what quality in observation he has, brought out in such a un-spectacular mannerism. Though, it is disappointing when asked about Second Life (~13:40), for which his answer was that he basically never tried it so doesn't know much to comment, despite the fact that he partially founded such a metaverse idea and in fact supported its development by creating a wiki metaweb.com during mid 2000s. (in fact, my name and my article on trolling (On Ignoring Trolls) was mentioned on that wiki while it existed. (metaweb.com went defunct few years back and today it's some company's site.))


Here are some of Neal's popular books. Quotes are from Wikipedia. His novels won many awards.

Snow Crash》 (1992) amazon. «fuses memetics, computer viruses, and other high-tech themes with Sumerian mythology, along with an analysis of the differences between ideologies such as libertarianism, laissez-faire capitalism, and communism.»

The Diamond Age: or A Young Lady's Illustrated Primer》 (1995) amazon. «deals with a future with extensive nanotechnology and dynabooks.»

Cryptonomicon》 (1999) amazon. «A novel concerned with concepts ranging from computing and Alan Turing's research into codebreaking and cryptography during the Second World War at Bletchley Park, to a modern attempt to set up a data haven.»

The Baroque Cycle (novel)》 «A series of historical novels and is in some respects a prequel to Cryptonomicon. It was originally published in three volumes but has subsequently been republished as eight separate books.»

1. 《Quicksilver》 (2003) (containing the novels 《Quicksilver》, 《King of the Vagabonds》, and 《Odalisque》) amazon

2. 《The Confusion》 (2004) amazon (containing the novels 《Bonanza》 and 《Juncto》)

3. 《The System of the World (novel)》 (2004) amazon (containing the novels 《Solomon's Gold》, 《Currency》, and 《System of the World》).

Anathem》 (2008) amazon «A work of speculative fiction set in an Earth-like world[5]».


Spent 6 hours yesterday reading about Neal and his works. Wikipedia articles about his novels, his home page (web.mac.com/nealstephenson), grabbed some samples of his work from pirate networks (sorry, i live $2 a day for food. Will buy his book(s) if i actually read them.)

In particular, spend some 4 hours reading the Wikipedia page about 《The Diamong Age》. amazon

His novels are dense, and i'm into reading dense info. Reading the novel itself would take a long time, so so far i've just read Wikipedia about them, and that takes several hours, to understand all the terms, new concepts, etc.

For example, i learned the terms, words, new concepts, or learned more, about:

Of course, many of his themes i'm already familiar to intimately familiar, such as cyperpunk, metaverse, nanotech, viruses, Newton, Leibniz, confucianism.

Yaron Minsky, Janestreet Talk On Ocaml and Functional Language

Perm url with updates: http://xahlee.org/comp/Yaron_Minsky_Janestreet_talk.html

Yaron Minsky, Janestreet Talk On Ocaml and Functional Language

Xah Lee, 2008-09-16

Caml Trading Yaron Minsky, a programer at “Janestreet.com”, giving a talk about using Ocaml in the company. Dated about 2009-03. Highly intelligent.

Started my own tutorial about Ocaml about a month ago. OCaml Basics.


Is Microsoft a Monopoly?

Perm url with updates: http://xahlee.org/UnixResource_dir/writ/Microsoft_monopoly.html

Is Microsoft a Monopoly?

Xah Lee, 2010-08-20

Kenneth Tilton wrote:

They've run up the white flag, Microsoft, haven't they?

Tim Bradshaw wrote:

I think it's what happens to monopolists: they get big by being a monopolist, and because they have no competition they get slow and bureaucratic...

many tech geekers don't understand what the word monopoly means.

monopoly is preventing others from entering market. Monopoly is not saturation of a market.


a bit explanation is in order.

When a company prevents others from entering the market by tricks = evvvill!. This is what most tech geekers are thinking.

There's not that much example of such in our capitalistic US going on, to the degree that idiot everybody or tech geekers need to be alarmed, maybe except US government.

When a company saturates a particular market, such as Microsoft's OS for PC, Google for web search, that's called success. Because, any joe can come in and sell their shit, and when the public decided joe's better (e.g. linux), the so called monopoly topples.

Judge Alex Kozinski of the 9th Circuit pointed out that the key to monopoly is not market share — even when it is 100 percent — but the ability to keep others out. A company which cannot keep competitors out is not a monopoly, no matter what percentage of the market it may have at a given moment.

above from 〈Basic Economics〉, First Edition, by Thomas Sowell. ISBN: 0-465-08138-X. amazon Chapter 2: Big business and Government: Anti-Trust Laws, p.102

See also:

Run and buy the book now. Save humanity!


Apple iPad Censorship

Perm url with updates: http://xahlee.org/comp/Apple_iPad_censorship.html

Apple iPad, Censorship

Xah Lee, 2010-08-19

While writing reviews on Kindle and iPad, i learned that Apple practices heavy censorship. Not just about technology issues of what software technology is allowed to run, such as Adobe Flash, but actual contents from established newspapers, magazines, cartoons. Here are some details gathered from Wikipedia.

Censorship on Nudity

In May 2009, Apple rejected the first version of 'Newspapers', an iPhone app that let users read content from 50+ newspapers around the world, including the New York Times, France's Le Monde, and the United Kingdom tabloid The Sun. The app was rejected because the topless “Page 3” girls daily features were described as “obscene”. A second version of the application was submitted, removing access to The Sun, and adding a price tag of £0.59. The app was made available in the summer, after the release of the iPhone 3.0 software.[53][54]

Note that Page Three, is a well-known feature of The Sun, basically features photo of topless or nude females.

Censorship on Ancient Text

Here's a rejection because it contains the book Kama Sutra. Quote:

Another application, of similar nature to 'Newspapers', called 'Eucalyptus' allowed users to download e-books to their iPhone, though was censored by Apple because one of the e-books that could have been downloaded was the Kama Sutra. The ban has since been lifted.[55]

The Hypocrisy

They censor nudity, but don't censor big, well-known, porn money makers like Playboy.

It should be noted that the App Store has Playboy and Sports Illustrated adult-rated apps that have yet to be removed, while some apps by others were removed citing adult content which has resulted in accusations of hypocrisy.[58][59][60]

In November 2009, the application of Stern (a mainstream German weekly magazine with a print circulation of about 900,000) was deleted for several weeks without warning.[57][61] In January 2010, Europe's largest newspaper, German tabloid Bild, removed content from the iPhone version of its print edition at the request of Apple, and later it had to modify one of its applications - like in the Stern case because of nudity.[62] The Association of German Magazine Publishers (VDZ) warned that with such interventions Apple might be moving towards censorship.[62]

... Workers at the fashion magazine Dazed & Confused have nicknamed their iPad edition the “Iran edition”.[56]

Censorship On Satire

In December 2009, Apple banned a cartoon app called NewsToons by cartoonist Mark Fiore, on the grounds that it “ridiculed public figures.”[63][64]

In April 2010, Fiore won the Pulitzer prize for his political satire cartoons, making history as the very first internet-only cartoonist to win the prestigious journalistic prize.[65][63][64]

Following public outcry after the story broke in the wake of the award, Apple asked Fiore to resubmit his app. Fiore said, “Sure, mine might get approved, but what about someone who hasn’t won a Pulitzer and who is maybe making a better political app than mine? Do you need some media frenzy to get an app approved that has political material?”[64]

Bravo to Mark Fiore.

Censorship On Music

Also in May 2009, Trent Reznor of the rock band Nine Inch Nails announced, via his Twitter account, that Apple had rejected an update to the Nine Inch Nails application due to “objectionable content”.[67] The developer posted a message on the Nine Inch Nails discussion boards explaining the situation further: “v1.0 is live. v1.0.3 got rejected due to content yet the app has no content in it. This was mainly a stability release to fix the bug that crashes the app for international users. The bug was fixed 24 hours after 1.0 went live and we have been waiting for apple to approve it ever since. Meanwhile the app continues to get a growing number of 1 star ratings from international users understandably frustrated by the bug. “But looks like our hands are tied”.[68] Apple later permitted the update.[69]

Here's what Steve Jobs has to say about censorship:

“We do believe we have a moral responsibility to keep porn off the iPhone ... Folks who want porn can buy an Android phone” – Steve Jobs[56]

With all due respect to Steve's visions and innovation, moral his ass.

Here are some comical parts out of the censorship.

I Am Rich

I Am Rich. Quote:

In August 2008, an application known as I Am Rich was released in the store, “a work of art with no hidden function at all”, with its only purpose being to show other people that they were able to afford it, as it cost US$999.99, €799.99, and UK£599.99.[46] The application was removed from the App Store the day following its release, on August 6, 2008 (2008-08-06).[47] Eight people had bought it before it was pulled.[48]

YouPorn Response

Due to the exclusion of porn from the App Store, YouPorn and others changed their video format from Flash to H.264 and HTML5 specifically for the iPad.[78][79] In an e-mail exchange[80] with Ryan Tate from Valleywag, Steve Jobs claimed the iPad to offer “freedom from porn”, leading to many upset replies including Adbustings in Berlin by artist Johannes P. Osterhoff[81][82] and in San Francisco during WWDC10.[83]

Lol. The war of porn formats.

Kindle, iPad, Android, and All That Jazz

Perm url with updates: http://xahlee.org/comp/Kindle_iPad_and_all_that_jazz.html

Kindle, iPad, Android, and All That Jazz

Xah Lee, 2010-08-19

Recently, i noticed there's something called Kindle from Amazon. What's with the jazz? Another hand-held electronic gadget?

Kindle ad from Amazon

Kindle ad from Amazon

I don't think i'd be interested. If you want a small computer for reading, you can buy a small computer for reading, which lets you do a lot more things than reading. (They are called Subnotebook.) Or, you can buy one of those fancy cellphones. So, i looked up Wikipedia. Quote:

Amazon Kindle is a software and hardware platform developed by Amazon.com for the rendering and displaying of e-books and other digital media...

Kindle software applications exist for Microsoft Windows, iOS, BlackBerry, Mac OS X and Android[2]. Amazon's first hardware device, the Kindle First Generation, was released only in the United States on November 19, 2007. The latest hardware device, the 3rd generation Kindle with 3G support for use in 100 countries and territories, was announced on July 28, 2010.[3]

The Kindle hardware devices use an E Ink brand electronic paper display that features 16 shades of gray...

And what the hell is “E Ink brand of electronic paper”? Sure, i heard of electronic paper before. It's supposed to be a future tech, where, basically it's just like a paper, except the text on it can change. So, i looked up Wikipedia again. Quote:

Electronic paper, e-paper or electronic ink display is a display technology designed to mimic the appearance of ordinary ink on paper. Unlike a conventional flat panel display, which uses a backlight to illuminate its pixels, electronic paper reflects light like ordinary paper. It is capable of holding text and images indefinitely without drawing electricity, while allowing the image to be changed later.

Ah, so, that's it. The display tech is rather different from cellphones or laptops. Basically, you can read it under sunlight. You see that attractive chick comfortably sitting on a beach holding the Kindle with sunglasses and reading? Now that makes sense! (she might be reading bodice-ripper.)

OK. So it basically is a gadget primarily for reading books. If you do a lot writing, chat with friends, play games, play dvd, then that's not for you, but you also don't have to deal with all the computer problems. It's a simple device.

So you buy this, then you can buy digital books from Amazon. I've seen prices like 2 bucks to 9 bucks. Am pretty sure most widely circulated books, mags, come in a kindle version. (and if you are into math text books and computer journals, forget it. lol.)

Ok, so what's the format of the digital book? Certainly it's not plain text or some html, because that quickly gets pirated all over. Apparently, Amazon provides free software that you can download on Apple or PC or other handheld devices so that, if you bought a Kindle book, you can read them on your laptop too.

Kindle's OS is actually Linux! More juicy Wikipedia quote:

Amazon released the Kindle First Generation on November 19, 2007, and it sold out in five and a half hours.[14] The device remained out of stock for five months until late April 2008.[15]

The Kindle 2 features, a text-to-speech option to read the text aloud, and 2 GB of internal memory[18]

To promote the new Kindle, author Stephen King made UR, his then-new novella, available exclusively through the Kindle Store.

Wow, amazing. So it actually quite popular. I guess your grandma simply just want to read, begone with software updates, anti-viruses shit, browser wars, incessant ads.

Specific Kindle sales numbers are not released by the company, but Jeff Bezos, founder and CEO of Amazon.com, stated in a shareholders' meeting that “millions of people now own Kindles.” [40] According to anonymous inside sources, over three million Kindles have been sold as of December 2009[41], while external estimates as of Q4-2009 place the number at about 1.5 million.[42]

Humm... i think that number is bigger than emacs. Actually, probably bigger than linuxes.

How Much?

The cheapest runs around $140, called “Kindle Wi-Fi” amazon

The middle is called “Kindle 3G + Wi-Fi”. amazon About $180.

The big bad ass runs close to $400. “Kindle DX” amazon. It's about the size of a standard US A4 paper. Kinda unwieldy.


Probably red-eyed by Kindle's success, Barnes & Noble introduced a competing ebook device: The Nook. Looks like it's also selling well.

Quite a interesting trend with these ebook devices. Of course, laptop sales has been taking over desktops since mid 2005s. iPod, iPhone, have been selling like hotcakes, and Apple changed its company name from “Apple Computer, Inc.” to just “Apple Inc.” in 2007.

  • “iPod Nano” amazon
  • “Apple iPod touch 32 GB” amazon

iPad says: “What About Me?”

It'll be another day to fully philosophize on Apple's latest: IPad, on the technology, the impact on economy, influence on human animal society, relation to futurism and singularity... but just a quick juicy Wikipedia quote:

Apple released the iPad in April 2010, and sold 3 million of the devices in 80 days.[13][7]

humm... that's much more than Kindle. Note also the iPod, iPad, are tightly controlled by Apple:

The iPad's design imposes strict restrictions in its usage namely DRM intended to lock purchased video content to Apple's platform, the development model requiring a non-disclosure agreement and paid subscription to develop for the iPad, and the centralized approval process for apps as well as Apple's general control and lockdown of the platform itself,...

Of particular concern is the ability for Apple to remotely disable or delete apps, media, or data on the iPad at will.[66][67][68]

Digital rights advocates, including the Free Software Foundation, Electronic Frontier Foundation, and computer engineer and activist Brewster Kahle, have criticized the iPad for its digital rights restrictions.

It turns out Apple practices heavy handed censorship. Not just about technology issues of what software technology is allowed to run, such as Adobe Flash, but actual contents from established newspapers, magazines, cartoons. See: Apple iPad and Censorship.


Windows Starting Too Slow? Disable Windows Startup Apps with msconfig

Perm url with updates: http://xahlee.org/mswin/disable_Windows_startup_apps.html

Windows Starting Too Slow? Disable Windows Startup Apps with msconfig

Xah Lee, 2010-08-18

Is your Windows starting super slow?

On Windows, just every software automatically adds itself to startup when the machine starts, even if you don't use it. e.g. iTune, Adobe Acrobat, Java. It is a pain in the ass. They do that because when you actually start the application, they appear to start instaneously, making you think they are fast and good. (while Microsoft takes the blame of the overall slowness of Windows startup.)

msconfig startup1

“msconfig” screen of Startup programs.

To disable the auto hidden start, you can use Msconfig. Press “Win+r”, then type “msconfig”. Then, click on the Startup pane. There you can disable them. Here's the ones i recommend to disable:

  • Adobe Reader
  • Adobe Acrobat
  • MobileMe (Apple iTune stuff if you don't have iPod or iPhone stuff)
  • QuickTime
  • iTunes
  • HP Health Check Scheduler (crap from HP)
  • hpwuSchd Application (crap from HP)
  • hpsysdrv Application (crap from HP)
  • Pando Media Booster (from some game)

Things like CyberLink PowerCinema etc i never use so i've already de-installed them.

When you install games, especially free ones, they often add junk here without you knowing. Later, it's usually hard to find out what junk in the startup are. Even well known commercial games.

Whenever there's a update to one of these software, such as Java, Adobe, iTunes, they automatically add back to the startup. So be sure to disable them again.

Disable Services

hp pc startup services

msconfig's Services panel.

While you are at it, you might click on the Services tab and disable some there. (they are not applications, but hidden background processes) Here, you should know what they are to disable. Here's some i disabled:

  • Apple Mobile Device (i don't own any iPod, iPhone stuff)
  • iPod Service
  • Bonjour Service (from Apple. If you don't have local networks, disable it.)
  • HP Health Check Service (crap from HP)

WARNING: you better know what you are doing. Disabling critical services can cause problems. I'm not responsible if your computer won't start up.

world literature classics: thoughts extempore

Perm url with updates: http://xahlee.org/Periodic_dosage_dir/thoughts_extempore_arabian_nights.html

World Literature Classics; Thoughts Extempore

Xah Lee, 2010-08-18

Spent like a whole day last week revisiting all of my World Literature Classics pages. Rechecked all links, nosed about anything that might be new (e.g. reread Wikipedia articles, checked printing status at amazon, editions, reader comments...), and fixed any unintended grammatical errors and or improved my annotations here and there.

Here's a few short ones you might enjoy:

  • This one is hilarious: Little Red Riding Hood (Politically Correct version). Note that the Little Red Riding Hood story changes thru the ages, to suite the waves and tides of the changing times and places.
  • This one by James Agee: A Mother's Tale, is the best presentation of agnosticism. (agnosticism here is not with respect to god, but epistemology.)
  • This one, is just classic. Cupid and Psyche. Very typical of greek mythology. In which, you learned that their gods and goddesses are not some righteous beings as of gods in Abrahamic religions, but filled with desire, jealousy, anger, materialistic wanting, all the foibles. e.g. it's common for a greek goddess to kill or deform some mortal maiden out of jealousy of her beauty, or for gods to vie for power or steal other's wives, even eating their own son or cutting off dad's penis for power. (in-faimly power struggle between males happens thru-out Chinese history, am sure in Europe too).
  • To Build a Fire (Jack London) About human animals vs nature.

I really love them.

The one novel i never completed reading is Gulliver's Travels. The last annotation i did was on Part 4, chapter 7. That means i have about just 10% more to go. Supposedly, the ending is somewhat a surprise: that of all the Lilliputians and Brobdingnagians and Laputians whatnot hateful creatures so described in the saga, it turns out it's just human animals.

I was reading it starting in 2005 but stopped about 2008, because i found the work quite boring and tedious to go thru. All the allusions and satire require a understanding of UK politics of 1700s. Quite painstaking research to annotate.

Another large work, which i really do enjoyed reading a lot, is The Arabian Nights of Sir Richard Burton's translation. This work is just amazing. In the phantasmagorical story itself (often with wild sexuality), but as well as Burton's amazing English style. I remember that some alt.english.usage folks commented that Burton's Arabian Nights is bad tortuous English, but i truely enjoyed it, in its perhaps stilted use of archaic words, far more than Gulliver's Travels. And, i really do love the embedded poems littered thru-out. These poems, as it is often said, are “extempore”.

Here's one example from The Fisherman And The Jinni:

“O toiler through the glooms of night in peril and in pain,
Thy toiling stint for daily bread comes not by might and main!
Seest thou not the fisher seek afloat upon the sea
His bread, while glimmer stars of night as set in tangled skein?
Anon he plungeth in despite the buffet of the waves,
The while to sight the bellying net his eager glances strain,
Till joying at the night's success, a fish he bringeth home
Whose gullet by the hook of Fate was caught and cut in twain.
When buys that fish of him a man who spent the hours of night
Reckless of cold and wet and gloom in ease and comfort fain,
Laud to the Lord who gives to this, to that denies, his wishes
And dooms one toil and catch the prey and other eat the fishes.”

Do you know what Arabian Nights is about? You've watched Disney right? Check these three single-paragraph tales out: The Arabian Nights: 70. ABU AL-ASWAD AND HIS SLAVE-GIRL.

Speaking of long tales, the other one i truely enjoyed, read it i think 3 times, is The Tragedy Of Titus Andronicus.


new version of ErgoEmacs Keybinding (5.3.4)

Perm url with updates: http://xahlee.org/emacs/blog.html

A new version of the ErgoEmacs Keybinding is out.

The new version is 5.3.4. New is a Swedish layout, and also the window splitting keys have changed for the ergonomically better. See the included “_HISTORY.txt” file for more detailed release notes. Thanks to Kristian Hellquist for the Swedish layout.

Also thanks to many who have voiced support.

How to Replace Multiple String Pairs in Emacs Lisp Buffer

Perm url with updates: http://xahlee.org/emacs/elisp_replace_string_region.html

How to Replace Multiple String Pairs in Emacs Lisp Buffer

Xah Lee, 2010-08-17

This article is a detailed tutorial for emacs lisp programers, on how to do multiple pairs of find/replace string for a given region in a buffer.


You have a given region in a buffer. You want to do one or more pairs of find/replace strings. For examples:

html entities
& ↔ &amp;
< ↔ &lt;
> ↔ &gt;
url percentage encoding
“ ”  ↔ “%20”
~ ↔ %e7
_ ↔ %5f
writing math
alpha ↔ α
beta ↔ β
gamma ↔ γ
quote/unquote in elisp string
" ↔ \"
\ ↔ \\
\" ↔ "
converting paths (Unix, Windows, UNC, URL, local)
\ ↔ /
\ ↔ \\
C:\Users\mary ↔ ~/
file:///C:/Users ↔ C:
"../ ↔ "http://

Some of these tasks are generalized and well defined, so there may be existing lisp package to deal with them. Examples:

  • URL percentage encoding
  • HTML entities encoding
  • Windows/Unix path conversion
  • URL/UNC conversion

However, usually you don't want generalized solution, because your input is not a well defined file like XML, and you know exactly what you need.

The normal idiom to do find replace in a region is like this:

(defun replace-html-chars-region (start end)
  "Replace “<” to “&lt;” and some other chars in HTML.
This works on the current region."
  (interactive "r")
    (narrow-to-region start end)
    (goto-char (point-min))
    (while (search-forward "&" nil t) (replace-match "&amp;" nil t))
    (goto-char (point-min))
    (while (search-forward "<" nil t) (replace-match "&lt;" nil t))
    (goto-char (point-min))
    (while (search-forward ">" nil t) (replace-match "&gt;" nil t))
    ) )

Basically, you narrow to region, and for each pair you use a while loop. This is quite cumbersome.

It would be nicer, if you can write it like this:

(defun replace-html-chars-region (start end)
  "Replace “<” to “&lt;” and some other chars in HTML.
This works on the current region."
  (interactive "r")
  (replace-pairs-region start end
 ["&" "&amp;"]
 ["<" "&lt;"]
 [">" "&gt;"]


Here are several elisp functions that make this easy.

  • replace-pairs-in-string
  • replace-regexp-pairs-in-string
  • replace-pairs-region
  • replace-regexp-pairs-region

For each function, there's a plain text version and a regex version. Because, it is often a pain and error-prone to use regex when all you need is fixed string find/replace.

Each function also has a string and region version. The string version works on a given string, the region works on a region in buffer. This saves you time because when all you got is a string, you don't have to create a buffer just to do some find/replace then turn back to string. Same when you have a buffer to begin with.

The region versions call the string versions to do their work. This makes the code more manageable. That is:

  • “replace-regexp-pairs-region” prepares a string then calls “replace-regexp-pairs-in-string” then put it back in buffer.
  • “replace-pairs-region” prepares a string then calls “replace-pairs-in-string” then put it back in buffer.

Both the string versions call the builtin elisp function “replace-regexp-in-string” to do their work.

Note that emacs does not have a plain text version analogous to “replace-regexp-in-string”. So, when you want plain text find/replace, you warp “regexp-quote” on your string, then call “replace-regexp-in-string”.


The code can be downloaded here: code.google.com.

The code is 130 lines (not counting comment header). Here's the main code that does the bulk of the work.

(defun replace-pairs-in-string (str pairs)
  "Replace string STR by find/replace PAIRS sequence.

 (replace-pairs-in-string \"abcdef\"
  '([\"a\" \"1\"] [\"b\" \"2\"] [\"c\" \"3\"]))  ⇒ “\"123def\"”.

The search strings are not case sensitive.
The replacement are literal and case sensitive.

If you want search strings to be case sensitive, set
case-fold-search to nil. Like this:

 (let ((case-fold-search nil)) 
   (replace-regexp-in-string-pairs ...)

Once a subsring in the input string is replaced, that part is not changed again.
For example, if the input string is “abcd”, and the pairs are
a → c and c → d, then, result is “cbdd”, not “dbdd”.
See also `replace-pairs-in-string-recursive'.

This function calls `replace-regexp-in-string' to do its work.

See also `replace-regexp-pairs-in-string'."
  (let (ii (mystr str) (randomStrList '()))
    (random t) ; set a seed

    ;; generate a random string list for intermediate replacement
    (setq ii 0)
    (while (< ii (length pairs))
      (setq randomStrList (cons
                    (concat "ㄓ" (number-to-string (random)) "ㄘ")
 ; use rarely used unicode char to prevent match in input string
                    randomStrList ))
      (setq ii (1+ ii))

    ;; replace each find string by corresponding item in random string list
    (setq ii 0)
    (while (< ii (length pairs))
      (setq mystr (replace-regexp-in-string
                   (regexp-quote (elt (elt pairs ii) 0))
                   (elt randomStrList ii)
                   mystr t t))
      (setq ii (1+ ii))

    ;; replace each random string by corresponding replacement string
    (setq ii 0)
    (while (< ii (length pairs))
      (setq mystr (replace-regexp-in-string
                   (elt randomStrList ii)
                   (elt (elt pairs ii) 1)
                   mystr t t))
      (setq ii (1+ ii))

Find/Replace Feedback Loop Problem

One interesting issue about multiple find/replace is that the input string is recursively replaced, and you may end up with a substring that's not in the original input string nor in any of the find/replace pairs.

For example, if the input string is “abcd”, and the pairs are “a → c” and “c → d”, then, result is “dbdd”, though most of the time you want “cbdd”.

The function “replace-pairs-in-string” will not do feedback loop. It guarantees that a replacement is done IF AND ONLY IF the original input string contains a substring in one of your find string.

This is important when you do complex text processing such as transforming HTML4 to HTML5 or HTML to XHTML.

For a version that does feedback, use “replace-pairs-in-string-recursive”, also in the package.

To implement the non-feedback version, i first replace the string to a intermediate random string. For example, suppose the input pairs are “a → b” and “c → d”. Then, the code will actually do this:

  • “a → randomString1”
  • “c → randomString2”
  • “randomString1 → b”
  • “randomString2 → d”

The random string so generated should not happen in the input string. This is achived by using rarely used char in Unicode plus a random number, for the intermediate string.


Here are some commands i defined that make use of the replacement pair functions.

(defun space2underscore-region (start end)
  "Replace space by underscore in region."
  (interactive "r")
(replace-pairs-region start end '([" " "_"])))
(defun underscore2space-region (start end)
  "Replace underscore by space in region."
  (interactive "r")
(replace-pairs-region start end '(["_" " "])))
(defun replace-mathematica-symbols-region (start end)
  "Replace Mathematica's special char encoding to unicode of the same semantics.
For example:
 \\=\\[Infinity] ⇒ ∞
 \\=\\[Equal] ⇒ =="
  (interactive "r")
  (replace-pairs-region start end '(
 ["\\[Infinity]" "∞"]
 ["\\[Equal]" "=="])))
(defun replace-greek-region (start end)
  "Replace math symbols. e.g. alpha to α."
  (interactive "r")
(replace-pairs-region start end '(
["alpha" "α"]
["beta" "β"]
["gamma" "γ"]
["theta" "θ"]
["lambda" "λ"]
["delta" "δ"]
["epsilon" "ε"]
["omega" "ω"]
["Pi" "π"])))
(defun replace-html-chars-region (start end)
  "Replace “<” to “&lt;” and some other chars in HTML.
This works on the current region."
  (interactive "r")
  (replace-pairs-region start end
 ["&" "&amp;"]
 ["<" "&lt;"]
 [">" "&gt;"]
(defun escape-quotes-region (start end)
  "Replace \" by \\\" in region."
  (interactive "r")
  (replace-pairs-region start end '(["\"" "\\\""])))
(defun unescape-quotes-region (start end)
  "Replace \\\" by \" in region."
  (interactive "r")
  (replace-pairs-region start end '(["\\\"" "\""])))
(defun replace-curly-apostrophe-region (start end)
  "Replace some single curly quotes ‘ or ’ to '."
  (interactive "r")
(replace-pairs-region start end '(
["‘tis" "'tis"]
["’s" "'s"]
["’d" "'d"]
["n’t" "n't"]
["’ve" "'ve"]
["’ll" "'ll"]
["’m" "'m"]
["’re" "'re"]
["s’ " "s' "])))
(defun replace-straight-quotes-region (p1 p2)
  "Replace straight double quotes to curly ones
Also replace “--” by “—”."
  (interactive "r")
  (let (quoteReplaceMap)
    ;; a map that helps converting straight quotes to double quotes in texts
    ;; (e.g. novels). Note: order is important since this is huristic.
    (setq quoteReplaceMap
["--" " — "]
["  —  " " — "]
[">\"" ">“"]
["(\"" "(“"]
[" \"" " “"]
["\" " "” "]
["\"," "”,"]
["\"." "”."]
["\"?" "”?"]
["\";" "”;"]
["\":" "”:"]
["\")" "”)"]
["\"]" "”]"]
[".\"" ".”"]
[",\"" ",”"]
["!\"" "!”"]
["?\"" "?”"]
;; ";
["\n\"" "\n“"]
[">\'" ">‘"]
[" \'" " ‘"]
["\' " "’ "]
["\'," "’,"]
[".\'" ".’"]
["!\'" "!’"]
["?\'" "?’"]
["(\'" "(‘"]
["\')" "’)"]
["\']" "’]"]
[" ‘em" " 'em"]))

    (replace-pairs-region p1 p2 quoteReplaceMap)))

Emacs is beautiful!


Left Wrist Motion Pain; vi Esc Syndrome

Perm url with updates: http://xahlee.org/emacs/vi_esc_syndrome.html

Left Wrist Motion Pain; vi Esc key Syndrome

Xah Lee, 2010-08-16

In the past month, my left hand wrist started to feel funny. Especially yesterday after several hours of heavy coding. Not pain yet, but distinctively something is wrong. The closest description is tingling, and tingling sensation is the first symptom to RSI.

(Been using emacs for like 16 hours per day for the past 6 months. Especially in the past 3 months. No it's not a exaggeration. Hard to say the exact hours my fingers are actually typing, but literally from the time i wake to the time i sleep i'm in front of comp, and about half of that time i'm inside emacs.)

I consider myself a keyboarding expert. I use a fancy ergonomic keyboard (since 2005). I use the Dvorak Layout (since ~1992). I use a ergonomic emacs keybinding system (since 2007). I have extensive system-wide custom-designed shortcuts to save keystrokes. I read extensively on all things related to keyboard, in the past 20 years. (See: All About Keyboards, Keyboard Layouts, Shortcuts, Macros.)

So, it is a slap to my face, that i might be developing repetitive strain injury (RSI). I am quite puzzled on what's the cause.

Is it the emacs chording? No, i don't find any evidence tracing to that with my system. Is it lack of breaks? No, i take at least 5 min walk every 2 hours. I thought it's because i played too much first-person shooter in Second Life. (because i use left hand for mousing. (btw, i use 2 mouses, one for each hand, and i alternate mousing hands without thought, whichever comes handy at the moment. Been doing this since 1995 or so.)) Certainly playing first-person shooter didn't help, especially when you get intense and got immersed in the game to kill your opponents, and this can happen for hours unconsciously.

Perhaps, 10+ hours a day keyboarding is just too much? I was guessing the problem is Second Life combat, but can't be sure. But today, i found out why.


It's the goddamn keys like 1, 2, Tab, Esc, `. In a sentence, perhaps it is best understood as “vi Esc key syndrome”.

One way to know your problem is to have a camcorder pointing at your hands for the whole day. Then, play them back with increased speed. When you watch the video, you can clearly see what's the most repetitive motion. (This technique is widely used in athlete training to monitor habits and movements. (i know because i was in college swimming team in around 1992 to 1993, and have been subjected to this by our coach Ron Oburn, once.))

I don't have a camcorder and didn't bother to do this. Nevertheless, little hints and thoughts made it clear.

The 1, 2, Esc, Tab keys are on the extreme left side of the keyboard. Let's say the 1 key, which is the most frequently used digit. How you press that depends on person. You can flatten your palm and extend your pinky. This is the method traditionally taught in touch-typing. However, i remember about a year ago i find this way to be too slow and cumbersome for the keyboard i am using. I press the 1 key by bending my wrist leftward, then use my middle finger to press 1. This means i move my wrist in a horizontal left/right motion a lot.

Also, in ErgoEmacs, splitting window is done by Alt+2, and expanding the current pane is done by Alt+1, and closing all other panes is “Alt+Shift+1” (Alt+!). Window expanding and spliting are two of the most frequently used emacs operations. (See: Emacs's Command Frequency) So, that adds significantly to my wrist left-right movement.

(Note: the original design of Dvorak layout has numbers arranged like this: “7 5 3 1 9”, “0 2 4 6 8”. The 1 would be today's 4, which is most easily typed for that row for left hand)

In the past few days, before this discovery, i have attempted to reproduce any hand movement that would cause this tingling sensation, but just couldn't pinpoint. Now i know. Now, if i just emulate the motion of my left hand trying to type the 1 and back to normal typing position, TINGLE! Move my hands away from keyboard, then try to move my wrist left/right, Tingle! Don't laugh, because it's very unpleasant. (and i shudder to think about it, because many programers have permanently damaged their hands by typing.)


The solution is quite simple. Here are some suggestions.

• Do not press the 1 key using index finger. Same for all the other keys there (Esc, `, Tab, 2). Press them by moving your whole arm to avoid wrist bending. (Pressing them by extending pinky will probably cause a different problem.)

• Avoid heavy use of these keys. If your software need them frequently, remap them elsewhere using keyboard macros software. Map them to function keys, or modifier combo with easier keys in positions of 3, 4, 7, 8, 9. If it means slower operation, keep in mind that your hand health is more important than saving of little seconds.

(for key macros, on Windows you can use AutoHotkey, IntelliType. On Mac you can use Mac OS X DefaultKeyBinding.dict, Keyboard Maestro at keyboardmaestro.com (trial ware), Quicksilver at blacktree.com (free). Also QuicKeys (commercial) (startly.com) is available for both Windows and Mac. )

This also means, my ErgoEmacs keybinding will be changed. Alt+1, Alt+2 won't be for splitting windows. When i designed them, those choices were sloppily chosen without much thought. They were based on mnemonic, similar to emacs's default C-x 1, C-x 2. But now i know how bad these choices are. I'll create a new version with new binding for spliting window functions. For now, you can put the following in your emacs init file:

;; remove some default
(define-key ergoemacs-keymap (kbd "M-1") 'nil)
(define-key ergoemacs-keymap (kbd "M-!") 'nil)
(define-key ergoemacs-keymap (kbd "M-2") 'nil)
(define-key ergoemacs-keymap (kbd "M-@") 'nil)

;; new
(define-key ergoemacs-keymap (kbd "M-3") 'delete-other-windows )
(define-key ergoemacs-keymap (kbd "M-0") 'delete-window)
(define-key ergoemacs-keymap (kbd "M-4") 'split-window-vertically)
(define-key ergoemacs-keymap (kbd "M-$") 'split-window-horizontally)

The above takes out the ispell-word command. If you use that, remap it somewhere. I remap it to the keypad's 4. (<kp-4>) (other numbers are already used. I use the keypad keys as function keys. If you don't use Calculator, the keypad can serve as extended function keys. Can be system-wide or app-specific.)

I'm sooo very happy i discovered this problem.

emacs lisp: escape quotes

small elisp programing tip.

elisp has the toothpick syndrom. When you use elisp to process
html, all the "quote" characters needs to be escaped. (worse if you
have backslash (e.g. Windows style path) and need to process it with
emacs regex.)

Here's a quick function i've been using for a couple of years:

(defun escape-quotes-region (start end)
  (interactive "r")
  "Replace \" by \\\"."
  (replace-pairs-region start end '(["\"" "\\\""])))

(defun unescape-quotes-region (start end)
  (interactive "r")
  "Replace \\\" by \"."
  (replace-pairs-region start end '(["\\\"" "\""])))

You can assign a key to them.

This calls replace-pairs-region. Which i have defined. See if you can code that. I'll post my code tomorrow.