FBI can put GPS in your car sans warrant

Student Who Found GPS Device On His Car Due To Reddit Comment Sues The FBI (2011-03-04) By Mike Masnick. @ Source www.techdirt.com

Here's a comment by the well know computer security expert Bruce Schneier.

The FBI is Tracking Whom? (2010-10-13) By Bruce Schneier @ Source www.schneier.com

Time mag has a article about a related issue:

The Government Can Use GPS to Track Your Moves (2010-08-25) By Adam Cohen. @ Source www.time.com

Google shutting down your account

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

What Happens If Google Shut Down Your Account?

Xah Lee, 2011-03-05

Yesterday, Google shut down my account for suspecting “unusual activity” for about 4 hours. On 2011-03-03 from ~4 pm to ~8 pm.

I have no idea why. I went to bed at 3pm to take a few hours sleep. I woke around 8pm. When i went to my gmail tab, it requires me to login. (usually i don't have to, because i didn't logout.) After i type my gmail and password, then it says my account has been suspended for “unusual activity”. It provides me a option to type my phone number, so google will send me a message and i can verify that. I was reluctant in giving my phone number. After about 10 min reading about Google help, i did, and things went normal again.

I am quite unhappy about this. When i checked my Google blogger stats, i realized that Google had shut down my blogger as well, because the stat were flat in the duration. And, i think this also means that Google had shut down all Google services that are associated with my account. e.g. AdSense, Analytics, ... etc. I couldn't verify this in Analytics because i'm not sure there's a way to show stat by hours.

If i wasn't able to resolve this shut down problem, it's gonna be a huge headache. If my Google account were gone, that means i have to change my email address from some 10 other services (e.g. banks, paypal, etc.) that i have to spend hours to figure out. I have to notify friends or any business associates about email change. This also means, during the time when my account is shut, my AdSense is dead, Google Analytics is dead. I don't know if during the time email send to my gmail account (xahlee @ gmail.com) were bounced.

Most importantly, but luckily, i have a backup copy of my emails on my PC, because i've set up IMAP so i get a copy of my emails on my PC. (if you haven't done so, you should. Go to your account preferences, set up POP3 or IMAP to download your emails. If you don't have a email app, download the free Mozilla Thunderbird. I use that.)

This is really not cool. Also, Google now knows my mobile phone too. There doesn't seem any option other than entering your phone number. I usually don't even have a phone number. My mobile phone happened to working. (I don't use phone much. It's pay-as-you-go phone. It expires in about 2 days.)

Here's one of the Google's help page about locked account i found now: Source mail.google.com. (i don't think it's the same page i saw linked from the from the Account Disabled notification page.) Here's a quote:

Unusual account activity includes, but is not limited to:

  • 1. Receiving, deleting, or downloading large amounts of mail via POP or IMAP in a short period of time. If you're getting the error message, 'Lockdown in Sector 4,' you should be able to access Gmail again after waiting 24 hours.
  • 2. Sending a large number of undeliverable messages (messages that bounce back).
  • 3. Using file-sharing or file-storage software, browser extensions, or third party software that automatically logs in to your account.
  • 4. Leaving multiple instances of Gmail open.
  • 5. Browser-related issues. Please note that if you find your browser continually reloading while attempting to access your Inbox, it's probably a browser issue, and it may be necessary to clear your browser's cache and cookies.

If you go to http://mail.google.com/support/ and search for “account disabled” or “account locked”, you get many results. Apparently, many people have experienced this. (it shoud be noted that some of them could be actually from spammers).

I don't know what might be the “unusual activity” that Google detected. Possibly someone else broke my account and did bad things. Though i don't have reason to think that was true. The only thing i can think of, is that yesterday i posted a message to comp.lang.python, which contained 5 links to my website xahlee.org about keyboard and unicode issues. I suspect perhaps more than 1 person may have flagged my post as spam. The post is here: Source groups.google.com. Though, my post isn't flame or in bad netiquette, so i'm not sure it's the cause.

Gmail has a feature that lets you view the IP address and location of your past access. It's at the bottom, that says “Last account activity: 0 minutes ago at this IP ( Details”. Click on the “Details”. Though, it seems only to track 4 hours back (or just last 10 access). By now, it's about 8 hours from the time my account is re-opened, so it's too late to use it to check if anyone is accessing my account from another IP address. I wished i've done this earlier.

Here's a post from Google on this: Why is Google asking for my phone number? (2010-10-17) By Mike CH. @ Source www.google.com. Some quote:

Why does Google ask for this?

It is an anti-spam system. Here's how it works.

Each phone number can be used to re-activate accounts a small number of times before it won't be accepted anymore, and each Gmail account can send to a limited number of recipients every day.

Because most people don't buy things from spammers, they need to work with lots of accounts in order to send enough email to make money. If we think an account might be being used by a spammer, we lock it until the owner provides a phone number. So, spammers need to have access to a large quantity of phone numbers to unlock all their accounts. This is very expensive for them but pretty easy for most regular people. In most cases it is expensive enough for the spammer that it becomes unprofitable for them to spam, so they give up.

I don't want to provide my phone number, that's personal.

You can provide any phone number that has not been "used up". It does not have to be your own. Even payphones can work.

I don't want to provide any phone number at all.

You can follow the instructions on the verification page to contact support. However it may take us some time to get to your ticket, as these cases are lower priority than people who have been genuinely locked out without any way back in. We strongly encourage you to go through the phone verification process - many people have already done it, and we keep the numbers used private.

(Note: If you got a EMAIL telling you your account is GOING TO BE locked and asking you for password, that is SCAM, not from Google.)

I just changed my password. I hope this doesn't happen again.


How to Create a APL or Math Symbols Keyboard Layout

Perm url with updates: http://xahlee.org/kbd/creating_apl_keyboard_layout.html

How to Create a APL or Math Symbols Keyboard Layout

Xah Lee, 2011-03-04

This page shows you how to create a APL (programming language) keyboard layout, on Windows or Mac OS X. Or, creating a math symbols layout for computer languages such as Fortress, Scheme Lisp, Haskell. (See also: Unicode Support in Ruby, Perl, Python, javascript, Java, Emacs Lisp, Mathematica.)

APL Symbols in Unicode

APL keyboard layout

APL keyboard layout. Source en.wikipedia.org

Unicode has the complete set of APL chars.

' ( ) + , - . / : ; < = > ? [ ]
\ _ ¨ ¯ × ÷ ← ↑ → ↓ ∆ ∇ ∘ ∣ ∧ ∨
∩ ∪ ∼ ≠ ≤ ≥ ≬ ⊂ ⊃ ⌈ ⌊ ⊤ ⊥ ⋆ ⌶ ⌷
⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇
⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗
⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧
⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷
⍸ ⍹ ⍺ ⎕ ○

APL2 keyboard layout

APL2 keyboard layout. Source en.wikipedia.org

For other chars, such as λ ∑ ⊕ ƒ ⇒ ↦ used by APL derivatives, or Fortress, or other languages, see: Math Symbols in UnicodeArrows in UnicodeComputing Symbols in Unicode.

Unicode Font

First you need to have unicode fonts. See: Best Fonts for Unicode.


if you are a emacs user, you might use Math Symbols Input Mode (xmsi-mode).

Or, you can create your own rather easily. There are few ways depending on how you want the input to work.

You can insert unicode by abbrev, such as typing “alpha” auto expands to “α” or “rarrow” auto becomes “→”. Sample code at: Using Emacs's Abbrev Mode for Abbreviation. (one flaw with this solution is that emacs abbrev only allow sequence of english letters to be used as input. So, you cannot create “->” as abbrev for “→”.)

Or, you can setup systematic keys in emacs. e.g. hold down Win key and any letter becomes the ones in APL keyboard. See: Emacs: Remapping Keys Using key-translation-map and Emacs Custom Keybinding to Enhance Productivity.

Mac OS X

If you are on OS X, you can also setup system-wide config to enter complete custom designed unicode layout. Super easy too (though there are a few problem with certain key combo, because they are low level that Apple don't want changed). See: Creating Keyboard Layout in Mac OS X and Technical Note TN2056: Installable Keyboard Layouts @ Source developer.apple.com.

Other Solutions for Windows, Mac, Linux


Here are some linux solutions for APL language. I haven't tried them.

Windows & Mac

Here's a project that has the APL layout made for Mac and Windows, i haven't tried it: http://code.google.com/p/apl-keyboard-layouts/.

On Windows, you might use The Microsoft Keyboard Layout Creator. See: Keyboard Layout & Key Macro tools for Windows. However, i never tried it.

emacs artist-mode

Discovered “artist-mode”. It's a mode that let you draw ascii pictures with the mouse.

See: http://xahlee.org/emacs/emacs_string-rectangle_ascii-art.html

周杰倫 — 夜的第七章 (Jay Chou — Twilight's Chapter 7)

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

周杰倫 — 夜的第七章 (Jay Chou — Twilight's Chapter 7)

Xah Lee, 2011-03-03

Fantastic song. Jay Chou's Twilight's Chapter 7 (周杰倫 — 夜的第七章) (Jay Chou).

Title: 夜的第七章 (Twilight's Chapter 7)
Date: 2006
Album: Still Fantasy
Singer: 周杰倫 (Jay Chou)
Lyrics: 黃俊郎
Music: 周杰倫 (Jay Chou)
Arrangement: 鍾興民/林邁可 (Michael Lin)
1983年小巷 12月晴朗
夜的第七章 打字機繼續推向
石楠煙斗的霧 飄向枯萎的樹

貝克街旁的圓形廣場 盔甲騎士臂上
鳶尾花的徵章 微亮
無人馬車聲響 深夜的拜訪
邪惡在維多利亞的月光下 血色的開場

消失的手槍 焦黑的手仗
融化的蠟像 誰不在場
珠寶箱上 符號的假象
矛盾通往 他堆砌的死巷

 如果邪惡 是華麗殘酷的樂章
 (那麼正義 是深沉無奈的惆悵)
 它的終場 我會 親手寫上
 (那我就點亮 在灰燼中的微光)
 晨曦的光 風乾最後一行憂傷
 (那麼雨滴 會洗淨黑暗的高牆)
 黑色的墨 染上安詳
 (散場燈關上 紅色的布幕下降)

事實只能穿向 沒有腳印的土壤
突兀的細微花香 刻意顯眼的服裝
每個人為不同的理由 戴著面具說謊


越過人性的沼澤 誰真的可以不被弄髒
我們可以 遺忘 原諒
但必須知道真相 被移動過的鐵床

我聽見腳步聲 預料的軟皮鞋跟
他推開門晚風晃了煤油燈 一陣
西敏寺的夜空 開始沸騰

在胸口綻放 豔麗的死亡

如果邪惡 是華麗殘酷的樂章
他推開門晚風晃了煤油燈 一陣)
它的終場 我會 親手寫上
西敏寺的夜空 開始沸騰)

黑色的墨 染上安詳
如果邪惡 是華麗殘酷的樂章
它的終場 我會 親手寫上
晨曦的光 風乾最後一行憂傷
黑色的墨 染上安詳

Here's a quick lousy translation

In a alley, December morning, 1983
twilight's chapter 7, the typewriter pushes forward
near the truth in the next line
the pipe smoke wisps over that shriveled tree
tells me in tears

Baker Street Portman Square, armored knights
Irise on badges, shines
noises of empty carriage, moves at night
darkness lurks under the moonlit Victoria, redness sets in

the gun that's gone, the black cane
the melted wax model, the empty witness
the jewelry box, the fake symbolism
the paradoxical passage, the constructed deadend
evidence buried in perfection
the smug at Scotland officer

 if evil, is the grandeur of cruelty
 (then justice, is the helpless melancholy)
 i would personally write its finale
 (then let me kindle, the dying light)
 morning light, dried the last line of anguish
 (then raindrops, would wash the wall of darkness)
 black ink dyes tranquility
 (lights out at the end, red curtain drops)

facts passed that soil without a trace
the sudden faint fragrance, that eye-catching costume
everyone lies, for different reasons
the motives are all the same, called desire


who can keep clean, when passing the human mire
we can, forget, forgive
but must know the truth; that iron bed has been moved
that last piece finally came

i heard footsteps, from that leather shoe i expected
he pushed open the the door, breeze disturbed the kerosene lamp
typewriter stopped at the murderer's name, i turn around
the night of Westminster, begin to seeth

blooming on my chest, the sublime death
i savor the last taste of sweet truth
with a smile, i recall that justice is the extension of quietness
violin at Thames

[repeat refrain]

“Jay Chou — Twilight's Chapter 7”

Note, “Twilight's Chapter 7” isn't a movie. It's just the music video.

The female voice is from Penny (潘儿), of music group Room19.

This song is themed on Sherlock Holmes's detective story. Note that Sherlock is a fictionl character created by the author Arthur Conan Doyle (1859‒1930). (for some reason, i always hated the name Sherlock Holmes, and never find any attraction towards detective stories. I find the whole thing repulsive. I detest the icon of a detective with a magnifying glass. Can't really explain why.) Sherlock lives in a specific fictional address at a real place Baker Street. Also interesting to note is Blue rose. There's no natural blue colored rose, but people dye it blue, and recently some genetic engineering have been tried. The song also seems to hint on Jack the Ripper, which is a name given to multiple murder cases. The murderer seems to like to cut his victum's chest open.

The 貝克街旁的圓形廣場 might be Trafalgar Square not Portman Square.

I like this song, for its music, and the dark theme. In particular, this refrain sung by the female:

if evil, is the grandeur of cruelty
i would personally write its finale
morning light, dried the last line of anguish
black ink dyes tranquility

Some source: Source baike.baidu.com

“Jay Chou — Twilight's Chapter 7” amazon

FSF Declaration on Facebook

FSF made a declaration on Facebook. See: Mark Zuckerberg is TIME Magazine's Person of the Year? Where's the “dislike” button? (2011-02-03) by Matt Lee et al. @ fsf.org.

FSF say no to facebook Zuckerberg

See also: Facebook's Ethics.

Notes on Masturbation, Heartbeat, Midlife Crisis

this page's content is removed due to possible incompatibilities with Google's AdSense. For the content, goto http://xahlee.org/sex/masturbation.html


elisp: new version of get-selection-or-unit

Much improved my code for “get-selection-or-unit”. Also, a “unit-at-cursor” function is created. This is separated out because sometimes you want to get the thing at point, without caring whether there's a text selection. For the code, see: Emacs Lisp: Using thing-at-point.

another ergonomic layout: bvofrak!

Discovered a new ergonomic layout, for French, called bvofrak. See: Dvorak, Maltron, Colemak, NEO, Bépo, Turkish-F, Keyboard Layouts Fight!. (thanks to Hugues Dumez.)

It's interesting that on their site bvofrak.blogspot.com they mentioned this (translated by Google):

  • The jedi have force. You, you have resistance to change!
  • The following jedi force. You, you depend on the trail!
  • The Jedi can read minds. You, you have muscle memory!
  • The Jedi have a long life to learn. Not you!

xah's log: refactoring my .emacs

Spent the past 5 hours refactoring elisp code in my .emacs. Not exactly thrilled. it's the kinda work that has no immediate benefit, but potentially disruptive. The software proverb goes: “if it ain't broken, don't fix it.”.

I'd say it's only half complete. But am tired of it at this (point). Actually, about every 4 months in past 4 years i spend several hours refactoring stuff there. (not counting the time adding stuff there) As the functions pile up, more time went into it. As my elisp kungfu increases, more is there to be refactored.

well, today, most work done is to replace “thing-at-point” by get-selection-or-unit. But alone the way, saw old code, and can't help to clean it.

Though, my strategy towards “.emacs” is still basically “don't bother unless you absolutely have to”. Organize Your “dot emacs” Init File in 5 Minutes.

second life in real life

“2009 ABC Television Interview with Paisley Beebe in Real Life”

In case you don't know, Paisley BeeBe (sl name) runs a TV show in sl. Usually interviewing people. I've attended a couple. First in around 2008.

html5 demo for developers

Very cool html5 demo for web developers: http://slides.html5rocks.com/. (advanced. Best viewed with Google Chrome)


SGI Logo & Visual Illusion

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

SGI Logo & Visual Illusion

Xah Lee, 2011-03-01

sgi logo flat sgi logo sgi logo old

Silicon Graphics's logo.

This logo is designed by Scott Kim. Scott Kim website.

Silicon Graphics's famous logo is a corner perspective of a tubed cube. The key behind this successful logo lies in the illusion it imparts. A cube appears hexagon when viewed from a corner.

sgi logo on chip

sgi logo etched microscopically on cpu.

sgi logo rendered

Computer rendered sgi logos, by Paul Bourke.

SGI logo spinning A spinning sgi cube. The SGI cube is sgi's hallmark and trademark. Its perspective illusion and rendering symbolizes the company's craft. In early 1990s, SGI is regarded as the king of computer graphics.

sgil new logo

Idiotic sgi new logo.

Around 1998 SGI is bleeding to death, with graphic CAD systems happily running on cheaper but not slower Windows/Intel and Mac's PowerPC chips. They changed their logo to a stylized SGI and dropped the iconic cube. Later years, due to complaints, they re-adopted the old cube logo.

SGI logo sculpture SGI logo sculpture

Real sculpture of the SGI logo, at its headquarter in Mountain View, California, USA. The plate at the bottom (not shown) reads: “In Celebration of 20 Years of innovation. Dedicated by Dr. James Clark Founder, Silicon Graphics, Inc. on August 12, 2002. Sculpture previously installed at SG Manufacturing S.A., Switzerland”.

sgi logo
sgi logo

Google Chrome & Browser War II

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

Google Chrome & Browser War II

Xah Lee, 2010-12, 2011-03-01

holy cow! Google Chrome is really changing the landscape of what web browser is.

In Google Chrome, If you click on a mailto link (e.g. mailto:xah@xahlee.org), it'll popup a window that looks just like a normal email app's compose mail window. The mailto uri scheme has pretty much been dead since mid 2000s, but with this Chrome feature, it might revive.

SPDY Protocol

Google is quite powerful today. Not only having own browser, OS (Google Chrome OS), mobile OS (Android), and gazillion web services, but invents its own protocols.

This is old news, but see SPDY. SPDY is a protocol intended to replace HTTP. The interesting part is that it's not just a proposed protocol, but actually used daily when you use Google Chrome to access Google's websites and services. What this means is that, probably sooner or later, others will adopt. Quote:

SPDY is a research project in TCP-based application-level protocol for transporting web content. It is proposed by Google as a replacement for HTTP.

The goal of SPDY is to reduce web page load time. This is achieved by prioritizing and multiplexing the transfer of several files so that only one connection per client is required. All transmissions are SSL encrypted and gzip compressed by design (in contrast to HTTP, the headers are compressed too). Moreover, servers may hint or even push content instead of awaiting individual requests for each resource of a web page.

Google Chrome utilizes SPDY when communicating with Google services, such as Google Search, Gmail, Chrome sync and when serving Google's ads. Google acknowledges that the use of SPDY is enabled in the communication between Chrome and Google's SSL-enabled servers. SPDY sessions can be inspected in Chrome at the special URL 〔chrome://net-internals/#events&q=type:SPDY_SESSION%20is:active〕.

Check out that special url in Chrome.

It's not a wonder, that Google Chrome is faster in general. (among quite a few other reasons.)

Unicode Support

Been working with unicode a lot in the past 5 years. (For 30+ articles, see: Xah's Unicode Tutorial.)

Here's what i think of browser quality with respect to unicode support: From best to worst: Google Chrome and Opera. Then, Firefox, Safari, Internet Explorer 8. (All are current public versions of browsers on Windows, as of 2010-12.)

Note that unicode support in browsers have improved very much in the past 5 years.

Fractal Viewer

Google made a fractal application, based on Google Maps, at juliamap.googlelabs.com.

It's written using Javascript using Web Workers.

Though, am rather disappointed. When you zoom in just a few steps, the resolution does not automatically increase enough to get crispy edges.

Much better are some dedicated fractal apps. See: Great Fractal Software.

For a basic explanation of the mandelbrot set, see: Mandelbrot Set Explained (no complex number needed).

Web Apps, Chrome Web Store

Google recently launched Chrome Web Store, at: https://chrome.google.com/webstore.

The idea is similar to Apple's hugely successful iPhone iPad App Store. Apple's App Store more or less started a revolution in selling software.

Anyone can write a app and sell it there. This is a new channel for money making. A number of programers has become rich over-night, selling millions of copies of their apps. A lot programers have quit their day-jobs to dedicate their time to their own software. See for example:

One major problem Apple solved is software piracy, by a combination of hardware and centralized distribution channel. If you are a programer, unless you are a big company with lots money to invest in a distribution and encryption scheme, your software will be piraceted freely. (and even those from big corps are almost always in piracy networks)

Apple solved the piracy problem also psychologically. The iPhone and iPad you paid for. When you see some app you want, somehow you don't feel it's like traditional software and ask “where do i get a copy”? You simply just buy it right on your iPhone. See: Theodore Gray: Future of Text Book, iPad, Education.

Google WebGL Apps & Google Body

If you look at some of the apps, they are quite amazing. They use html5 tech. They usually just work in Chrome at the moment. Even though the tech is always open source, but other very competitive browsers Firefox, Opera, Safari, usually doesn't do it well yet.

For example, see this WebGL demo from Google. http://bodybrowser.googlelabs.com/body.html (use Chrome to view.)

Here's all the other WebGL apps: http://www.chromeexperiments.com/webgl.

Google HTML5 Demos

Here's site from Google demo html5 tech, for developers. HTML5 truely has lots nice features geared for web apps. http://slides.html5rocks.com/.

20thingsilearned.com. A fancily designed website, that is a kinda educational article for the general public that teaches them what is the web and web technologies, together with some opinions mixed in. A sorta propaganda, from Google. However, it demonstrates what html5 can do.

Which Browser Will Win Browser War II?

I think that Google Chrome will be the most popular browser before the end of 2012.

I use 5 browsers DAILY. I'll have to say, Google Chrome today is already the best, all things considered. (i rate Firefox second, Opera 3rd, Safari 4th, IE8 last. (all rating based on my experience on Windows versions))

IE9 Beta is making some noises recently. (to be released probably in a few months) But even if IE9 is fully out today, i think it still have at least a year dev time to catchup with other browsers.


Computer Language Design: String Syntax

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

Computer Language Design: String Syntax

Xah Lee, 2010-10-12, 2011-02-28, 2011-03-01

This article discuss string syntax in a computer language design.

Problem with Escapes

Typically, the syntax for string in a lang look like this:

mystr = "abc";

However, if your string contains double quote, then you need to escape them (usually with backslash), and this is ugly, hard to read, and inconvenient for programers. For example, suppose your code processes a lot html:

mystr = "<link rel=\"stylesheet\" type=\"text/css\" href=\"../xyz.css\">";

Here's a practical example from real emacs lisp code. The backslash gets annoying.

(while (search-forward "<div class=\"donate253586027\">If you enjoyed this site, please consider donating $3. Any amount is appreciated. <a href=\"http://xahlee.org/thanks.html\">Thanks!</a><form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"><div><input type=\"hidden\" name=\"cmd\" value=\"_s-xclick\"><input type=\"hidden\" name=\"hosted_button_id\" value=\"8127788\"><input type=\"image\" src=\"https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif\" name=\"submit\"><img alt=\"\" src=\"https://www.paypal.com/en_US/i/scr/pixel.gif\" width=\"1\" height=\"1\"></div></form></div>" nil t)

It's much worse with regex, especially emacs regex:

(while (search-forward-regexp
 "<a href=\"\\([^\"]+\\)\"><div class=\"img\"><img src=\"\\([^\"]+\\)\" alt=\"\\([^\"]+\\)\" width=\"\\([0-9]+\\)\" height=\"\\([0-9]+\\)\"></div></a>" nil t)
(replace-match "<div class=\"img\"><a href=\"\\1\"><img src=\"\\2\" alt=\"\\3\" width=\"\\4\" height=\"\\5\"></a></div>" t))

Other Forms of Escape: HTML Entities, Hex Code Literals

Another form of escape is html entities or hex code. For example, in html, the ampersand char can be written as &amp; or &#38; or &#x26;. The char “b” can be written as &#98; or &#x62.

Similarly, in Java and many other langs, hexidecimal code can be used. For example, “b” can be written as “\u0062”.

These are also considered as escapes here.

Variable Delimiters (Perl, PHP, Python)

One solution is to use different delimiters for the string. Perl, Python, take this approach.

For example, in perl, the following evaluates to the same string:


Basically, it allows several chars to be used for the string delimiter. This way, if your string contains ", you can switch to a different quoting delimiter, then you don't need to do the escapes, and your string is more readable. Here's how it looks, so much more clear:

mystr = q[<link rel="stylesheet" type="text/css" href="http://xahlee.org/xyz.css">];

Python is similar. e.g. the following lines all evaluate to the same string:



Another mechanism, used by Perl and PHP, is called “heredoc”. Basically, it uses a random string as delimiter, and anything in between is literal. Here's a example.

# perl
$mystr = <<'randomstringhere823497';
<link rel="stylesheet" type="text/css" href="http://xahlee.org/xyz.css">


Can Escape be Completely Avoided?

On 2010-09-26, Ron Garret wrote:

And just for good measure, some «European style quotes» and “balanced smart quotes” which I intend some day to try to convince people to start using to eliminate the scourge of backslash escapes. But that's a topic for another day.

On 2010-09-26, Spiros Bousbouras 〔spi...@gmail.com〕 wrote:

I don't see how they would help to eliminate backslash escapes. Let's imagine that strings were delimited by « and ». If you wanted a string which contained a » you would still need to escape it.

Using rich varieties of matching pair chars in unicode can greatly eliminate many escapes and improves code readability. (See: Matching Brackets in Unicode.)

Ultimately, escape can not be completely eliminated, doesn't matter how many variation of delimiters your language have (unless it's infinite, such as “heredoc”, or non-syntactic methods). This is because, if you lang is a general lang, inevitably it'll be used to parse its own source code. And there will be occasions when the text you want to parse is a complete enumeration of all possible string delimiters of your lang. (e.g. a tutorial of your language) So here, doesn't matter what delimitor you choose, it occures in the string you want to quote.

I think this problem can be mathematically modeled to be equivalent to the self-reference problem in symbolic logic, and is not a avoidable problem. (See: Russel's paradox)

“heredoc” is a ugly solution to this. Another possible solution is variable repeatition. e.g. consider any repetition of a matching pair delimiter is also a valid syntax:(((abc))), {{abc}}, 「「「「abc」」」」, etc, or any combination of repetition of variable delimiters, e.g. ([((【〈『‹abc›』〉】))]).

(Note: here, the desired property is the ability to quote a text without modifying the text in any way. So, this excludes adding any form of escapes, or inventive ways such as adding a Tab char in front of each line. Also, am thinking in the context of computer language syntax. This excludes semantic solutions by specifying how many chars/lines to read in and not using any delimiters. Thanks to reddit discussion @ Source www.reddit.com.)

Disadvantage of Variable Delimiters

The variable quoting chars also introduces some complexity. Namely, each delimiter symbol in your lang now has multiple meanings, context dependent, and or, you have multiple symbols for the same semantic. (See: Problems of Symbol Congestion in Computer Languages (ASCII Jam; Unicode; Fortress).)

For example, one language that does not have multiple string delimiters is emacs lisp (or lisps in general). In emacs lisp, a string is always delimited by the double straight quote ("). (single straight quote is not a string delimiter) Emacs lisp has the worst readability problems of Leaning toothpick syndrome, however, one advantage is that string syntax has a very simple logic. For example, you can ALWAYS locate ALL strings in the source code by searching for double straight quote char. In langs with variable quotes such as perl, this can no longer be true. You have to search several chars, and for each occurrence you have to judge based on adjacent chars.

Similarly, in Mathematica, paren is used for one single purpose only, always. It's delimiter for specifing evaluation order of expressions (e.g. (3+4)*2). The square bracket [] has one single purpose only. It's delimiter for function arguments e.g. f[x_]:= x + 1, f[3]. The curly brackets {} again has one single purpose only. It's delimiter for list. e.g. {1,2}. In traditional math notation and most comp langs, it's all context dependent soup.

Doesn't matter which is your philosophy in lang design with regards to quoting mechanism, unicode introduce many proper matching pairs that are helpful, and avoid multiple semantic meanings for a given char.

(this post is originally from online forum discussion at Source groups.google.com)

Diplomacy vs Propaganda (John H Brown)

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

Diplomacy vs Propaganda (John H Brown)

Xah Lee, 2011-02-28

My blog entry What is Al Jazeera? and What's Al Hurra?, is quoted by ex US diplomat John H. Brown at his blog at Source publicdiplomacypressandblogreview.blogspot.com.

Here's a quote from Wikipedia about John H Brown:

Brown, who received a Ph.D. in Russian History from Princeton University in 1977, was a member of the U.S. Foreign Service from 1981 until March 10, 2003 where he resigned over the war in Iraq;

Here's a video linked from his blog site, about the issue of diplomacy vs propaganda:

“John H. Brown FINDING OUR VOICES Bonus Feature”

In the video, he lists 4 things about propaganda:

  • ① Simplification of the issues.
  • ② Constant repetition of slogans that's often unconnected. (e.g. weapons of mass destruction, regime change)
  • ③ Demonization of the “other”. (e.g. the “evil”, the “other”)
  • ④ Stretching the truth, to unacceptable limits.

threat from Falung Gong?

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

Falun Gong Twitter Threat

Xah Lee, 2011-02-28

I made one tweet about Falung Gong yesterday, and today i got spamed by 7 consecutive tweets from the group, with hinted threats. The last 2 of the tweets read thus:

musella 3:32am via Web

Do not stand in the opposite of "truthfulness, benevolence, forbearance", do not think that disasters are accidental. @xah_lee

musella 3:33am via Web

To be or not to be ? That is a question for you to choose. @xah_lee

Here's the screenshot of the whole tweets:

falung gong tweet threat

screenshot of tweets from Falung Gong group.

Falun Gong Front Groups

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

Falun Gong Front Groups

Xah Lee, 2011-02-28

Just discovered this post at Source www.politicsforum.org . It lists some front groups of Falun Gong. I learned, that recently the call for China to start a revolution, which seems to be from “boxun.com”, is a Falun Gong front group as i suspected. (See: Chinese Revolution à la Egypt?.)

Here's the post.

✻ ✻ ✻

Posted: Mon 21 Feb 2011, 17:26, by benpenguin

First post here, hi guys!

I know Falun Gong is almost a dead topic, but I can assure you they are still around, just under various alias or disguises. To the trained eyes however, no matter what name they are under, one can spot them easily by reading the heavily loaded language, heavily critical to the Chinese Communist Party (CCP) with similar style to the CCP official propaganda in the 1960 era (Well the CCP is much smarter now)

A bit of background information about Falun Gong(FLG) front organizations — openly FLG or disguised:

Media Groups:

  • http://www.ntdtv.com — NTD TV
  • http://www.boxun.com — Boxun news
  • http://www.theepochtimes.com — Epoch Times
  • http://www.minghui.org — Ming Hui (Openly FLG)
  • http://www.soundofhope.org — Soung of Hope radio
  • http://www.renminbao.com — People's Newspaper (LOL I love this one, the name confuses with the Chinese official newspaper)


  • http://www.chinainterimgov.org/ — China Interim Government (Yes it is real — they even elected a president and parliament!)
  • http://www.shenyunperformingarts.org — Shen Yun Performing Arts (I betcha seen their ads somewhere on the streets — if you didn't, you're blind )

I couldn't list all their organizations, but you get the point — all the above organizations / media is nearly 100% founded by Falun Gong faithfuls. Everytime you make an argument against them on facebook, you are quickly swarmed by FLG loyals saying that you violate their freedom of speech / is brainwashed / simply needs to look at their book (I did)

Are they a cult? Well, because the CCP said they are, doesn't mean they aren't. To my definition, they are a cult. Where did I do my research? Reading their book, their own websites, and talking to their members.

Trust me, they are bloody scary.

Now lets take a look of some of some of their insider stuff:

  • 1. Old forces — Master Li, head of the movement, once said "old and evil forces" — used to describe evil spirits and CCP (Which is also evil spirit) The term is then used to describe everything they don't like. Denouncing made easy!
  • 2. Denial of medicine — because FLG guys are "spiritual" in nature, they cannot get sick, and therefore no need for conventional medicine. What if somebody in FLG died of sickness? Well, he's not doing it right. HOWEVER, they are not stopping you to see a doctor if you want to.
  • 3. “To succeed, you need to listen to the master. If you fail, you are not listening to the master.” One of the basic morals in their book. The master means Mr. Li Hong Chi, the founder — no1 else can be “master”. FLGers are ferociously loyal to the master, and will nearly burst into grateful tears when talking about him — just read some of their newspapers and you get the point.

These guys claim that they are not an organization. Well, they are certainly organized. Why did they get banned in the first place? They ORGANIZED 10000 practitioners to surround Chong Nan Hai, China's power enclave (or Russia's Kremlin in that respect) How did they do that without the Chinese police even noticing? They organized the event on the internet, which is under heavy monitor from the CCP. THE CCP DIDN'T SEE THEM COMING UNTIL THE DAY! Well, that can only mean they infiltrated the CCP beforehand.

They did threw a lot of accusations of CCP organ harvesting and prosecution. Prosecution needs no explanation — I will do that if were I in CCP's place — but organ harvesting? They did provided some circumstantial evidence, but nothing solid. An independent human rights group investigated their claims and found no evidence as well.

And being mistreated still doesn't count as an argument that they are not a cult anyway!

Cult or new spiritual movement? YOU decide.


STRiDA LT Folding Bike


Strida LT folding bike

“STRiDA LT Folding Bike” amazon

See also Wikipedia articles: Folding bikeStrida.

Emacs Lisp: Find String Inside HTML Tag

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

Emacs Lisp: Find String Inside HTML Tag

Xah Lee, 2011-02-27

This page shows emacs lisp script that search files, similar to unix grep, but with the condition that the string must happen inside a HTML tag. If you don't know elisp, first take a look at Emacs Lisp Basics.

The Problem

Few days ago we covered How to Write grep in Emacs Lisp. With a few lines of change, here's a version that search a string only if it is inside a html tag. This is something grep and unix tool bag cannot do, and difficult to do even with Perl, Python, unless you use a HTML parser.


Here's the code:

;; -*- coding: utf-8 -*-
;; 2011-02-25
;; print files that meet this condition:
;; contains <div class="x-note">...</div>
;; where the text content contains more than one bullet char •

(setq inputDir "~/web/xahlee_org/" ) ; dir should end with a slash

(require 'sgml-mode) ; need sgml-skip-tag-forward

(defun my-process-file (fpath)
  "process the file at fullpath fpath ..."
  (let (mybuffer 
p3 p4  (bulletCnt 0) (totalCnt 0)

        (and (not (string-match "/xx" fpath)) ) ; skip some dir

      (setq mybuffer (get-buffer-create " myTemp"))
      (set-buffer mybuffer)
      (insert-file-contents fpath nil nil nil t)

      (setq bulletCnt 0 ) 
      (goto-char 1)
          (search-forward "<div class=\"x-note\">"  nil t)

        (setq p3 (point) ) ; beginning of text content, after <div class="x-note">
        (sgml-skip-tag-forward 1)
        (backward-char 6)
        (setq p4 (point) ) ; end of tag content, before the </div>

        (setq bulletCnt (count-matches "•" p3 p4) )

        (when (> bulletCnt 2)
          (setq totalCnt (1+ totalCnt) )
          (princ (format "this many: %d %s\n" bulletCnt fpath))

      (kill-buffer mybuffer)

(require 'find-lisp)

(let (outputBuffer)
  (setq outputBuffer "*xah occur output*" )
  (with-output-to-temp-buffer outputBuffer 
    (mapc 'my-process-file (find-lisp-find-files inputDir "\\.html$"))
  (princ "Done deal!")

The code is almost exactly the same as our previous grep in Emacs Lisp code, with only about 5 line change. (if you are not familiar with the code, see: grep in Emacs Lisp.)

Here's the main part that's different:

          (search-forward "<div class=\"x-note\">"  nil t)

        (setq p3 (point) ) ; beginning of text content, after <div class="x-note">
        (sgml-skip-tag-forward 1)
        (backward-char 6)
        (setq p4 (point) ) ; end of tag content, before the </div>

        (setq bulletCnt (count-matches "•" p3 p4) )

        (when (> bulletCnt 2)
          (setq totalCnt (1+ totalCnt) )
          (princ (format "this many: %d %s\n" bulletCnt fpath))

The interesting part here is the use of “sgml-skip-tag-forward” function. It moves the cursor to the end of the tag, skipping all nested tags. Without this function, it may take days to code it in any language, unless you have experience in writing parsers. (note that this cannot be done with regex.)

The other thing i really love about this is that we are not using a XML parser. If you do this in Perl or Python, you almost certainly have to use a HTML/XML parser. With that, your code becomes really complex, dealing with parents, child, tree structure, and not simple text processing.

O Emacs! ♥


Find & Replace, or just Find, has extensive use in text processing. Here's some examples of variations, all of which i need on weekly basis and have several elisp scripts to do the job:

  • Find by printing file names.
  • Find by printing adjacent text.
  • Find by condition of number of occurrences.
  • Find only if the file contains a set of strings.
  • Replace text based on file's name.
  • Find (or and Replace) only if <title> and <h1> name doesn't match.
  • Find/Report/Replace only if the string is at a particular position in the file. (e.g. near top, near bottom.)
  • Find only if the string is inside a tag.

Why I Wrote This Code

Here's a little side story on why i wrote this one. It's a bit long.

I have about 30 classic literature with annotations. For example: The Tale Of The Bull And The Ass. The annotation system is custom HTML tags with proper CSS. (so-called HTML Microformat) Extensive custom emacs commands are used to insert such tags. (you can see these commands at Xah Lee's Emacs Customization Files.)

Each annotation are in the tag <div class="x-note">…</div>. For example:

<div class="x-note">• provaunt ⇒ provide. Provant is a verb meaning: To supply with provender or provisions.</div>

However, some “x-note” block is multiple annotations in one. For example, in the story The Fisherman And The Jinni, there's this one:

<div class="x-note">• stint ⇒ a fixed amount or share work.
• might and main ⇒ with all effort and strength.
• skein ⇒ A quantity of yarn, thread, or the like, put up together, after it is taken from the reel.
• buffet ⇒ hit, beat, especially repeatedly.
• fain ⇒ with joy; satisfied; contented.

Each of the annotation are marked by a bullet “•” symbol, followed by a word. Each word corresponds to the same word in the main text marked by <span class="xnt">…</span>. (I pack multiple annotation into one “x-note” block to save space in html rendering.)

This annotation system is not perfect. It is static HTML/CSS based. Recently i've been thinking of making it more dynamic based on Javascript. With Javascript, it's possible to have features such as hide/show annotation. Or, mouse over to have a annotation show. Or, mouse-over any word to show its definition from a online dictionary.

To make that possible from my existing system, i need to make sure of few things:

  • ① My custom markup must have precise semantics.
  • ② The syntax should be as simple as possible. (otherwise it increases the work in js code)
  • ③ My html file's annotation markup must have correct syntax. (else js will fail silently)

With my current system, a annotation block is contained in a “x-note” tag, and within that block, each annotation is marked by a bullet. This semantic is precise, but isn't simple enough. If i want javascript to automatically highlight the annotation text when user mouse-over a annotated word, the js will have to do some parsing of text in the “x-note” block.

It would be simpler, if each “x-note” block contains just ONE annotation. This means, i will first change all my files that contain multi-annotation blocks to make them 1-annotation per block. This is a text processing job. (Hello emacs lisp!) But it will probably take a full day's work over about a thousand files. The number of files doesn't matter. What'd be time consuming is to do it correctly. First, i need to make sure the text has correct syntax. For example: make sure that each “x-note” do indeed contain at least one bullet symbol. Make sure that each <span class="xnt">…</span> has a corresponding <div class="x-note">…</div>. (i will be writing emacs lisp scripts to do these validation tasks.)

So, that's why i wrote this script. I wanted to get some idea of how many “x-note” blocks in which files actually contain multi-annotations.