Linux vs Minix

The current version of Linux kernel is 3.3.4. You can find out the version by uname -a.

I didn't realize that when Linus did Linux, BSD wasn't legally free. (i always thought BSD was there already, free.)

Following are good read, but will take 30 min at least, hours or days for understanding. Read the one by Andy Tanenbaum.

emacs: improving key choices

in past few days, i made another majorish change to my emacs keybinding set.

Now personal global commands start with F5. (used to be 【Ctrl+l】) Personal mode-specific commands start with F8. (used to be 【Ctrl+e】) (this is on Dvorak)

the gist in the change is that i now use single key sequence instead of combination.

over the years, i gradually switched almost all my most often used commands to single key or single key sequences, instead of combo keys or combo-key sequence.

if you type a whole lot, and experiencing hand discomfort, then single key is healthier than combination keys, even if it means a fraction of second slower to reach the F keys.

working in emacs now is like hunt'n'peck. LOL

music video updates 2012-05-04

music video updates

update Lily Allen - Fuck You Very Much

updated Portishead - Glory Box

update Heineken Commercial - The Entrance (The Golden Age - The Asteroids Galaxy Tour)

updated Sarah Brightman - Harem

updated VNV Nation - Illusion

Javascript DOM Scripting Pain: Whitespace Nodes

coding javascript+DOM is a pain in the ass.

no, am not talking about using those jquery etc libs.

am talking about js+dom raw.

every whitespace in your html code is a node too, by spec. Say, you want to get nextSibling. But what you get is a text node of white space.

This is a pain in the ass. However, there's also a advantage aspect. Because, this spec makes it possible to write a DOM processor that preserve the original formatting, including manipulating comments.

(on the other hand, comment or formatting are lost in most lang's compiler. Suppose you want to write a most advanced {lint, pretty-printer, automatic code formatter}. You might think you'll just use the lang's compiler, since it knows everything about the language. But you can't! you kinda have to write a entirely different tool from scratch. Because the compiler is totally ignorant about the comments and formatting! (this includes so-called “lisp reader”) This also explains, auto formatting tools (aka lint) isn't always available. Even in emacs, formatting source code sucks majorly. Those formatting commands (e.g. indent-region), they go line-by-line manual/guessing methods. And this “no auto formatting condition” encouraged all the hacker type idiots to drivel about “coding style” day and night. (is there a language whose compiler are aware of source code comments and formatting?))

but anyway, normally when doing web app scripting, we don't care for the whitespaces between tags. So, in order to get the real next sibling, it's a pain in the ass. You have to check the returned node's type, then check if its value is all whitespaces (and don't forget the Unicode whitespace characters, kids).

of course, any sane coder will just use a js lib.

Javascript: Navigating DOM Tree: previousSibling nextSibling childNodes firstChild lastChild parentNode

Perm URL with updates: http://xahlee.org/js/js_navigate_nodes.html

This page is a tutorial of Javascript navigating the DOM tree. This page show examples of using methods: {previousSibling nextSibling childNodes firstChild lastChild parentNode}.

previous/next Sibling

‹node›.previousSibling Return the previous sibling of ‹node›, or null if it doesn't exist.

‹node›.nextSibling Return the next sibling of ‹node›, or null if it doesn't exist.

When the sibling does not exist, the return value is null.

test code: javascript test page: nextSibling

Whitespace Nodes

Note: in most browsers, any space in HTML source code between tags are considered a node too. This is by W3C spec. So, typically, when you call nextSibling, you'll get a text node of whitespace. This is usually not what you want.

Here's a example. In the following, we get a node's next sibling, and get its node type. If the nodeType is 3, it means text node, and thus it's (probably) just white space. If node type is 1, then it's element.


Test page: javascript test page: nextSibling is whitespace node?

You can avoid the whitespace node problem by not having space or newline between your element's tags. e.g.

<!doctype html><html><head><title>test</title></head><body><p>something</p></body></html>

Of course, this is not practical, because it makes the html hard to read.


‹node›.childNodes Return all children of ‹node› as a list.

Suppose this is your HTML:

<div id="A">
some <span id="B">thing</span>

This is your javascript code:

var xx = document.getElementById("A").childNodes;

var num = xx.length;

alert("total children: " + num);
alert("first child node name: " + xx[0].nodeName);
alert("second child node name: " + xx[1].nodeName);
alert("3rd child node name: " + xx[2].nodeName);
total children ⇒ 3
first child node name ⇒ #text
second child node name ⇒ SPAN
3rd child node name ⇒ #text

Test page: javascript test page: childNodes

Source developer.mozilla.org

firstChild lastChild

‹node›.firstChild Return the first child of ‹node›.

‹node›.lastChild Return the last child of ‹node›.


‹node›.parentNode Return the parent of ‹node›.


Linux UI Overview 2012

Perm URL with updates: http://xahlee.org/linux/linux_UI_overview_2012.html

so, am running lxde and xfce now.

been also running xmonad, unity 2d, gnome 2. (and of course, 12 years ago, i've been running CDE, and bare x11 with a clock and xterm. lol)

shit, am now a wm master!

ok, now the judgement.

  • Unity = mom and pop extreme shit with its software store shit.
  • xmonad = SHIT. (any tiling wm is a inefficiency SHIT, by principle. +Craig Lennox n +Jeff Weiss's opinions not withstanding. ☺ )
  • Gnome 2 = usable. Good.
  • Xfce = usable. Good.
  • LXDE = kinda bare threads. ugly font. The font in the default terminal (lxterminal) is one ugly face! (pun there) Probably due to bad anti-aliasing. LXDE's look'n'feel is kinda like Windows 95.

I think Gnome 2 or xfce would be my choice forward.

so, in general, i'm extremely a pure functional guy. I don't care for any “visual effects” shit (such as the compiz fuck), but if a visual effect do aids functionality in subtle and measuable ways (e.g. window shadow), then it MAY be good (depends on how much it aids recognition, in this case.). Yet, am not into the typical hacker types who clamor about killing the mouse or tiling windows shit. (i live inside terminal & emacs, yet i fucking love the mouse. I use 2 mouses, one for each hand, for 15 years now, and my mouses each must have 5 buttons minimum! and i have like literally over a hundred personally defined hot keys key system of my own devise, so those ratpoison guys, shut up n am more efficient, faster, than u in any aspect of operating the OS, YET i type less in doing any operation, YET overall i type 2 times more than u!)

in summery, when it comes to UI, am highly efficiency and pure functionality oriented, but everything i judge by more scientific grounds as much as possible, not by Geeking HABIT or Culture.

o btw, so, it's been 13 years since i played with linux. Of all these wm i've tried, when compared to Windows today (Window 7), am sorry to say, the linuxes are all clunky, error prone, less features, by FAR. (i was thinking and wishing it to be otherwise, but am sorry to say this is simply unbiased fact) And, OS X's UI, on prettiness, functionality, ease of use, robustness, is another level up than Windows.

humm… so, it looks like, after 10 years, things haven't changed much, really.

TED2012: The only way to learn to fly is to fly

Perm URL with updates: http://xahlee.org/Periodic_dosage_dir/pd.html

If you want to understand how, ask yourself this question, “What would you attempt to do if you knew you could not fail?” It's an uncomfortable question, because it forces you to realize that the fear of failure holds you back. The path to new and innovative things always contains failure, but we're constantly afraid of it — we have to get over that fear. Dugan quotes Clemenceau, “Life gets interesting if you fail, because it means we've surpassed ourselves.”


  • TED2012: The only way to learn to fly is to fly By Regina Dugan. @ Source blog.ted.com


Linux: Great Image Viewer Applications

Perm URL with updates: http://xahlee.org/linux/linux_image_viewers.html

This page gives a list of popular image viewers on Linux.

  • GNOME: Eye of GNOME eog
  • KDE: Gwenview gwenview
  • GQView (GTK+) gqview
  • GThumb gthumb (similar to IrfanView on Windows)
  • LXDE (light weight desktop): GPicView (similar to Microsoft Windows's Picture Viewer)
  • KuickShow
  • GImageView gimv
  • QIV (Quick Image Viewer)
  • ViewNior

I asked on twitter this:

what's a linux image viewer that allow random slide show? have 20k images,want view random. eg Mac's Graphics Converter, Windows IrfanView

Someone answered: PornView. Here's a quote from the description:

PornView is an image and movie viewer/manager with thumbnail previews. Additional features includes thumbnail caching, directory tree views, adjustable zoom, and fullscreen view. Slideshows allow for unattended presentation of images for hands-free viewing. Pornview is written using GTK+.

LOL. Exactly what i needed.

Windows sys admin app command line program names

random Windows notes, 2012-05-02

in Windows 7, in 〔Control Panel\All Control Panel Items\Administrative Tools〕, the items there are just shortcuts. You can find the program path and launch parameters by looking at the Properties.

Here's a list:

  • Component Services: %windir%\system32\comexp.msc
  • Computer Management: %windir%\system32\compmgmt.msc /s
  • Data Sources (ODBC): %windir%\system32\odbcad32.exe
  • Event Viewer: %windir%\system32\eventvwr.msc /s
  • iSCSI Initiator: %windir%\system32\iscsicpl.exe
  • Performance Monitor: %windir%\system32\perfmon.msc /s
  • Services: %windir%\system32\services.msc
  • System Configuration: %windir%\system32\msconfig.exe
  • Task Scheduler: %windir%\system32\taskschd.msc /s
  • Windows Firewall with Advanced Security: %windir%\system32\WF.msc
  • Windows Memory Diagnostic: %windir%\system32\MdSched.exe
  • Windows PowerShell Modules: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -ImportSystemModules

Microsoft Security Essentials is 〔C:\Program Files\Microsoft Security Client\msseces.exe〕

functional languages influence graph

Perm URL with updates: http://xahlee.org/comp/functional_languages_history_diagram.html

Here's a diagram by Michael Fogus:

functional programing languages influence graph
functional programing languages influence graph. Source blog.fogus.me

See also:

  • [Clojure] notes on Mathematica pattern transformation & Clojure predicate dispatch By Kovas Boguta. @ Source grokbase.com

What are some first pattern matching languages?

Note: Michael Fogus is a author of a Clojure book. See: Clojure Books.

Windows Firewall Error code 0x80070424; How to Fix

Perm URL with updates: http://xahlee.org/mswin/MS_Windows_Firewall_Error_code_0x80070424.html

In Windows 7, when i go to the Control Panel and click on Windows Firewall, i got this error:

Windows Firewall can't change some of your settings.
Error code 0x80070424

here's how to fix:

  • Error Code 0x80070424 with Windows Firewall and “Base Filtering Engine Service” Not available in services database list. By Danma_. @ Source blogs.technet.com


Download the following registry files:

There are 2 of them in the zip file:


Open them to import to your registry.

Restart Windows.

Launch regedit. (press 【Win+r】 and type regedit)

Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\BFE

  • Right click on it, choose 〖permissions〗.
  • Click on 〖ADD〗 and type Everyone and click OK.
  • Now Click on 〖Everyone〗, below, select full control and click OK.

Now, launch services.msc. (press 【Win+r】 and type services.msc)

  • Start “Base Filtering Engine” service. (right click on it and chose 〖Start〗)
  • Start “Windows Firewall” service. (right click on it and chose 〖Start〗)

For how i got/noticed this error, see: Microsoft Windows Update Fail KB2691905.

Microsoft Windows Update Fail KB2691905

Perm URL with updates: http://xahlee.org/mswin/Microsoft_Windows_update_fail_KB2691905.html

On , Microsoft Windows Update prompted me for a update. One of the update is marked Important, and it's about updating Microsoft Security Essentials. During the update i lost internet connection. When connection is back few seconds later, i tried to update again. Things seems fine. However, when i restarted my machine, i noticed that Microsoft Security Essentials disappeared, and also, i can't start the Security under Action Center, and can't start Firewall. This page is a record of the story and how to fix.

My Windows machine is Windows 7 Home Prenium, Service Pack 1, 64-bit OS.

Here's a screenshot from the “update history” in Windows Update, showing the update failure due to lost of connection:

Microsoft Windows update fail KB2691905 2012-04-30
Microsoft Windows update failure KB2691905

Here's the text content:

Microsoft Security Essentials Client Update Package - KB2691905

Installation date: ‎2012-04-30,Mon 15:16

Installation status: Failed

Error details: Code 8004FF82

Update type: Important

You can also see this update failure in the log from Windows Update Client. From Event Viewer at 〔Control Panel\All Control Panel Items\Administrative Tools\〕 %windir%\system32\eventvwr.msc /s. 〖Applications and Services Logs▸Microsoft▸Windows▸WindowsUpdateClient▸Operational〗.

- System
  - Provider
   [ Name]  Microsoft-Windows-WindowsUpdateClient
   [ Guid]  {945A8954-C147-4ACD-923F-40C45405A658}
   EventID 25
   Version 0
   Level 2
   Task 1
   Opcode 11
   Keywords 0x4000000000000022
  - TimeCreated
   [ SystemTime]  2012-04-30T22:16:59.162697500Z
   EventRecordID 7800
  - Execution
   [ ProcessID]  428
   [ ThreadID]  2516
   Channel Microsoft-Windows-WindowsUpdateClient/Operational
   Computer h3-HP
  - Security
   [ UserID]  S-1-5-18
- UserData
   errorCode 0x80072efd

The error code “0x80072efd” there means “ERROR_INTERNET_CANNOT_CONNECT”.


Problem: Microsoft Security Essentials (MSE) Disappeared

To fix the MSE problem, just download it again.

Go to http://windows.microsoft.com/en-US/windows/products/security-essentials and re-installed that.

However, 2 other problems i've noticed, am not sure they are caused by this incidence, or perhaps because i didn't notice until now. The problems are:

① goto Control Panel, Action Center. The Windows Security Center Service is turned off. When turning it on, it says:

The Windows Security Center service can't be restarted.

② goto Control Panel, Windows Firewall. Double click on it. The error is:

Windows Firewall can't change some of your settings.
Error code 0x80070424

Windows Security Center service can't be started

Windows Security Center service cant be started 2012-05-02
Windows Security Center service cant be started

There are several Microsoft sites that tries to fix this problem. However, they are extremely confusing, because it depends on whether you are running Windows Vista or Windows 7. In Windows 7, the “Windows Security Center” has become just Action Center. However, Windows 7 still has a program called “Windows Security Center service”.

So, when you check online for solution, make sure the page describes a Windows version on your machine.

Here they are 2 best answers, but didn't work for me:

These solutions didn't work for me because i cannot see “Security Center” in my Services panel.

Problem: No “Security Center” in Services Panel

When going into the Services panel, there's no item named “Security Center”.

Following is a page that fixed my problem. (Check posts by Niki Han. He's a MSFT CSG (Contigent Staff)):

Go there, and download the Registry key fix. at Source cid-9fb18a384ebfc662.office.live.com (this one is for 64-bits).

Run it. Then, restart Windows. Then, go back to Action Center, and now you can start Security.

Windows Firewall Error code 0x80070424

See: Windows Firewall Error code 0x80070424; How to Fix.


Xah's Emacs Goodies

My emacs goodies.

ErgoEmacs Keybinding (with David Capello)
svn checkout http://ergoemacs.googlecode.com/svn/trunk/ergoemacs/ergoemacs-keybindings ergoemacs-read-only

Emacs: Perl PHP Dictionary Wikipedia Google … Reference lookup
wget http://ergoemacs.googlecode.com/svn/trunk/packages/lookup-word-on-internet.el

Emacs Unicode Math Symbols Input Mode (xmsi-mode)
wget http://ergoemacs.googlecode.com/svn/trunk/packages/xmsi-math-symbols-input.el

Emacs Unicode Browser (xub-mode)
wget http://ergoemacs.googlecode.com/svn/trunk/packages/xub-mode.el

Emacs AutoHotkey Mode (xahk-mode)
wget http://ergoemacs.googlecode.com/svn/trunk/packages/xahk-mode.el

Emacs BBCode mode (xbbcode-mode)
wget http://ergoemacs.googlecode.com/svn/trunk/packages/xbbcode-mode.el

Emacs LSL Mode (xlsl-mode) for Linden Scripting Language
wget http://ergoemacs.googlecode.com/svn/trunk/packages/xlsl-mode.el

• grep util in elisp. (draft version)
wget http://ergoemacs.googlecode.com/svn/trunk/packages/xah_file_util.el

Emacs Lisp: get-selection-or-unit
wget http://ergoemacs.googlecode.com/svn/trunk/packages/xeu_elisp_util.el

Emacs Lisp: Multi-Pair String Replacement Function
wget http://ergoemacs.googlecode.com/svn/trunk/packages/xfrp_find_replace_pairs.el

Your donation is appreciated.

misc emacs lisp tutorials update

Several updates in past months:


Confusing Terminology in Javascript/DOM: tag, element, node, object, attribute, property, method

Perm URL with updates: http://xahlee.org/js/javascript_DOM_confusing_terminology.html

Javascript/DOM scripting is really confusing. You have terms like {tag, element, node, object} and then {attribute, property, method}.

• “tag” is really the informal term for “name of a node”, or it may refers to the string {<…>, </…>}. e.g. we say “opening tag”, “closing tag”. Am not sure it's officially defined.

• “element” is the official/formal term for technically a node of a html document. e.g. represented by the string <p>something</p>.

• “node” refers to a node of DOM, but in practice, it more often refers to a element of XML (as opposed to HTML). However, note that the text content of a HTML/XML element is also a node. e.g. the “xyz” in <p>xyz</p> is a child node of the element “p”. So, node isn't just element. By W3C spec, the empty spaces between elements are actually a node too, but browser implementation differs.

• “object” is basically a parsed node in browser. But in another sense, technically, it refers to certain things in DOM, e.g. {location, navigator, window, clientInformation, clipboardData, documentType, …}.

• “attribute” is basically a property of a node in HTML/XML. Mostly, it refers to things like {id, class, href, width, height, title, …} of a HTML element, or arbitrary such in XML. e.g. in <x y="z">3</x>, the “y” is a attribute.

• “property” in DOM is more general, e.g. { .length, .name, .nodeName, .parent .onclick, .baseURL, .characterSet, .color, …} are all properties.

• “method” can mean javascript's OOP methods, or it can mean a method in DOM, which is often also a “property” of a node. e.g. nodeName is a method and also a property, but getElementById is a method, not property. In some sense, you can think of property as a OOP method that doesn't have any argument.

all these terms are not used consistently among docs (e.g. Mozilla vs Microsoft), and am not sure they even have precise definition.

What do you think? Corrections? Any references for better explanation?

Javascript: Get a Element's {Type, Name, Value}

Perm URL with updates: http://xahlee.org/js/js_get_node_info.html

This page shows you how to get a HTML/XML element's {type, name, value}.

Node Type

Use ‹node›.nodeType to get a element's type. The ‹node› is a HTML element object.

The return value is a number. Usually 1 or 3. “1” means it's a HTML/XML element. “3” means its content.

Here's a complete list:

  • TEXT_NODE → 3

sample code:

var xx = document.getElementById("id63656");

alert("type is:" + xx.nodeType);

alert("firstChild type is:" + xx.firstChild.nodeType);

javascript test page: nodeType.

As of , this works in all major browsers.

Node Name

‹node›.nodeName returns the node's (tag) name (as string), if the node is a element node (nodeType returns 1). If it's a text node, the value is "#text". See references for all possible values for different types of node.

var xx = document.getElementById("id43160");

alert("name is:" + xx.nodeName);

alert("firstChild name is:" + xx.firstChild.nodeName);

javascript test page: nodeName

As of , this works in all major browsers.

Node Value

Use ‹node›.nodeValue to get the content of text node. For most other node types, it returns null.

var xx = document.getElementById("id82521");

alert("node value is:" + xx.nodeValue);

alert("firstChild node value is:" + xx.firstChild.nodeValue);

javascript test page: nodeValue

To change a html element's content, you can just set “nodeValue” to some text. See: Javascript: Changing HTML Content Example.

As of , this works in all major browsers.

GNU Emacs Bug: find-dired on Filenames with Spaces

Perm URL with updates: http://xahlee.org/emacs/emacs_bugs.html

GNU Emacs Bug: find-dired on Filenames with Spaces

when using GNU Emacs, calling find-dired, i got one of this:

  2533274790481547    2 -rwx------   1 h3       None         2994 Apr
28 20:52 xx\ saga\ of\ bsof\ 2011-07-22.html

note the backslash there.

when i move the cursor to that line and press Enter, i get:

dired-get-file-for-visit: File no longer exists; type `g' to update
dired buffer

update doesn't help. Somehow, filenames with spaces causes the problem.

The problem also happens when calling dired-do-query-replace-regexp Q. It'll stop dead reporting file doesn't exist.

What could possibly be the problem?

GNU Emacs (i386-mingw-nt6.1.7601) of 2012-04-23 on MARVIN

(if starting emacs with -Q, then another problem occur. It calls Microsoft cmd.exe's find.

Math: Grigori Perelman videos

Perm URL with updates: http://xahlee.org/math/Grigori_Perelman.html

you are looking at a guy who solved a million-dollar math problem but turned it down.

Grigori Perelman in shopping market
Grigori Perelman walking on street
Grigori Perelman on subway
Grigori Perelman on subway