web hosting service with virtual machine

woot! just activated my digitalocean account. It's a web hosting service using virtual machines. Meaning, you have a whole linux box to yourself, as a dedicated box, with root access. So, you can do anything you want. Ruby, Rails, ngixn, Node.js, anything, or just play with it. They run it on solid state drive.



programing language: closure should be ban'd

slightly updated. Python: Function with State (closure-like)

btw, hacker-type of programers will probably object, saying that the techniques on that page isn't “closure”. However, if you consider closure as purpose, then it amounts to a function with state. Python can do real closure, which is a function with a “closed off” variable environment. Will have to write a tutorial on that another day. (if you want to know, a web search should easily find you tutorials on that)

see also Python Scope Complexity, Shallow Copy, Deep Copy, Circular List, and the Garbage Underneath Computer Languages

“closure” in programing is something i truely despise. Because it creates a complexity level that's voodoo. All it achieves is function with state. First of all, function with state should be avoided. But if you really want, OOP is a systematic way of function with state, use OOP then. Or, in some languages, use the property of a function, such as in lisp or in JavaScript. 〔☛ Emacs Lisp Symbol (tutorial)〕 〔☛ JavaScript: Closure, and Function with State〕 If you don't want OOP, then, just use global vars with a special scheme of naming them, such as starting with 2 underscore “__” and end with a random id. 〔☛ What's Windows CLSID? Second Life UUID?〕 In fact, many languages uses this scheme to do things. Python has special variables that has underscore in its naming, ⁖ __name__, Mathematica has internal variables name$random string as used by Module[] function to generate local variables. http://reference.wolfram.com/mathematica/ref/Module.html

here's real closure in JavaScript JavaScript: Closure, and Function with State


♥ JavaScript, Node.js, socket.io ♥

thanks to friends on g+, discovered Socket.io

Socket.IO is a JavaScript library for realtime web applications. It has two parts: a client-side library that runs in the browser, and a server-side library for node.js. Both components have a nearly identical API. Like node.js, it is event-driven.

Socket.IO primarily uses the WebSocket protocol, but if needed can fallback on multiple other methods, such as Adobe Flash sockets, JSONP polling, and AJAX long polling,[2] while providing the same interface. Although it can be used as simply a wrapper for WebSocket, it provides many more features, including broadcasting to multiple sockets, storing data associated with each client, and asynchronous I/O.

It can be installed with the npm (node packaged modules) tool.[3]

if you have Node.js's npm installed, npm install socket.io

JavaScript, Node.js, am in heaven. Screw perl, python.


♥ Ryan Dahl, mathematician turned programer ♥

been wanting to write this for a while. The node.js creator, Ryan Dahl, i really like. He's a mathematician originally, doing his phd. (i forgot exactly what topic, anyone? algebraic topology or something)

Anyway, i've watched about 5 of his video presentations over the past year year, and read several of his article, opinions on languages and software, and studied his creation node.js.

i really like this guy. This guy, his opinions, are somewhat controversial. But, i find that, his thinking, and views on software, is quite in sync with mine.

i think possibly this is because we are both math guys first. He's never took any computer course. Nor i.

i don't speak for all math guys, but, for me, coming to programing, most of it is pure complex garbage. The coders, in particular unix, perl, python, they don't know what they are talking about. Different ideas are extremely hard to get to them, as i've written few thousand articles on various aspects. 〔☛ Computing & its People

also, note that, mathematicians don't think alive themselves. In fact, there are also camps of extreme opposite styles who don't like the other.

Python creator, Guido, is also a mathematician (don't know exactly to what extent. If he simply has a math digree, that kinda doesn't count.). But, i think he may be a coder before he is a mathematician. His thoughts on computing, stabs mine in every way.

Knuth is a mathematician. Though, i didn't like his thoughts much.



beauty and the beast: what's the evolutionary psychology's reason for men preferring beautiful women?

saw a tweet on Chinese weibo, saying that the worst is for you (men) to worry about your looks, because, women don't care. They care about your ability, personality, your commitment to her.

true enough. (is this critically true? well, i think so, but not gonna worry about that now) What got me thinking, is what's the reason that men care about women's looks, but in particular, she be beautiful, not just young.

men like young, and that's because only young ones have more chance of reproduction. But why beautiful? well, youth and beauty are connected, but, the thing is, say there are 5 college teens walking on a street, and say one has the looks of models, but the others are rather ugly. The most beautiful one will be our focus. What's the evolutionary psychology's explanation for this?

O, btw, have you heard of “beauty and the beast”? It's a perennial tale, in fairy tales, folk lores, or today, in movies, novels, posters, comics. (⁖ phamtom of the opera) Male, can be extremely ugly, even a monster, and there can be love between him and a most beautiful girl. However, you never hear a story of a hero loving a ugly or old woman. This reflects our behavior.


Xah's Sex Blog

JavaScript declaration and assignment

JavaScript. Multiple variables can be declared on the same line, separated by comma var name1, name2, name3 …;

// declare variable, use 「var」
var x;
var y;

// multiple variables can be declared on the same line, separated by comma
var a, b, c;

Multiple variables can be declared and assigned at the same time.

// declare variable and assign
var x = 4;

// declare variable and assign multiple variables
var a = 1, b = 2, c = 3;

When a variable is declared but not assigned, the default value is undefined.

When a variable is not declared nor assigned, and you try to access it, you get ReferenceError.

var x;
console.log(x); // prints 「undefined」
console.log(y); // ReferenceError: y is not defined


Teary Eyes, a Need for Intimacy

the primary purpose of tears in weeping is to signify a need for intimacy.

for adults, typically, it's attractive when done by female.

you can see, in media, for example Miley Cyrus's 〈Wrecking Ball〉 featuring big blue eyes with tears. And also, in Lady Gaga's 〈Bad Romance〉

see also Reading Notes on 《Intimate Behavior》



Wilt Thou Gallantly Tilt at Windmills

Tilting at windmills is an English idiom which means attacking imaginary enemies. The word “tilt”, in this context, comes from jousting.

The phrase is sometimes used to describe confrontations where adversaries are incorrectly perceived, or to courses of action that are based on misinterpreted or misapplied heroic, romantic, or idealistic justifications. It may also connote an importune, unfounded and vain effort against confabulated adversaries for a vain goal.

Wilt Thou Gallantly Tilt at Windmills?


Writing Programing Tutorial vs Coding a Project

writing programing language tutorial isn't easy, and is extremely time consuming. Suppose you are reading a book or a doc. In few minutes, or even after a hour with coding, you understood it, and can employ it right away in your project or job. But, if you want to write a tutorial of what you just learned, it'll take 10 folds more time. Because, first of all you have to give context of why, and this aspect often takes some research by itself. Then, you have to have a good understanding of the whole instead of just the parts you just understood, because otherwise its like the blind men feeling the elephant and you can't say to readers that a elephant is pillar-like and period (this happens to haskell monad blogs). Then, you need to give good examples. Proper ones, and ones that are idiomatic, industrial accepted. So, it's like you have to have a survey of sorts, either from experience or have read tons about it. And, if you are like me, have idiosyncratic bent on things, you need to put things into style yet respect all the above mentioned issues. That doubles or triples the time and effort.

note that, this is not to imply that coding a project is easier. They are quite different endeavors. For example, if you are coding a project, once you read something, you can put to use right away, but, then you have 100 other details and complexities you need to solve, that you otherwise don't have to deal with if you are writing a tutorial. Tutorials typically deal only with clean, crystallized, account.

comment on g+

JavaScript Unicode Search box

major update on unicode search. You can search by name, codepoint (decimal or hexadecimal) or paste in Unicode characters. Search is now real-time. Result shows as you type. For example, try to find unicode related to christmas. 🎄 🎅.

Use the search box at Unicode Symbology ☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥

unicode search screenshot 2013-12-17
Unicode search screenshot


JavaScript Name Hosting and One-Liner Functional Style

JavaScript has name hosting. 〔☛ JavaScript: Variable & Function Declaration Order: Name Hoisting〕 and i think Douglas Crockford recommends to move all vars to the top, to reflect reality.

but look at the following code. Moving all var to the top would be silly.

function displaySearchResult (charArray, anchorNode) {
    // clear the result first
    while (anchorNode.hasChildNodes()) {

    if ( charArray.length === 0 && searchBox.value.length !== 0) {
        var noResult = document.createElement("span");
        noResult.innerHTML = "none found. Try type more characters, or try “star”, decimal search “#97”, hexadecimal search “#x61”, or enter a Unicode “♥”";
    } else {

        for (var ii = 0; ii < charArray.length ; ii++) {

            var uNum = charArray[ii];
            var uHex = uNum.toString(16);
            var uChar = String.fromCodePoint(uNum);
            var uName = unicodedata[uNum];

            var resultItem = document.createElement("table");
            resultItem.innerHTML = "<tr><td><span style='font-size:6ex'>" + uChar + "</span></td><td>" + uNum + "<br />x" + uHex + "</td></tr><tr><td colspan='2'>" + htmlEncode(uName) + "</td></tr>";

            resultItem.style.border="solid thin red";

        } }}

i think to solve this, one'd do heavy functional style instead. That is, often just eliminate variables all together.

For example, this block:

var uNum = charArray[ii];
var uHex = uNum.toString(16);
var uChar = String.fromCodePoint(uNum);
var uName = unicodedata[uNum];

var resultItem = document.createElement("table");
resultItem.innerHTML = "<tr><td><span style='font-size:6ex'>" + uChar + "</span></td><td>" + uNum + "<br />x" + uHex + "</td></tr><tr><td colspan='2'>" + htmlEncode(uName) + "</td></tr>";

would be rewritten as:

resultItem = document.createElement("table");
resultItem.innerHTML = (function(uChar, uNum, uHex, uName ){return "<tr><td><span style='font-size:6ex'>" + uChar + "</span></td><td>" + uNum + "<br />x" + uHex + "</td></tr><tr><td colspan='2'>" + htmlEncode(uName) + "</td></tr>"})( charArray[ii], uNum.toString(16), String.fromCodePoint(uNum), unicodedata[uNum] )

yep. I think that's what i'll do. How this reminds me my Mathematica code days. My Mathematica code is all like that.

g+ discussion https://plus.google.com/+XahLee/posts/776XQf46CvZ


JavaScript syntax soup: 「p in o」

another episode of syntax soup. In JavaScript, you have p in o and for (var p in o) {…}. The first looks the same as part of the second, but have completely different semantics.

Soup. Soup. Soup. It's All Soup.


Stereographic Projection & mobius transformation

Stereographic Projection & mobius transformation。 If you want to understand Einstein's theory of relativity, you must understand mobius transformation. To understand mobius transformation, you must first understand Riemann sphere, complex numbers, geometric inversion.

stereographic projection by Henry Segerman 2013-12-12
stereographic projection by Henry Segerman


see http://xahlee.info/math/stereographic_projection_physical_model.html

wikipedia controversies

wikipedia is not without controversies in its reliability. However, in general, if you are a learned man, and read it frequently, you basically know by heart which parts is not trustworthy.

when you are a learned man (as in, you have several degrees, or is a scholar, and often minimally knowledgeable in diverse fields from sciences to humanity, such as philosopher), you can basically tell when you read something that came across as funny, wikipedia or not. Because, you know what you know and what you don't know, and you have good experience of seeing questionable writing.

And, if you do use wikipedia a lot, you also know which type of article, or part of the writing style, is red ink.

gratuitous links:


Python: Example of Using Sets

Python: Example of Using Sets

# -*- coding: utf-8 -*-
# python

# utility to show the difference of JavaScript's encodeURI and encodeURIComponent functions

# 2013-12-09

digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}

letters_upper = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}

letters_lower = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}

printable_ascii = digits.union(letters_upper, letters_lower,
{'!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/' , ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~' })

encodeURIComponent_not_encoded_ascii_chars = digits.union(letters_upper, letters_lower, {"""-""", """_""", """.""", """!""", """~""", """*""", """'""", """(""", """)"""})

encodeURIComponent_encoded_ascii_chars = printable_ascii - encodeURIComponent_not_encoded_ascii_chars

encodeURI_not_encoded_ascii_chars  =  digits.union(letters_upper, letters_lower,
{"""-""", """_""", """.""", """!""", """~""", """*""", """'""", """(""", """)""", """;""", """,""", """/""", """?""", """:""", """@""", """&""", """=""", """+""", """$""", """#"""})

encodeURI_encoded_ascii_chars = printable_ascii - encodeURI_not_encoded_ascii_chars

print encodeURI_encoded_ascii_chars

see JavaScript Encode URL, Escape String


do you understand the lang well before you use frameworks?

normally, the way a programer uses a lib or framework is that he already knows the lang well, so uses the lib that makes it convenient. However, that doesn't seem to be the case with JavaScript jQuery, or lots other framework in JS or other lang, these days.

these days, many programers just learn the framework, without knowing the language well. I think this is particularly so with JavaScript and Ruby.

is this good or bad?

in one sense, obvious bad. The sign of times, when idiots reign on earth…

but perhaps that's actually progress. Who understand how sine, cosine is implemented? raise your hand.


Wolfram Language and Lisp, Clojure

every developer should buy a copy of Mathematica, because it will expand their mind. —Rich Hickey (clojure inventor)

Wolfram language is on the news recently.

  • Something Very Big Is Coming: Our Most Important Technology Project Yet By Stephen Wolfram. @ blog.stephenwolfram.com…
  • Putting the Wolfram Language (and Mathematica) on Every Raspberry Pi By Stephen Wolfram. @ blog.stephenwolfram.com…

Mathematica is very similar to lisp. Every concept of lisp has a counter-part in Mathematica. Symbols, atoms, read/eval/print loop, symbol properties, nested expression (sexp and Homoiconicity), macros (in M it's far more advanced, called pattern matching (but Haskell and Ocaml's Pattern Matching not like M, because M work on symbols, as do lisp macros)), even package system is akin to Common Lisp.

if you want to get a sense of what the lang is like, watch this video:

Kovas Boguta — session — Clojure NYC Meetup 20120516. From Tom Hickey, 2012

Mathematica part start at 5:50 to 18:00.

for more detail about Mathematica from the perspective of lisp, see


What Does “Formal Method” Mean?

one abuse of term in math & programing is “formal”, ⁖ formal methods, formal proof. In practice, people meant roughly “more rigorous”. But, it has a more technical meaning: formal in “formal language”, Hilbert “formalism”, the “form” of formulas, calculational proof.

when programers mention formal methods, ⁖ lisper, haskeller, pythoner, please help better the world by shoving a cucumber in their mouths.

see also Math Notations, Computer Languages, and the “Form” in Formalism


Guido Says: Python 3 Things Still Unsolved: Multi-Line Lambda

lol. In Guido's python 3 retrospect, his last item is: “Things still unsolved: Multi-line lambda”.

Python 2 vs. Python 3: A retrospective By Guido Van Rossum. @ www.dropbox.com…

See also:

Example of JavaScript Sort Method Using Custom Sort Function

Example of JavaScript Sort Method Using Custom Predicate

// array sort example
var aa = ["a1", "a70", "a8", "A2"];

// default sort. element compared as string
console.log(aa);                // [ 'A2', 'a1', 'a70', 'a8' ]

// sort by comparing as numbers after first char
console.log(aa);                // [ 'a1', 'A2', 'a8', 'a70' ]

function ff (x,y) {

    var nx = parseInt(x.slice(1)); // remove first char. consider rest as number
    var ny = parseInt(y.slice(1));

    if ( nx < ny ) { return -1; }
    if ( nx > ny ) { return 1; }
    if ( nx == ny ) { return 0; }

see more at JavaScript Array Methods


How to Connect BlackBerry PlayBook to Linux

Perm URL with updates: http://xahlee.info/comp/blackberry_playbook_unable_to_delete_file.html

  1. • plug in the USB between PlayBook and Linux machine.
  2. • on PlayBook, go to 〖About〗, find the USB IP address of the PlayBook. In the About screen, the Network menu. Note, it's the USB'S IP address, not the wifi ip address.
  3. • on PlayBook, go to 〖storage & sharing〗, set the menu “USB Connections” to “Connect to Window”. In the “File Sharing” section, turn it on.
  4. on Linux, just open a folder, and in the address type smb://, where the IP is your IP.

BlackBerry PlayBook is the worst tablet.


the phenomenon of selfy

the phenomenon of selfy

since tech advanced to the point where everyone had a camera carried in their pocket, there's a phenomenon called “selfy”. That is, people taking a photo of themselves. And, in particular, in the context of male vs female, it's always the girls, who do that. Not just normal photos, but also nude photos of themselves. #feminism

Kim Kardashian tits and ass
Kim Kardashian tits and ass. from her own blog, img src


Math Terminology: Magma vs Groupoid

Math Terminology: Magma vs Groupoid

The term magma for this kind of structure was introduced by Nicolas Bourbaki. The term groupoid is an older, but still commonly used alternative which was introduced by Øystein Ore.

why did the Bourbaki guys introduce the term magma? it seems to me groupoid is a better term. Was it introduced to avoid confusion due to the many slightly different definitions of groupoid?


The Death of Perl, UML, Design Patterns, eXtreme Programming

there are few things am rather happy in my programing career.

  • the death of Perl.
  • death of UML, eXtreme Programing, Design Patterns.
  • death of Sun Microsystems.

those are scums lying thru their teeth.

am looking forward to the death of Agile, MySQL, Apache.

Apache is experiencing slow death by nginx, node.js. 〔☛ Tech Humor: Apache vs Node.js vs NGINX 📺〕 MySQL is getting killed by Oracle — how ironic. Agile is a lingering mutation of eXtreme Programing. 〔☛ EXtreme Programing and Agile Voodoo

Justice — feels good.


how much you'll get for writing a programing book?

how much you'll get for writing a programing book?

maybe $2 per book, and if you are successful, you might sell 4k copies.

how long does it take to write it? half a year to a year or more, full time work.



lady justice kissing lady liberty

gay marriage ruling cartoon by Nate Beeler 2013-06-26
gay marriage ruling cartoon by Nate Beeler . img src

Lady Justice (Latin: Iustitia, the Roman goddess of Justice, who is equivalent to the Greek goddess Dike) is an allegorical personification of the moral force in judicial systems.

In ancient Greek culture, Dikē (Greek: Δίκη, English translation: “justice”) was the spirit of moral order and fair judgement based on immemorial custom, in the sense of socially enforced norms and conventional rules. According to Hesiod (Theogony, l. 901), she was fathered by Zeus upon his second consort, Themis.

The sculptures of the Temple of Zeus at Olympia have as their unifying iconographical conception the dikē of Zeus, and in poetry she is often the attendant (paredros) of Zeus. In the philosophical climate of late 5th century Athens, dikē could be anthropomorphised as a goddess of moral justice. She was one of the three second-generation Horae, along with Eunomia (“order”) and Eirene (“peace”):

Dike (mythology)


Angry Birds on the Plane

there's a dude sitting besides me on the airplane, playing Angry Birds on iPad. All of a sudden, he shouts: “i've got 2 bombs, go to hell you stupid pigs”. I jumped, and all other passengers wet their pants.

飞机上有个二逼坐我旁边用iPad玩愤怒的小鸟,玩着玩着突然激动地大吼一声:“我有两个炸弹!都他妈死吧蠢猪们!”当时吓了我一大跳…… 那天飞机上的其他乘客也都吓尿了...... (from xie107)

Hacker News Hit Traffic Effect

Hacker News Hit Traffic Effect

yesterday's Hacker News hit, 5.5k visits. 〔https://news.ycombinator.com/item?id=6056420〕 Last time in April hit is 4.5k visits. 〔https://news.ycombinator.com/item?id=5536134

About 50% are using Google Chrome. 26% Firefox. 8% IE.


BlackBerry Tablet Browser Sucks: CSS rel attribute match support

amazing, in this day of age, the BlackBerry tablet doesn't support this CSS:

a[rel="next"]:before {content:"▶ ";font-size:2ex}
a[rel="up"]:before {content:"▲ ";font-size:2ex}
a[rel="previous"]:before {content:"◀ ";font-size:2ex}

the CSS above is supposed to match navigation links such as this:

<a rel="previous" href="a.html">a</a>
<a rel="up" href="b.html">b</a>
<a rel="next" href="c.html">c</a>

It should marke each nav link with a proper Unicode triangle, like this:

css nav link rel screenshot 2013-07-15
nav bar screenshot

but in BlackBerry, all links are marked with ◀.

test here: Blackberry Tablet Rel Next Link Css Test

〔☛ CSS 2.1 & CSS 3 Selector Syntax

The browser on BlackBerry's user agent string is:

Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/ Safari/536.2+

Modern Hipster Obsession

today, the super popular Oatmeal comics has this piece: 〔The terrible and wonderful reasons why I run long distances - The Oatmeal By Matthew Inman. @ theoatmeal.com…

it's a long one, some 10 pages in 5 parts.

in the end, he linked to his blog about his toenail falling off. See photo here http://theoatmeal.com/blog/ultramarathon

that's strange and pretty sick to look at. Is toenail problems some sort of common problem for marathon runners?

it's a enjoyable comic, and inspiring. However, if you are like him, it's call pathetic. Running obsession like that as he does is a symptom of psychological problems, just as body builders or gym goers that he dissed.

and, now the Xah American say. In rich countries, such as US, the online hipsters worry about being fat. People do “try-something-new-for-30-days”, people invent foodies, yelp, these hip and well-fed and got-nothing-to-do folks, tries to live a healthy living, wholesome life, tries to help blacks, tries to save the world, tries to not be fat and ugly. But they, ‘tis they, who could not diss with their money, who will not shut up in disagreement, could not help a stranger near by, could not do without their 4-wheel drive luxury trucks, could not put away their fancy devices.

give your money to me. Paypal to xah@xahlee.org

Unicode Naming: Slash or Solidus

Unicode changed the name of slash “/” to from “SLASH” to “SOLIDUS”. Is this a good name change?

here's other slash symbols in Unicode:

/ \

See also: Unicode Search: Find Your Symbols

Why's vi's ADM-3A Terminal Chose {H J K L} Keys for Arrows?

you know how the vi keys came from the ADM-3A terminal's keyboard? but do you know why THE KEYBOARD chose {h j k l} instead of say {i j k l}?


Strange Phenomenon in Chinese Microblogs: Images Instead of Text


There's a curious phenomenon in Chinese Weibo (microblog). That is, normally the character limit is to make user's post dense and focused. However, Chinese people started to use image instead for long Chinese articles. The transmission size of a image is a thousand times greater than text, and it can't be searched, nor resized clearly. Strangely, English microblogs such as twitter haven't developed this phenomenon.


Will #lgbt and Feminism Become Passé?

recently i realized, the #lgbt (lesbian gay bisexual transsexual) kinda stuff is not going to end. Actually, lgbt will come to pass sooner or later, but women's jostling for power with men is not going to end, which once known as feminism.

this is because, tech will not cease advancing, making muscle not necessary, and women will continue to hitch a ride in the power ladder.

the #lgbt kinda thing that's so hot in recent years, will pass as zeitgeist, however. Because, gay and the tranny stuff is only a minuscule percentage of human animals. Currently, gay borrows tranny for a ride, and feminism borrows lgbt for a ride. Gay and Tranny stuff can't last.

but female's struggle for more power, will not cease, because, women, the half of human animal, doesn't have inherent sexual difference from men in hunger for power. The fashionable terms may change, but essentially #feminism will keep going for a decade, 2 decades, 10 decades...

sex will become just a pure pleasurable activity, evermore. At some point in the future, marriage will disintegrate as well. The gay marriage today paved the way.

but what about our genes? i.e. females being feminine and male being masculine, in the genes? our genes don't change over night. So i suppose in the next hundreds of years, most women will still be into womanly things, soft, gentle, benign, submissive, and same with man with power, aggression, ruthlessness. These will not change, and they will forever be the big conflict for women's power struggle in sex politics.

what about Asian countries? where men and women are ok with what we are? humm…, am not sure what'd happen there. Feminism's been around heavy and strong in western countries in past decades, but they don't seem to have changed Asian much.

See also: Why Did Feminism Arise?.


JavaScript Object's Properties Are Strings

remember, in JavaScript, Objects are just unordered key/value pairs. And the keys are string, cannot be numbers. (the value can be any type) If you have o = {2:7, 3:4}, the keys are still strings, because JavaScript automatically does number to string conversion.

here's a example.

o = {"a":7, 2:4}
var k = Object.keys(o);

console.log(typeof(k[0]))       // string
console.log(typeof(k[1]))       // string


Emacs Regex Advantages, Whitespace Syntax & Semantics Complexity in Computer Languages

Emacs Regex Advantages

emacs regex is usually a pain, but it has advantages.

today, i need to change text like this:


to this:


Basically, i need to remove newline chars, and only if it is inside the “p” paragraph tag, and only when that text is Chinese, not English.

there are few hundred of such pages i need to do this.

Emacs regex has a nonascii character class. So, i can use this regex:


and replacement is this:


〔☛ Emacs: Text Pattern Matching (regex) tutorial

I looked at Python, it doesn't have a named char class for Unicode. Though, am sure one can use a char range. Perl does support Unicode char class, same syntax as emacs, which is POSIX regex. Am not sure if it's added in recent years or existed around 2000.

Syntax, Whitespace, Programing Languages

Note that this is important, because otherwise browser will render a gap when there is a newline, and for Chinese text, it's very annoying. There is no way to use CSS to remove such gap.

And here we have a interesting issue. Namely, the semantic of whitespace among languages.

in HTML, it's quite complex. Newline char can be equivalent to space, and multiple spaces can be equivalent to single space, and newline char at beginning/ending of a tag has special meaning. See: Programing Language Design: Syntax Sugar Problem: Irregularity vs Convenience. Only some of these semantic complexity can be adjusted by CSS, but there's no systematic rule to know which can and which cannot, see: CSS Text Wrapping Tutorial.

In other languages such as Perl, Python, Ruby, it's also very complex. See: What Does it Means When a Programing Language Claims “Whitespace is Insignificant”?.

Should Programer Keep Lines to 70 Chars?

another interesting aspect this touches on is the habit of cutting lines at every 70 char or so.

as you can see, for Chinese language, doing that is unacceptable. Gaps in Chinese can effect semantics. Gaps at wrong place changes meaning. Because, ancient Chinese started not having any punctuation, then later one gaps are used for punctuation. Today, gaps can still be used for punctuation, especially for verse or title.)

note that emacs usually have problems when the lines are very long. This is due to deeply ingrained implementation of unix habit of cutting lines.

Also, it's interesting that emacs's fill-paragraph command behave correctly on this. That is, when the neighboring chars around newline are Chinese characters, emacs simply remove the newline, instead of replacing it with space.

So, this means, another approach to solve this problem is to programmatically call “unfill-paragraph”. 〔☛ Emacs unfill-paragraph, unfill-region, compact-uncompact-block

HTML Meta Language Tag Obsolete

the meta language tag:

<meta http-equiv="content-language" content="zh">

is now obsolete. See: http://www.w3.org/TR/2011/WD-html-markup-20110113/meta.http-equiv.content-language.html

instead, use the “lang” attribute, like this:

<body lang="zh">…</body>


Douglas C Engelbart Died

Douglas C Engelbart died yesterday, on July 2nd. 1925 〜 2013. 88 years old.

he invented the mouse 〔☛ Computer Mouse, Trackball, Input Devices〕, and is a pioneer of computer networks.

I figured since i write so much about keyboard and mouse, i should mention it.

See this interesting post to learn more about him. 〔Engelbart's Violin By Stanislav. @ www.loper-os.org…

Paris Hilton, on Sexual Competition Among Primates

ran into a pop love song today, sung by female. One of its salient vocal goes like this:

I can do what she can do so much better

and, what a wonder, it's a song by Paris Hilton.

Unicode Navigational Pointers

👆 👇 👈 👉

🔙 🔚 🔛 🔜 🔝

These are new in Unicode 6 i think. If it doesn't display, get the font, see: Unicode 6 Emoticons and Supporting Fonts. For many other arrows, see: Unicode: Arrow Symbols ← → ↑ ↓


Emacs Lisp, Coding Style, Language Idioms, Controversy

now and then, i get criticisms on my emacs lisp tutorial. They point out that i'm not following convention. Most of the time, they just pointing out that my trailing parenthesis are not tugged into a single line (aka hanging parenthesis). Other common complaints is that my code is not idiomatic.

I appreciate criticisms, and welcome negative ones. Though, coding style and idiomatic programing are two aspects of programing i've put a lot thought in, more so than most programers.

In summary:

  • Coding style conventions are mostly harmful. The language's syntax and semantics should naturally enforce it.
  • Idiomatic programing are harmful. It should be ban'd, except the type of idiom that has a non-trivial effect on algorithm or computational complexity.

here's some excerpt from discussion on Google Plus thread

+Nick Alcock +Elias Mårtenson i think the concept of code formatting style is harmful, for a lang with regular syntax, such as lisp, xml, Mathematica. In the latter two, one don't hear much about code formatting style, yet we see it heavily in lisp. That impedes awareness and real progress of automatic formatter.

Programing: Lisp: Automatic Code Formatting, Lint, Auto Indentation

idioms are not that good to have in a lang. Similar in natural languages. They are basically quirks, irregularities, ad hoc, and hard to learn.

i think there's one type of idiom that's very good, that is, the type that effects algorithmic complexity (due to the lang's quirks and implementation detail). For example, python string are not mutable, so when one needs to append string in a loop, one use a list instead, then convert it to string.

Programing: Why Idiomatic Programing Are Bad

see also the article by Zed linked at bottom. He goes over Ruby.

for my tutorial, sometimes am sloppy, and the code is a learning process as well, and sometimes there's pedagogical constraints. I do appreciate comments, as well as criticisms. Thanks.

+Elias Mårtenson yes, what you said is true. I agree. I've been there.

though, we can look deeper in this.

Idioms, just as in natural languages, are unavoidable. They develop naturally too. However, too often, we see the elitist type of programers, who insist on idioms. It's more about cult formation. This point Zed covered well. Often, these elitist programers do not see the nature of idioms, and kept on spreading something that's more coolness and fashion than real substance. Perl community is the best example of this. As such, it's like fashion, it comes and go.

what i wanted to point out in that essay, is a illustration that idioms are actually just quirks. Lang X speaker may not notice it, and thinks everyone must use it, but to all other speakers who are outsiders of X, they simply see it as full quirks and special cases, something that is not appetizing.

Again, idioms are not avoidable, but the zest for idioms, as typically seen in programing communities, are over-zealous.

as i mentioned, there is one type of idiom i can think of, that we should encourage their use. Namely, the type that makes a difference in algorithmic complexity. And the python immutable string case i posted before is a good example.

meanwhile, what i wanted to impart, is that as programers or languages designers, idioms should be actively avoided.

on elisp, i disagree somewhat with your stance, or in general with established norm. Note that, most conventions in programing, are simply habit, historical baggage. This includes formatting lines no longer than 80 chars.

the lisp convention of parenthesis placement, is also a problem. Because, such convention lessen awareness of automated formatting. Thus, we have thousands of style guides and arguments about it, while, a automated system don't come to mind. This is especially ironic for lang with regular syntax such as lisp. Meanwhile, in XML, Mathematica community, they almost never talk about code formatting, because it's automatic and transparent to the user. This should happen to lisp. I usually do tug in my trailing parenthesis, but i just don't take the extra mile to specifically care for this, because i consider it harmful to spread this lisp lore of certain formatting style.

why should we, tell each other about formatting, and spend the thousands hours manually do so perhaps with help of paredit, when we could have it to automatically and transparently?

some of these points i've been arguing with lispers in comp.lang.lisp for a decade. I have also written tens of articles on my site. It's a issue i'm afraid that cannot come to agreement, unless someday science based study on this became common. So, what you and many lisper's criticism of my elisp code i'm fully aware. Some are due to my code quality, but many are that way intentionally. We should throw out old precepts based on scientific validity. Newer generation usually adopt new style, without even thinking about it. (Clojure comes to mind, many Common Lispers just don't like Clojure or anything that's not Scheme or Common Lisp. It's more about habit than anything.)

in summary, idioms are necessary, but by itself is not a good thing. Good idioms are those have computational effect on the code's performance.

code formatting, should be entirely eliminated. And this effects the direction of language design too. Language's syntax, its chars, should have semantic markup builtin. This is so with Lisp and Mathematica and XML (in Lisp and Mathematica, the bracket characters carries a semantic info of code unit. In XML, it's a specific syntactical pattern)). For these languages, editors should be able to do it in real time, automatically, and transparent to user.


lisp cult

i damn hate the lispers, in particular, old Common Lispers. Sputtering scientifically baseless shit.

programing lang communities need more science. Not lore, convention, cult dogma.

it is incredible, that lisp monotonic syntax is a problem seen by all non-lispers and expert lispers, but the lisp cult insists no problem.

then, lispers sing macros, but none ever seen Mathematica pattern matching.

lisper insists regular nested paren, data is code shit, yet when u point out it's not regular, they say it's ok.

while, lispers don't seem to see the XML, Mathematica, both have more regular nested syntax, and code is data too.

it's helpless, because years after year, the cult cultivates untruth. Thoughts are ingrained. like religion.

that concludes my Sunday spam


Math: Symmetry, Flatland, by Ian Stewart

A new book. 〔Symmetry: A Very Short Introduction By Ian Stewart. amazon

It cited my work: Discontinuous Groups of Rotation and Translation in the Plane. ☺

Ian Stewart is a well-known mathematician. He has written many books introducing interesting math to the laymen. Including:

  • Flatterland: Like Flatland, Only More So By Ian Stewart. amazon
  • The Annotated Flatland: A Romance of Many Dimensions By Ian Stewart. @ amazon

You can also read Flatland here: FLATLAND: A Romance of Many Dimensions

There's also a Chinese translation: 神奇的二维国 (Flatland)


Linux, Audio Problem, pulseaudio

in Linux, if audio doesn't work, you can try

pulseaudio -k # kill it

then wait few seconds for it to die. You can check by

pgrep -l pulseaudio

then, start pulseaudio again.

pulseaudio --start # start it again

To start the sound level control panel, do:

setsid pavucontrol # start sound level control panel

now, if your desktop dock volume shows gray, you might need to restart it.

# restart xfce dock
pkill xfce4-panel
setsid xfce4-panel

The Linux audio problem is caused by the kernel having problem with several popular Logitech webcam. In my case, its Logitech HD Webcam C310 amazon

In your syslog, tail -f /var/log/syslog, you get flooded by this message:

kernel: [ 1438.563209] 3:3:4: cannot set freq 48000 to ep 0x86
kernel: [ 1438.563976] 3:3:4: cannot set freq 48000 to ep 0x86
kernel: [ 1438.565348] 3:3:4: cannot set freq 48000 to ep 0x86

The solution is just to unplug that webcam.

You can see bug report here. https://bugzilla.kernel.org/show_bug.cgi?id=44281


Philosophy, Extreme Utilitarianism on the Dead

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


just got a idea. We need to create a society, where dead is regarded irrelevant, period.

no eulogies, no hating or admiring of the dead (such as Hitler, Lincon, past heroes, kings, great artists, anything)

the gist of the theory is some aspect of extreme utilitarianism.

i got this inspiration now because someone's twitting about people hating some dead guy, as taught in school. e.g. you spit on some bastard's grave, who have done your country wrong. And such act, and the emotion associated with it, is a waste of time.

so far, without further research/thinking, i think that MOST of acts, behaviors, emotions, in relation to the dead, is a futile, useless, one. It is somewhat similar to admiring God.

also, i guess the above might probably be already covered, ⁖ as a idea by some philosophy or movement in some region or history…

What's HTTP Etag?

Perm URL with updates: http://xahlee.info/js/http_etag.html

Here a quote from Wikipedia HTTP ETag:

An ETag or entity tag, is part of HTTP, the protocol for the World Wide Web. It is one of several mechanisms that HTTP provides for web cache validation, and which allows a client to make conditional requests. This allows caches to be more efficient, and saves bandwidth, as a web server does not need to send a full response if the content has not changed.

An ETag is an opaque identifier assigned by a web server to a specific version of a resource found at a URL.

The use of ETags in the HTTP header is optional. The method by which ETags are generated has never been specified at any time in the HTTP specification.

here's a sample HTTP header:

◆HEAD http://xahlee.info/

200 OK
Connection: close
Date: Thu, 27 Jun 2013 04:34:23 GMT
Accept-Ranges: bytes
ETag: "d0dc0093-2393-4dfed7ff74f80"
Server: Apache
Content-Length: 9107
Content-Type: text/html; charset=utf-8
Last-Modified: Mon, 24 Jun 2013 21:57:34 GMT
Client-Date: Thu, 27 Jun 2013 04:34:23 GMT
Client-Response-Num: 1
X-Pad: avoid browser bug

here's another example, querying Google.

◆ HEAD http://google.com/

200 OK
Cache-Control: private, max-age=0
Connection: close
Date: Thu, 27 Jun 2013 04:27:23 GMT
Server: gws
Content-Type: text/html; charset=ISO-8859-1
Expires: -1
Client-Date: Thu, 27 Jun 2013 04:27:23 GMT
Client-Response-Num: 1
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
Set-Cookie: PREF=ID=9dc114ba5ab05743:FF=0:TM=1372307243:LM=1372307243:S=3t1GefOPQpI5FjdG; expires=Sat, 27-Jun-2015 04:27:23 GMT; path=/; domain=.google.com
Set-Cookie: NID=67=esaPZnzLc7uJW1MKobIJoRbtq_1ESpvwkaGEGJppG7hRti4B39-wpxmAA-rWpju2ajhmSNEncos17GKSMpiX_mGtbWPAqh9FBi0-8eEkKjnEtGTKo8PAKUQO9prWCQHB; expires=Fri, 27-Dec-2013 04:27:23 GMT; path=/; domain=.google.com; HttpOnly
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block

encryption: What's Perfect Forward Secrecy?

Perm URL with updates: http://xahlee.info/comp/perfect_forward_secrecy.html

due to the Edward Snowden and NSA fiasco of recent, there's something called Perfect forward secrecy going around.

here's what it means. When you are using Public Key Cryptography (PKC), such as HTTPS protocol, you have public key and private key. For example, when you buy something on Amazon, its public key is in your browser, and its server has its private key.

The point here is that, once the secret key is lost, all is lost. If NSA have saved all your encrypted traffic for years, they may one day ask/get Amazon's secret key, and your life's history is a open book.

Now, PKC with Perfect Forward Secrecy (PFS) doesn't have this problem. Here's a excerpt from Wikipedia:

In an authenticated key-agreement protocol that uses public key cryptography, perfect forward secrecy (or PFS) is the property that ensures that a session key derived from a set of long-term public and private keys will not be compromised if one of the (long-term) private keys is compromised in the future.

… For PFS to exist, the key used to protect transmission of data must not be used to derive any additional keys, ….

however, looks like nobody is using PFS (not any of the banks, etc), except Google in Gmail and perhaps a few others. See these two nice article:

  • Perfect Forward Secrecy can block the NSA from secure web pages, but no one uses it By Michael Horowitz. @ blogs.computerworld.com…
  • The price to pay for perfect-forward secrecy By Nikos Mavrogiannopoulos. @ nmav.gnutls.org…

Note, encryption is extremely complicated business. The above is a very simplified explanation.

For a basic intro, see: Intro to Public-key Cryptography for Sys Admin; What's HTTPS, SSH, SSL, TLS, AES, SHA-1, MD5, ….


Python: Compute Exact Fractions

# -*- coding: utf-8 -*-

import fractions

print( fractions.Fraction(5,100)) # 1/20
print( fractions.Fraction(4,100)) # 1/25
print( fractions.Fraction(3,100)) # 3/100
print( fractions.Fraction(2,100)) # 1/50

Note that Mathematica had this feature, transparently, since 1990.

In Mathematica, any exact number are computed exactly. Number without a decimal dot are exact.


Silly Unicode Name Change: CENTER → CENTRE

Silly Unicode Name Change: CENTER → CENTRE

Unicode: Dingbats, Cultural Symbols (updated)

in Unicode, the name of the character is changed from OPEN CENTER ASTERISK to OPEN CENTRE ASTERISK. What's the technical reason they make such a silly change? Poltical reason?


Emacs Projects Proposal: Language Aware Modes for Emacs Lisp, HTML5, CSS

remember, am proposing several emacs projects.

the HTML5 mode, and emacs lisp mode, and CSS mode, are going to be semantic unit based editor. That is, any keystroke you type, work on the semantic unit of the language. So, it is IMPOSSIBLE to create invalid syntax when you use the mode.

also, a new idea is that it'll completely eliminate any form of manual formatting. You NEVER need to press Tab ↹ or Space or Return ↩ for the sake of aligning your code to make it pretty. NEVER. Instead, you press a button, then the current code block is automatically formatted, in a standard convention or in a preference you set up. Another button format the entire buffer, etc.

another “new” idea, is that these modes's coloring are “mostly” keyword based. That means, if it's colored in a particular way, you know for sure it's a particular type or word of the language. If it is not colored, you know for sure it's not a core language keyword, or that you had a typo. In other words, the coloring are tied to semantics of the core language, not in other aspect of “helping you code”. This feature is already done in HTML, CSS, emacs lisp, modes, but need to polish details (such as possibly not coloring inside comment or string).

There will be complete support for keyword or form completion. So, working in a lang, any form or structure of the language are inserted automatically as you type or call a command. I aim for a complete system, and aim to not rely on yasnippet mode or auto-complete-mode.

Your help is appreciated. Please support here: http://pledgie.com/campaigns/19973. Vote for the one you want the most. But, if i get funding, it's likely i'll have at least 3 of the projects done reasonably well.

My video presentation isn't well done, as i'm not skilled and well prepared in making video presentation. I hope you support it, and tell it to friends.

My yearly income from 2005 to now is about 2 thousand dollars per year. And, this year, my brother stopped supporting me, so am in a emergency situation for survival. Need to come up with $1500 per month, and job hunting hasn't been smooth. (i sold my car 2 years ago, dried my 401k savings 2 years ago, i live on a $3 food per day, and i haven't seen a doctor for a decade. I'm about as good as the homeless on the street.)


Functional Programing: the Jargon “Lambda”

these days, with functional programing getting popular, and lots lots new languages, the lambda name is falling out of fashion, and i think that's a good thing.

for example, in JavaScript, its functions are lambdas (⁖ function xyz {…}), but no JavaScript literature calls it lambda. 〔☛ Functional Programing in JavaScript〕 Same situation in Ruby. Younger generation using these languages, never thought about lambda, yet they benefit from what these so-called “anonymous” function provides. The name lambda actually harms understanding.

in Mathematica, the lambda is called Pure Function, but is written simply as Function[…]. (it's called Pure Function to differentiate from functions defined using pattern matching) Mathematica has been that way since version 1 in 1988.

the most important thing about lambda, isn't any advanced use, such as “closure”, or things one hear from the Haskell world. It's simply that the function is a expression, namely it returns a value that represents the function. (and therefore, it can be assigned to a var, or passed as a parameter to other function, or returned as a value from a function) (here, in lisp world it's sometimes known as “Function as First Class Citizens”. (again, a term that harms education and progress and propagation of functional languages))

United Kingdom slang: “bird” for “chick”

In United Kingdom, they call a girl “bird”, analogous to the US slang “chick”.

it's wrong to call a girl “bird”, because, “bird” is descendant of dinosaur. Dinosaur are not cuddly creatures.


Internet Explorer Anime Girl

Internet Explorer anime girl
Internet Explorer anime girl

emacs key poll, C-c and C-x

list 10 commands in #emacs you use the most.

  • 5 that start with C-c key. (any mode)
  • 5 that starts with C-x key.

(or more than 5 if you want. You can just write down the key, but with the mode's name.)


Declaring Character Set in CSS File @charset

by default, CSS file is assumed to be UTF-8 encoded, unless the server or other mechanism says otherwise.

however, you can declare it in your CSS file, in first line, like this:

@charset "UTF-8";

reference. 〔Declaring character encodings in CSS By W3C. @ www.w3.org…


unix man page getting obsolete?

these days, man page is getting the slack. Instead, the embedded inline doc --help option is emphasized. Often, the info from --help is more complete than man page. Many programs don't even bother to write a man page, but the linux distributor such as Debian, writes one for them, pro forma.

For example, i wanted to know what's the --minimal option do in xfce4-display-settings. So, i man xfce4-display-settings. The output doesn't mention it.

XFCE4-DISPLAY-SETTINGS(1)                 User Commands                 XFCE4-DISPLAY-SETTINGS(1)

       xfce4-display-settings - Display settings for Xfce

              xfce4-display-settings [OPTION...]

   Help Options:
       -?, --help
              Show help options

              Show all help options

              Show GTK+ Options

   Application Options:
       -v, --version
              Version information

              X display to use

       Copyright © 2004-2008
               The Xfce development team. All rights reserved.

       Please report bugs to <http://bugzilla.xfce.org/>.

xfce4-display-settings 4.6.0 (Xfce 4.6.0)   March 2009                  XFCE4-DISPLAY-SETTINGS(1)

but if i do --help, there it is:

◆ xfce4-display-settings --help
  xfce4-display-settings [OPTION...]

Help Options:
  -h, --help                    Show help options
  --help-all                    Show all help options
  --help-gtk                    Show GTK+ Options

Application Options:
  -s, --socket-id=SOCKET ID     Settings manager socket
  -v, --version                 Version information
  -m, --minimal                 Minimal interface to set up an external output
  --display=DISPLAY             X display to use

Lots other programs are like that, especially newer ones, and in particular those scripts from Ruby community written in Ruby.

this is in fact a good thing, because it lets doc in sync with the software. With man page, it's a separate program, and it's prone to be version discrepancy.

What About GNU info doc?

note that, Richard Stallman's GNU project, wanted us all to use his info doc format instead.

the info doc format is truly superior to man. Info is essentially a text-based hyperlink system, hyperlink as in today's HTML, yet it precedes HTML by a decade. The info doc supports chapters, navigation, cross-reference, search, and is easy to use.

however, there's a major problem: the verbosity of the content. Due to the writing style, info doc, like emacs's manual, are extremely verbose. For example, in the GNU Emacs Manual, it has several chapters telling user what copy paste means, what text editor means, what text selection means.

also, info is full of FSF propaganda.

info doc, like GNU's double-dash syntax diff --brief, are never embraced by unix users. And today, with incredible growth of open source software, by Google, by git, ruby, …, GNU and Info is falling into obsecurity.

Perm URL with updates: http://xahlee.info/linux/linux_manpage_getting_obsolete.html

Unix Shell Syntax, 2000 〜 2013

as of 2013, the unix shell tool syntax have gone thru more evolution.

note, in 1990s, the GNU introduced the double-dash syntax. ⁖ diff --brief, in hope to make it readable. Unfortunately, it didn't really catch on. Most commands today do offer the double-dash variant, but only for some options. The double-dash option does not necessarily mean there's a corresponding single-dash one, and vice versa. What happened instead is just a new syntax variation.

during 2000s, a new syntax form became popular, one that has a “action” keyword immediately following the command name. Here are some prominent examples:

  • apt-get install --simulate -y ‹name›
  • git add -m"…" ‹fpath›
  • iptables --table filter --append INPUT --jump DROP

One good example of the confuse ball in one command can be seen in Linux's “ps” command. See man ps.

read more at: Unix Pipe as Functional Language


the effect of keyboard hardware on your keyboarding habit

Here's a example. From 2005 to 2008, i was using the classic Microsoft Natural Keyboard. In about 2009, i switched to the new model Microsoft Natural 4000. The new keyboard is great, and i think it's a improvement, however, ON THAT KEYBOARD i developed a habit to press the {1, 2} keys by twisting my wrist to the left and press it with my middle finger (instead of using pinky and not turning wrist. (because, somehow on this new model, it's harder to press the 1 with pinky)). Then, i developed RSI symptoms. RSI cause is very difficult to track down, but eventually, after panicking for weeks, i eventually tracked it down to this wrist movement. For the full story, see: Programer Hand Health: vi Esc Key Syndrome.

Here's another personal example: Keyboarding: Effect of Mechanical Key Switches on You.

see also Bad Advices from Programers about Typing & Keyboard (RSI)

JavaScript Book by David Flanagan, and the Man-made Complexity in Computer Language

Perm URL with updates: http://xahlee.info/comp/js_book_man_made_complexity.html

Am very impressed with this book. VERY.

JavaScript Definitive Guide by David Flanagan
JavaScript Definitive Guide (6th ed.) By David Flanagan. @ amazon

Normally, if you've been programing for a few years, you can quickly start to program in a new lang. You just learn the basics, types, loops, list/array, function/objects, module, then you can practically code anything you want, albeit in a non-optimal way. But, you'll have a lot questions, especially with complex languages. Questions like scope, evaluation model, and the language's overall “model”. What happens if you do xyz. Understanding these makes you a true expert in that lang. To understand a lang well, is to be able to have a sense of a mathematical model of the language.

(and almost all modern langs are quite complex, including Java, Python, Ruby. Now, JavaScript is easy to use, but it turns out it's quite complex too actually, the hairy details of its prototype inheritance. Very few languages have simple models (Mathematica, Lisp, do)) (a language with a simple model, would be one that its syntax and semantics can be specified in just a handful of rules. (see: Formal language.) 〔☛ Math Notations, Computer Languages, and the “Form” in Formalism〕)

David Flanagan drills down on the real tech detail of JavaScript language.

I've only read parts of the chapters on JavaScript Objects, and the book is really good.

I noticed that he also wrote one on Ruby: 〔The Ruby Programming Language By David Flanagan. @ www.amazon.com…〕. Am looking forward to read this.

Actually, he wrote several others, on Java, on X11, since at least 1996.

The Cost of Complex Language

Most popular languages are exceedingly complex. The problem is that, you spend years to master them, but, new language comes out and replaces it, and the time you spend learning that language doesn't contribute your understanding to computer science or math in any way. What you learned is sometimes called “artificial complexity”, “man-made complexity”, unlike certain complexity in math or comp sci, that are inherent, unavoidable. Perl, C, C++, and unix tech (Shell, Apache) are good examples of man-made complexity. Lisp, in general, are the polar opposite.


Interface Design: How JavaScript Breaks UI, and the Evolution of User Interface

so many “modern” pure JavaScript based websites f�cks up the page so that basic universal browser operations broke. For example:

• Control+click or middle click on a link to open in new tab, or 【Ctrl+n】 to open new page, will not always work.

Perpetrator include Google's Google Plus, Twitter.

When a key that works only sometimes, it's annoying, but also dangerous, because after a few times of non-working, you stop using that key. Instead, user goes for the sure way of using the more cumbersome mouse.

• When a page contains Video (Flash) such as YouTube, almost always your keys such as ⇟ Page ▽, don't work anymore, because the “focus” is on Flash or some particular JavaScript scripted element, so key input got stolen. You need to click somewhere outside the video first.

From user's perspective, it's plainly annoying. However, the thing is, these fancy sites don't care, for good reasons, because, vast majority of people, probably 90%, don't even know about basic keys. Control+Click would be considered advanced.

so, how do we take this? should this be considered the inevitable progress of UI, or is it simply crassness of the corporations?

dollar sign in JavaScript

lots JavaScript libs use dollar sign “$” as the name of their primary function.

It seems, it started with the prototype lib, then others picked it up, in particular jQuery.

here's a quote from stackoverflow

As far as I can see, it's not recommended to use because the ECMAScript specification states that:

The dollar sign ($) and the underscore (_) are permitted anywhere in an identifier. The dollar sign is intended for use only in mechanically generated code.

Update: The above refers to ECMA-262 3.0. However, this is no longer the latest edition. Currently, 5.1 is the latest edition. In ECMA-262 5.1 the above text is changed to:

The dollar sign ($) and the underscore (_) are permitted anywhere in an IdentifierName.

That is, it seems that they dropped the "restriction" or whatever you want to call it.

So, is this the case where practice forced a chance in spec?

javascript books

JavaScript Books

  • 〈JavaScript Definitive Guide〉 amazon
  • 〈Professional JavaScript for Web Developers〉 amazon
  • 〈JavaScript: The Good Parts〉 amazon
  • 〈JavaScript Web Applications〉 amazon

git tip: fast way to revert to last commit

when you just pulled from remote, and realized it didn't work, you can quickly revert.

# revert before last commit
git checkout HEAD@{1}

Linux: How to Upgrade Xfce

to find your current version, type xfce4-about --version

to upgrade:

# upgrade xfce
sudo add-apt-repository ppa:xubuntu-dev/xfce-4.10
sudo apt-get update
sudo apt-get dist-upgrade
# delete cache
rm -rf ~/.cache/ ~/.compiz

# restart
sudo shutdown -r 0