new version of emacs math symbol input mode (xmsi-mode)

New version of Emacs Unicode Math Symbols Input Mode (xmsi-mode) (for math symbol and unicode input). This version added about 102 full width symbols. e.g. “fw&” becomes “&”. (these chars probably not useful to most, but i use the fullwidth version of ampersand often to avoid encoding complexity in html) happy using.

See: HTML Entities, Ampersand, Unicode, SemanticsProblems of Symbol Congestion in Computer Languages (ASCII Jam; Unicode; Fortress).

Stack Overflow is based on Microsoft Tech

Am surprised to learn that Stack Overflow is based on Microsoft technologies.

  • framework: Microsoft ASP.NET
  • language: C#
  • development environment: Visual Studio
  • web framework: ASP.NET MVC
  • browser framework: jQuery
  • database: SQL Server 2008
  • data access layer: LINQ to SQL
  • source control: Subversion (now Mercurial through Kiln)
  • compare tool: Beyond Compare
  • source control integration: VisualSVN (now, VisualHg)

See: Source blog.stackoverflow.com.

Great going Microsoft!


Rebecca Black - Friday (song)

Perm url with updates: http://xahlee.org/funny/Rebecca_Black_Friday.html

Rebecca Black - Friday (song)

Xah Lee, 2011-03-24

A 13-years-old girl, Rebecca Black, made a song called “Friday”. It went viral on the net on 2011-03-11, and within a few days, got millions of views. As of today (2011-03-24), it's got 44M views.

Here's the video.

“Rebecca Black - Friday” amazon

I think i first saw the video from twitter. My first impression was: bad song. Monotonic music, brainless lyrics — pubescent teeeens. I closed it without much thought, though i did finish watching it, for my fascination of teens. I didn't know she was 13. I might have taken her to be 16.

According to Forbes.com report, she might be making $60k due to the popularity. Here's the exceedingly intricate lyrics.

(Yeah, Ah-Ah-Ah-Ah-Ah-Ark)
Oo-ooh-ooh, hoo yeah, yeah

Seven a.m., waking up in the morning
Gotta be fresh, gotta go downstairs
Gotta have my bowl, gotta have cereal
Seeing everything, the time is going
Ticking on and on, everybody's rushing
Gotta get down to the bus stop
Gotta catch my bus, I see my friends

Kicking in the front seat
Sitting in the back seat
Gotta make my mind up
Which seat can I take?

It's Friday, Friday
Gotta get down on Friday
Everybody's looking forward to the weekend, weekend
Friday, Friday
Getting down on Friday
Everybody's looking forward to the weekend

Partying, partying (Yeah)
Partying, partying (Yeah)
Fun, fun, fun, fun
Looking forward to the weekend

7:45, we're driving on the highway
Cruising so fast, I want time to fly
Fun, fun, think about fun
You know what it is
I got this, you got this
My friend is by my right, ay
I got this, you got this
Now you know it

Kicking in the front seat
Sitting in the back seat
Gotta make my mind up
Which seat can I take?

It's Friday, Friday
Gotta get down on Friday
Everybody's looking forward to the weekend, weekend
Friday, Friday
Getting down on Friday
Everybody's looking forward to the weekend

Yesterday was Thursday, Thursday
Today i-is Friday, Friday (Partying)
We-we-we so excited
We so excited
We gonna have a ball today

Tomorrow is Saturday
And Sunday comes afterwards
I don't want this weekend to end

R-B, Rebecca Black
So chilling in the front seat (In the front seat)
In the back seat (In the back seat)
I'm driving, cruising (Yeah, yeah)
Fast lanes, switching lanes
Wit' a car up on my side (Woo!)
(C'mon) Passing by is a school bus in front of me
Makes tick tock, tick tock, wanna scream
Check my time, it's Friday, it's a weekend
We gonna have fun, c'mon, c'mon, y'all


There are lots of parodies. Some of them are actually more creative and musical.

“Rebecca Black - Friday, as performed by Bob Dylan” (HeyMikeBauer)

“Friday by Rebecca Black - Cover by Matt Mulholland” (parody)

“Rebecca Black - "Friday" (Brock's Dub)”


That's LOL!

More Covers

“Friday by Rebecca Black (Acoustic Cover by Kalie Shorr!)”


Here's interview on ABC News.

“Rebecca Black - Good Morning America”

I think she's pretty cool, and she certainly can sing.


HTML5 “figure” & “figurecaption” Tags Browser Support

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

HTML5 “figure” & “figurecaption” Tags Browser Support

Xah Lee, 2011-03-24

html5 has a nice “figure” and “figurecaption” tags, for images. Like this:

<img src="../i/lilies-s.png" alt="lilies" width="167" height="106">

Test if you browser support it here: html5 figure figurecaption test page.

Of all latest publically released browsers as of today (2011-03-24), Safari (5.0.4) and Opera (11.01) doesn't support it. Google Chrome (10.0.648.151), Firefox 4.0, IE9, all support it. You can tell because the caption should be rendered beneath the image, not to the right of it.

It's odd that Google Chrome and Safari both runs WebKit engine but behavior is different.


Tsunami in Japan (personal videos)

Here's a 9 minutes video of personal recording.

“大津波 tsunami japan おいらせ町” (wngad869 2011-03-17)

more at http://xahlee.org/Periodic_dosage_dir/tsunami_in_japan.html

CSS “pre” Problem: No Linebreak After Tag

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

CSS “pre” Problem: No Linebreak After Tag

Xah Lee, 2006-07-29, 2011-03-23

This page shows a odd CSS behavior of lines inside “pre” are being rendered without linebreaks. It has to do with “display:table”, and “span” tags.

Here's the html source code:

<pre style="display:table; border:solid thin">
<span style="color:red">line 1</span>
<span style="color:blue">line 2</span>
line 3

Here's what Safari shows:

Safari css pre display table line break

Screenshot of Safari (5.0.4 (7533.20.27)) on Windows.

The following browsers renders the first 2 lines in a single line.

  • Safari (5.0.4 (7533.20.27)) on Windows. (latest version as of 2011-03-23)
  • Google Chrome (10.0.648.151) on Windows. (latest version as of 2011-03-23)
  • Firefox ( Mac)
  • Safari (2.0.4) on Mac

The following browsers renders each line separate.

  • Firefox 4.0 on Windows. (latest version as of 2011-03-23)
  • Internet Explorer 9. (latest version as of 2011-03-23)
  • Opera 11.01 on Windows. (latest version as of 2011-03-23)
  • Opera (9.00 Mac)
  • iCab (β352 (3.0.1))
  • Internet Explorer 6. (however, IE6 does not honor the “display:table” CSS.)

What Does Your Browser Show?

Here's test pages to see what your browser shows.

What Does the Spec Say?

According to http://www.w3.org/TR/html4/appendix/notes.html#notes-line-breaks, quote:

SGML (see [ISO8879], section 7.6.1) specifies that a line break immediately following a start tag must be ignored, as must a line break immediately before an end tag. This applies to all HTML elements without exception.

This may explain this behavior. However, this is indeed a very odd spec. How is one suppose to break the lines inside “pre” in the above situation? Adding “br” is illegal, and adding another line break doesn't help.

If one removes the “display:table”, then all browsers renders the “pre” as expected.


Sex in Second Life: Video Interview with Paisley Beebee

post removed. see it at http://xahlee.org/sl/sex_in_sl.html

emacs cult scumbag: spell checking problem

Emacs cult scumbag. To spell check a file of 2.6k words, it froze emacs for 10 seconds. While in Mozilla Thunderbird and everywhere else it's 0.3 seconds.

Firefox 4 and AutoHotKey, MozillaWindowClass

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

Firefox 4 and AutoHotkey: MozillaWindowClass

Xah Lee, 2011-03-22

Firefox 4 is released today.

If you use AutoHotkey, you'll notice that Firefox's “ahk_class” changed. It was MozillaUIWindowClass, which is also used by Mozilla Thunderbird. But now for Firefox 4 it's MozillaWindowClass.

This is a good change. Because now you can define key sets separate for Firefox and Thunderbird, without resorting to using the window's title or other tricks.

Here's my Firefox keys.

; tttt --------------------------------------------------
;; Mozilla Firefox 4 hotkeys

#IfWinActive ahk_class MozillaWindowClass
; #IfWinActive ahk_class MozillaUIWindowClass
; #IfWinActive Mozilla Firefox

NumpadDiv::Send ^{PgUp} ; previous tab
NumpadMult::Send ^{PgDn} ; next tab

Pause::Send ^w ; close window

; swap middle/right buttons
$XButton2::Send ^w ; close

Send ^t
sleep 100
Send ^v
sleep 100
Send {Enter}

w3c validator fuckup: p tag inside li valid!

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

“p” Tag in “li” as Valid HTML4

If you have “p” tag inside “li”, it's valid! Even in html 4 strict.

(Note that technically any ending tag of “p” and “li” can be omitted.)

Test page: W3C HTML Validation Problem: p in li.

With this situation, at this point, you wonder what's validator supposed to be anymore.


Google Earth Mouse Navigation and Keys

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

Google Earth Mouse Navigation and Keys

Xah Lee, 2011-03-12

Do you find Google Earth's mouse navigation a bit confusing? This page explains.

Mouse Navigation

  • mouse wheel = zoom
  • Left mouse button = pan
  • Middle mouse button = rotate & tilt
  • Right mouse button = smart auto zoom, rotate, tilt. (up/down = zoom ◇ left right = rotate ◇ close to the surface = auto tilt)

By Keyboard

  • Zoom = PgUp, PgDn
  • Pan = , , ,
  • Rotate = 【Shift+】, 【Shift+
  • Tilt = 【Shift+】, 【Shift+

Holding down Alt before doing the above will make the steps smaller.

Extra for Control Freaks

  • tilt camera = 【Ctrl+】 and 【Ctrl+
  • rotate camera = 【Ctrl+】 and 【Ctrl+】 (camera is rotated around a axis from earth center to your camera)

Emacs Lisp Batch Processing: Grep Find Replace Variations

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

Emacs Lisp Batch Processing: Grep Find Replace Variations

Xah Lee, 2011-03-21

This page shows emacs lisp scripts that do variations of grep/find/replace string, and is applied to few thousand files. For example, report the position of a given string, replace a HTML page's “H1” tag text from its “TITLE” tag text. If you don't know elisp, first take a look at Emacs Lisp Basics.

Problem: Report String Position

I need to know if a particular string happens in beginning of file or near the end. Ι need to know this for about 5k files in a dir.


;; -*- coding: utf-8 -*-
;; 2011-03-21
;; report the position (line number) of a occurances of string, of a given dir

(setq inputDir "~/web/xahlee_org/" )

;; add a ending slash if not there
(when (not (string= "/" (substring inputDir -1) ))
  (setq inputDir (concat inputDir "/") )

(defun my-process-file (fpath)
  "process the file at fullpath fpath ..."
  (let (mybuffer (ii 0) searchStr)

    (when (not (string-match "/xx" fpath))

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

      (setq case-fold-search nil) ; NOTE: remember to set case sensitivity here

      (setq searchStr "<div class=\"amz728x90\">" )

      (goto-char 1)
      (while (search-forward searchStr nil t) ; NOTE: for regex, use re-search-forward
          (princ (format "this many: %d %s\n" (line-number-at-pos (point)) 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!")

You can modify the “inputDir” and “searchStr” above and test it on your own machine.

For explanation of this code, see: How to Write grep in Emacs Lisp.

Problem 2: Fix HTML “TITLE” & “H1” Tags

Today, while i working on my website, i noticed some html files are missing a “H1” header tag. While in another directory, i wish to replace all “TITLE” tag content by the one from “H1” tag.

So, i need a script that fix these tag's texts.


Here's a function that gets a file “title” tag text. I wrote this about a year ago.

(defun get-html-file-title (fname)
"Return FNAME <title> tag's text.
Assumes that the file contains the string
 (let (x1 x2 linkText)

     (goto-char 1)
     (insert-file-contents fname nil nil nil t)

     (setq x1 (search-forward "<title>"))
     (search-forward "</title>")
     (setq x2 (search-backward "<"))
     (buffer-substring-no-properties x1 x2)

I also need to get the “H1” tag text. So i just quickly did a copy-paste coding:

(defun get-html-file-h1-text (fname)
  "Return FNAME <h1> tag's text.
Assumes that the file contains the string
  (let (x1 x2 linkText)

      (goto-char 1)
      (insert-file-contents fname nil nil nil t)

      (setq x1 (search-forward "<h1>"))
      (search-forward "</h1>")
      (setq x2 (search-backward "<"))
      (buffer-substring-no-properties x1 x2)

It's not efficient to open file twice to get “title” and “h1” texts, but that's ok, because my whole script will finish running in a few seconds anyway and this is just one-time use.

Now, here's the code i wrote quickly to fix the tags:

;; -*- coding: utf-8 -*-
;; 2011-03-20
;; change title to h1 tag's text in “Time Machine” pages
;; for each html page in 〔~/web/xahlee_org/p/time_machine/〕
;; if the title tag and h1 tag text differ, make the title use h1's text

(setq inputDir "~/web/xahlee_org/p/time_machine/" ) ; dir must end with a slash

(defun my-process-file (fpath)
  "process the file at fullpath fpath ..."
  (let ( titleText h1Text p1 p2)

    (setq h1Text (get-html-file-h1-text fpath))
    (setq titleText (get-html-file-title fpath))

    (if (equal h1Text titleText)
        (find-file fpath )
        (goto-char 1)
        (search-forward "<title>" )
        (setq p1 (point) )

        (search-forward "</title>" )
        (backward-char 8)
        (setq p2 (point) )

        (delete-region p1 p2 )
        (insert h1Text)
        (print fpath)

(require 'find-lisp)

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

Again, all the above script are variations of find/replace. For code detail, see: How to Write grep in Emacs Lisp and Emacs Lisp: Find String Inside HTML Tag.

In this script, i didn't include code to save the changed file. This way, i can do some manual verification after the script has run. When i want them all saved, i just go to ibuffer and type 3 keys 【* u S】 to have all of them saved, and 【D y】 closes them all.

What might you use this script for in your work?




“How many engineers does Microsoft have?” Page asked.

About 25,000, he was told.

“We should have a million,” Page said, in all seriousness.

At that point, Schmidt put an avuncular hand on Page’s shoulder and brought him back to the real world. Now, with Page as CEO, that hand is less likely to be there.

Larry Page Wants to Return Google to Its Startup Roots (2011-03-18) By Steven Levy. @ Source www.wired.com
avuncular = Of or pertaining to an uncle.