2010-07-23

misc: google earth, kml, emacs lisp scripting

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

In the past few days, been working on my site that heavily involves emacs lisp scripts i've written.

First is a update to my kml files. See: (Google Earth) KML Validation Fuckup. This involves also updating my script for generating kml files, see: Emacs Lisp: Writing a google-earth Function. Then, i created a collection of links to kml files. See: Google Earth Files at XahLee.org. This is done by modifying my elisp script that generate Wikipedia links. See: Generate a Web Links Report with Emacs Lisp.

2010-07-22

(Google Earth) KML Validation Fuckup

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

(Google Earth) KML Validation Fuckup

Xah Lee, 2010-07-22

This article documents a condition of a software industry. It is a rant on software correctness and standards body responsibility.

So, today i'm working on kml files on my site again.

For example, a typical kml file on my site looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Placemark>
<name>Aapua wind park</name>
<description>
Good for a visit.

Seven 80 meter high wind turbines.

See photos at:
 http://xahlee.org/Whirlwheel_dir/windturbine.html
</description>
<Point><coordinates>23.436459,66.827370</coordinates></Point>
<LookAt>
 <longitude>23.436459</longitude>
 <latitude>66.827370</latitude>
 <altitude>0</altitude>
 <range>10000</range>
 <tilt>0</tilt>
 <heading>0</heading>
</LookAt>
</Placemark>
</kml>

Usually i'm super careful about correctness, so when i started to add kml files on my website, i made sure that they are valid. I'm spend several hours reading Google Earth's kml tutorial, and reading Wikipedia on KML about it. I know, for a certainty, that the format i created to be used on my site are correct.

However, i don't remember that i've ever used a kml validator to verify whether my kml files pass. I think at the time (this is in 2006), there's no kml validators. In any case, so today i quickly found a authoritave kml validator at http://www.kmlvalidator.com/. And, boom, it says my files are invalid.

The first error is:

This does not appear to be an OGC KML document--expected document element in namespace "http://www.opengis.net/kml/2.2", but found: "http://earth.google.com/kml/2.2"

What the fuck?

The second error is:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'tilt'. One of '{"http://www.opengis.net/kml/2.2":altitudeModeGroup, "http://www.opengis.net/kml/2.2":LookAtSimpleExtensionGroup, "http://www.opengis.net/kml/2.2":LookAtObjectExtensionGroup}' is expected.

I'm absolutely sure that i followed google tutorial carefully. So i went to google tutorial, again http://code.google.com/apis/kml/documentation/kml_tut.html. The phrase “http://earth.google.com/kml/2.2” is now nowhere to be found there. Apparantly, they changed it. Also, it no longer contain any "<tilt>" tag.

Apparantly, thru the years, as tech and software progressed, they made changes and fixed things, as usual. But the point here is, today a working programer has to know tens of protocols, formats, and multiple languages, and if the programer is super careful to follow spec, and later be fucked in the face for his efforts to follow spec, then why should listen to anything about correctness dealt out by standards bodies?

When XML and XHTML came alone in about 2000, we are told that XHTML will change society, or, at least, make the web correct and valid and far more easier to develop and flexible. Now it's a decade later. Sure the web has improved, but as far as html/xhtml and browser rendering goes, it's still a fuck soup with extreme complexities. It's hard to say if it is better at all than the HTML3 days with Font tags. The best pratical approach is still trial n error with browsers.

And, now HTML5 comes alone with a attitude, a flying fuck to the face about how XML is to replace html that was the mantra from standards bodies.


PS The story of my kml above is actually slightly simplified. When i started to create kml files in 2006, Google's tutorial says:

<kml xmlns="http://earth.google.com/kml/2.1">

But in around 2008, when i was working on kml again, i noticed that the version is not 2.1 anymore but 2.2, and i think the Google tutorial for a simple file start to contain the LookAt tag, like this:

 <LookAt>
 <longitude>23.436459</longitude>
 <latitude>66.827370</latitude>
 <altitude>0</altitude>
 <range>10000</range>
 <tilt>0</tilt>
 <heading>0</heading>
 </LookAt>

I don't remember if it became required tag or not, or if a kml 2.2 file without this blog will simply not have the old behavior in Google Earth. Or, perhaps this i got the idea of this block by looking at the many (thousands) existing kml files in Google Earth.

I spent a hour or two to add this block into my existing ~65 kml files and modified my elisp code that generate kml files. I wouldn't have done it if it wasn't important. Now, it all changes again, and this block is no longer shown in the simple example of Google Earth tutorial. Spent about 4 hours on this today, updating my site and research into this issue, not counting writing this article.

For many kml files, see: The Thousand-and-Second Tale of Scheherazade and Beautiful Architectures.

For emacs lisp code that generates kml files, see: Emacs Lisp: Writing a google-earth Function.

Poor Unfortunate Souls

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

Poor Unfortunate Souls

Xah Lee, 2005-08, 2010-07-22

This is a funny song from the soundtrack of Disney's The Little Mermaid (film) (1989).

Background: pretty little mermaid is half tricked and half curious and came to the sea-witch octopus Ursula to complain about her disatisfaction with her dad (Triton) and yearning to become a human so that she can be with her prince charming. In this song, Ursula seduces and ensnares Little Mermaid to sign a contract so the mermaid can get legs, but with the cost of her beautiful voice. In 3 days, if Little Mermaid get her prince charming to kiss her, then she gets her legs permanently and her voice back, else Ursula owns her soul.

Title: Poor unfortunate souls
Singer: Pat Carroll (as Ursula), Jodi Benson (as Ariel)
Lyrics: Howard Ashman
Music: Alan Menken

Ursula: The only way to get what you want is to become a human yourself.

Ariel: Can you do that?

Ursula: My dear, sweet child. That's what I do — it's what I live for. To help unfortunate merfolk — like yourself — poor souls with no one else to turn to.

「• mended = to repair, patche up, fix, alter for the better.」
「• get the girl = chicks want to get thinner (prettier), guys want to get the chicks. Here, shows the eternal human desire, based on biological requirement for propagation.」
I admit that in the past I've been a nasty
They weren't kidding when they called me, well, a witch
But you'll find that nowadays
I've mended all my ways
Repented, seen the light and made a switch
True? Yes
And I fortunately know a little magic
It's a talent that I always have possessed
And here lately, please don't laugh
I use it on behalf
Of the miserable, lonely and depressed (pathetic)

Poor unfortunate souls
In pain, In need
This one longing to be thinner
That one wants to get the girl
And do I help them?
Yes, indeed

Those poor unfortunate souls
So sad
So true
They come flocking to my cauldron
Crying, “Spells, Ursula please!”
And I help them?
Yes, I do

Now it's happened once or twice
Someone couldn't pay the price
And I'm afraid I had to rake 'em 'cross the coals
Yes, I've had the odd complaint
But on the whole I've been a saint
To those poor unfortunate souls

Ursula: Have we got a deal?

Ariel: If I become human, I'll never be with my father or sisters again.

Ursula: But you'll have your man. Life's full of tough choices, isn't? Oh — and there is one more thing. We haven't discussed the subject of payment.

Ariel: But I don't have any —

Ursula: I'm not asking much. Just a token, really, a trifle. What I want from you is... your voice.

Ariel: But without my voice, how can I —

Ursula: You'll have your looks! Your pretty face! And don't underestimate the importance of body language! Ha!

「• blabber = To chatter; babble.」
「• prattle = idle or foolish and irrelevant talk.」
「• dote = show excessive affection for.」
「• swoon = To be overwhelmed by ecstatic joy.」
「• fawn = To seek favor or attention by flattery and obsequious behavior.」
「• on a roll = idiom. Meaning: Undergoing or experiencing sustained, even increasing good fortune or success. (AHD)」
「• Caspian Sea = The Caspian Sea is the largest enclosed body of water on Earth by area. It's borders are Iran, Russia, Kazakhstan, Turkmenistan, Azerbaijan. It's near Black Sea, and to to the right of Black Sea. It is smaller than Black Sea but Black Sea is somewhat does not count as enclosed by land. Caspian Sea
The men up there don't like a lot of blabber
They think a girl who gossips is a bore
Yes, on land it's much preferred
For ladies not to say a word
And after all, dear, what is idle prattle for?
Come on, they're not all that impressed with conversation
True gentlemen avoid it when they can
But they dote and swoon and fawn
On a lady who's withdrawn
It's she who holds her tongue who gets her man

Come on, you poor unfortunate soul
Go ahead!
Make your choice!
I'm a very busy woman
And I haven't got all day
It won't cost much
Just your voice!

You poor unfortunate soul
It's sad
But true
If you want to cross a bridge, my sweet
You've got to pay the toll
Take a gulp and take a breath
And go ahead and sign the scroll!

Flotsam, Jetsam, now I've got her, boys
The boss is on a roll
THIS POOR UNFORTUNATE SOUL.

“Beluga....Sevruga....Come Winds of the Caspian Sea!”
“Now rings us glossitis and maxlarnygitis La Voce to me!”
“Now Sing...”

From this, we can also see the mastery of manipulation by the sea-witch. This reminds me of the Star Wars character: Palpatine: The Portrait of a Perfectect Sociopath and Master Politician.

a cartoon drawing of a happy girl-mermaid with a lobster

Cover for The Little Mermaid soundtrack. amazon. This is a great album.

Second Life hamster roller coaster

Perm url with updates: http://xahlee.org/sl/hamster_roller_coaster.html

Second Life Hamster Ball Roller Coaster

Get your Xah Particle Maker today!

My second Second Life video (aka Machinima).

Second Life hamster ball roller coaster. Click on the video to go to YouTube to see a HD version with bigger screen.

My first Second Life video:

Second Life Military air combat, CS vs Ordo. 2010-07-22

Want to dash through walls?
Try Xah Tele-Dasher!

2010-07-21

Screen Video Capture, Screencasting, Software

Perm url with updates: http://xahlee.org/sl/screen_video_capture.html

Screen Video Capture, Screencasting, Software

Xah Lee, 2010-07-21

This page lists some screen video capture software that i've tried, with comments on their quality and purpose.

My need for screen video capture are for 2 purposes:

  • Screen capture video games, in particular, Second Life.
  • Screen capture other non-game applications for teaching, presentation, purposes.

I am primarily interested in Windows version, and free ones. Also, i'm a programer, so, it is ok if the program is slightly technical. But am interested in flexibility. In ability to saving the video on my disk in standard video codecs/formats.

Camstudio Open Source

CamStudio. Free, but not very good. It offers pretty old codecs. The codec it offers are:

  • Microsoft Video 1
  • Cinepak
  • Intel IYUV

These are about 20 years old tech. Practically, what it means is that the video you created will have a low “video quality”/“file size” ratio in comparsion to modern codecs.

Jing

I tried Jing. Home page at: jingproject.com.

It's kinda modern social network thing. You can do screenshot and video catpure, then automatically upload it to a site.

It's well supported, free, commerical app.

But it's not designed for video game screen capture.

It saves your file as Flash and auto upload. If you want to save on disk or in some other format, or upload to YouTube, you have to buy the pro version. $14.95 a year.

Also, you need to signup to a online service that hosts your video you captured using Jing.

Overall, this is not a solution for capture video game play.

Note: if all you want to do is show your screen to friends, you can use Skype. It's free and can show a area of your screen to your friend in real time. See: Skype Chat Encryption and Screen Sharing.

WeGame

wegame.com. A commercially backed game vid blog service.

WeGame is similar to Jing. It is tied together with gaming video hosting website, and is commercially backed, high quality, and free.

It's very nice.

Camtasia

The company that makes Jing is TechSmith, it also makes the Camtasia Studio. $300.

Camtasia is a pro level tool for video capture. If video capture is only your hobby, then the price is probably too high.

Fraps

The most popular vid capture software for gaming is Fraps. Home page at: fraps.com.

It's a commercial software.

Fraps is designed for recording PC games only. You can't use it to record for example non-game applications. More precisely, it can record the app only if the app uses DirectX or OpenGL as a core runtime system.

Free version limits 30 secs of video, and with a watermark on your video. Full version costs $37.

The file format is “avi”, a widely supported file format. However, the code used is Fraps's own FPS1, a near lossless codec. That means, it's got high quality, but huge file size. 10 secs of recording, at 992x686 size and 30 frame per second, is 61 mega bytes. The FPS1 codec is proprietary. If you send your video to friends, they won't be able to play it, unless they also have Fraps installed.

To distribute your video or upload somewhere, you'll have to use some other tool to convert it to other codec. The fraps website recommend using “tmpgenc” or “VirtualDub” for this. But you can just use VLC media player. Go to the menu “Media‣Convert / Save”, then select a file. Then, click the “Convert/Save” button, then it'll show a dialog for you to enter a file name, codec to use, and file format to use. Here's the good codecs and container format you should use:

  • H.264 for video, AAC for audio, and MP4 as container format (file name ends in “.mp4”).
  • VP80 for video, Vorbis for audio, and Webm as container format (file name ends in “.webm”).

The first is most widely supported. The second is less supported, but is open source and owned by Google. Both are latest tech. Their quality are about the same.

If you are confused about codecs and container formats, see: Intro to Video Streaming and Video Audio Codecs.

Summary: If you do a lot video game capture, Fraps is the one to get. The downside is that it's not free.

Want to dash through walls?
Try Xah Tele-Dasher!

Others

Others i have to try:

For a full list of screen video capture software, see:

2010-07-20

Free Audio, Synthesizers, Software

Perm url with updates: http://xahlee.org/piano/music_audio_synth_software.html

Free Audio, Synthesizers, Software

Xah Lee, 2010-07-20

This page is a basic introduction to major audio software and technologies that are free. For example, what are the major audio editing software, software synthesizers, midi player, music recorder, what are the major technology components for audio, etc. This page is useful if you need to record or create audio files, but is a beginner in the field. This page is written mostly for people with a technical background, e.g. scientists, engineers, computer programers. (i'm a professional computer programer and amature mathematician)

Am looking for a software synth. My primary use will be to generate artificial sounds to create various beeps or sci-fi plasma gun for video games.

I've been dabbling with synthesizers since 1985. Owned about 6 music keyboards over the past 20 years. Studied music, music theory, playing piano, piano keyboard mechanisms, physics of music, tuning systems, midi technologies, music notation systems, music notation softwares, audio file fomats, etc. Though, i haven't been actively doing any sound related tasks or music since about 2000. I'm out of touch with the technologies.

The following are learning notes primarily for myself.

Some Technologies

SoundFont is a brandname tech that's basically a bank of sampled sounds.

Virtual Studio Technology (VST). A interface for integrating software audio synthesizer and effect plugins with audio editors and hard-disk recording systems. Used in many audio software.

Advanced Linux Sound Architecture (ALSA)

JACK Audio Connection Kit JACK (a recursive acronym which expands to JACK Audio Connection Kit) is a professional sound server daemon that provides real-time, low latency connections for both audio and MIDI data between applications that implement its API.

Audio Software

Audacity. A general digital audio editor. Mostly for recording sound, and editing, and save in several file formats.

Rosegarden Rosegarden is a free software digital audio workstation program developed for Linux with ALSA and QT4. It acts as an audio and MIDI sequencer, scorewriter and musical composition and editing tool. It is intended to be a free alternative to such applications as Cubase.

TiMidity, a software that plays midi files, and can also save the audio output as a file.

macaw Music synthesizer, sequencer, waves and sampler.

For a full list: Free audio software.

Software Synths

The following are mostly free ones.

FluidSynth. qsynth is a gui to FluidSynth.

ZynAddSubFX.

21st Century Schizoid Man

Perm url with updates: http://xahlee.org/piano/21st_century_schizoid_man.html

21st Century Schizoid Man

Xah Lee, 2008-12-13, 2010-07-20

The group's name is either Seasons or In-Season. Official home page is at: in-season.jp.

The original song is progressive rock, called by same name 21st Century Schizoid Man (1969), performed by King Crimson.

21st century schizoid man

〈In the Court of the Crimson King〉 amazon

The song is written by Robert Fripp, Ian McDonald, Greg Lake, Michael Giles, Peter Sinfield. The lyrics is by Peter Sinfield. It's sung by Greg Lake.

Here's the lyrics.

Cat's foot iron claw
Neuro-surgeons scream for more
At paranoia's poison door.
Twenty first century schizoid man.
「• Polititians = this mostly refers to Spiro Agnew (1918-1996), 39th Vice President of US (1969-1973). He is charged for accepting bribery and is forced to resign.」
「• pyre = wood heaped for burning a dead body as a funeral rite.」
「• napalm fire = Napalm is a sticky substance for burning, used in military. This line refers to Vietnam War.」
Blood rack barbed wire
Polititians' funeral pyre
Innocents raped with napalm fire
Twenty first century schizoid man.
Death seed blind man's greed
Poets' starving children bleed
Nothing he's got he really needs
Twenty first century schizoid man.

Schizoid is actually a technically term in psychiatry. The full term is Schizoid Personality Disorder. Vernacularly, schizoid man means something like a crazy or delusional person, however, the real meaning is entirely different.

Schizoid personality disorder (SPD) is characterized by a emotionless personality. That is, the person lacks the normal human desire for friendship, being part of community, or any relationship, affinity. Schizoids are loners. They prefer to be alone, and usually live alone. (I am a mild schizoid)

Each human animal, has a aspect of personality. That is, their likes and dislikes, manner, deportment, behavior pattern, etc. When a personality trait is so extreme, that it effects the normal function of a person in society, that's when psychiatrists calls it a personality “disorder”.

Each of us all sometimes prefer to be alone. Some more than others, with qualities of being shy, timid, introvert. However, when a person prefers to be alone at all times to a degree that it interferes his normal daily activity in society, such as at work, marriage, having children, he technically have a schizoid personality “disorder”. The “disorder” label may not be appropriate, because SPD typically do not cause the person to have any problem with law, e.g. become criminals or effect others. In contrast to, for example, antisocial personality disorder.

2010-07-19

“Please Don't Stop the Music”; Virtuoso Piano

Perm url with updates: http://xahlee.org/piano/please_dont_stop_the_music_piano.html

“Please Don't Stop the Music”; Virtuoso Piano

Xah Lee, 2010-07-19

Someone has composed a virtuoso piano piece based on a pop song “Please Don't Stop the Music” by Rihanna.

Here's the original song sung by Rihanna.

Not really a great song. The song is somewhat flat. The melody is also flat. The music video is also lousy. It just repeatedly display her beautiful eyes and face.

Here's the virtuoso piano composition inspired by it.

“Lola Astanova - Virtuoso piano inspired by Rihanna's Don't Stop The Music”

Great performance. Though, i don't particularly find this composition attractive. It lacks a strong melodic element, despite the fact that the original song already isn't noted for its melody.

How to Embed Video with Valid HTML

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

How to Embed Video with Valid HTML

Xah Lee, 2009-01-16, 2010-06-06

This page shows you how to embed a video with valid html, and also practical that it display video in all current browsers. (tested browsers: IE 8, Firefox 3, Safari, Google Chrome, Opera.)

YouTube Example

Suppose you have a youtube video you want to embed in your html page. Suppose the url is this http://www.youtube.com/watch?v=J_DV9b0x7v4. If you just copy and paste their link widget, you get this:

<object width="425" height="344">
  <param name="movie"
    value="http://www.youtube.com/v/J_DV9b0x7v4&hl=en&fs=1">
  </param>
  <param name="allowFullScreen" value="true"></param>
  <param name="allowscriptaccess" value="always"></param>
  <embed src="http://www.youtube.com/v/J_DV9b0x7v4&hl=en&fs=1"
    type="application/x-shockwave-flash"
    allowscriptaccess="always"
    allowfullscreen="true"
    width="425" height="344">
  </embed>
</object>

If you pass it thru w3c's html validator, the errors light up like a neon sign.

Here's a valid html markup for youtube video:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>video test</title>
</head>
<body>

<div>
  <object
    type="application/x-shockwave-flash"
    data="http://www.youtube.com/v/J_DV9b0x7v4"
    width="425"
    height="355">
    <param name="movie" value="http://www.youtube.com/v/J_DV9b0x7v4">
  </object>
</div>

</body>
</html>

In html 4, there is no “embed” tag. Instead, there's “object” tag, which is supposed to let you embed diverse type of objects, such as video, audio, java applets.

With the “object” tag, the value for “data” attribute should be a url of your object. The “type” attribute should be the internet media type format.

The object tag can have 0 or more of “param” tags, each param tag specifies a argument. In the above example, we don't really need it. As of 2009-01, Firefox, Safari, Opera, all will display the embeded video. However, Internet Explorer 7 won't. The “param” tag above is a fix for IE.

Google Video Example

Here's the code from their embeded widget:

Incorrect

<embed id=VideoPlayback
 src=http://video.google.com/googleplayer.swf?docid=3685846746009919856&hl=en&fs=true
style=width:400px;height:326px
allowFullScreen=true
allowScriptAccess=always
type=application/x-shockwave-flash>
</embed>

Correct

Here's a fixed code:

<div>
<object
 type="application/x-shockwave-flash"
 data="http://video.google.com/googleplayer.swf?docid=3685846746009919856&amp;fs=true"
 width="400" height="326">
<param name="movie" value="http://video.google.com/googleplayer.swf?docid=3685846746009919856&amp;fs=true">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
</object>
</div>

You must have the “&fs=true” and “<param name="allowFullScreen" value="true">” for full screen to work.

If you take out the “<param name="allowScriptAccess" value="always">”, then the menu to go to the original google video page won't work.

tudou.com Example

Incorrect

<embed src="http://www.tudou.com/v/9OoINUl31dQ/v.swf"
 type="application/x-shockwave-flash"
 allowscriptaccess="always"
 allowfullscreen="true"
 wmode="opaque"
 width="480"
 height="400"></embed>

Correct

<object
 type="application/x-shockwave-flash"
 data="http://www.tudou.com/v/9OoINUl31dQ/v.swf"
 width="480"
 height="400">
 <param name="movie" value="http://www.tudou.com/v/9OoINUl31dQ/v.swf">
</object>

Redtube Example

Suppose you want to embed the video http://www.redtube.com/7291 of a porn website. If you click on their widget, it gives you this markup:

Incorrect

<object height="315" width="434">
<param name="movie" value="http://embed.redtube.com/player/">
<param name="FlashVars" value="id=7291&style=redtube">
<embed src="http://embed.redtube.com/player/?id=7291&style=redtube"
pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash"
height="315" width="434">
</object>

The above is not valid. The following is a valid equivalent:

Correct

<object type="application/x-shockwave-flash"
data="http://embed.redtube.com/player/?id=7291&amp;style=redtube" width="434" height="315">
<param name="FlashVars" value="id=7291&amp;style=redtube">
<param name="movie" value="http://embed.redtube.com/player/?id=7291&amp;style=redtube">
</object>

In this case, we used 2 “param” tags. The one with the “FlashVars” is necessary, else redtube won't load the video. The one with the “movie” is again just for IE.

dailymotion.com Example

Here's another example. This is a video from http://www.dailymotion.com/video/xz3am_white-rabbit-jefferson-airplane-liv_music.

Incorrect

Their widget gives you this code:

<object width="420" height="339">
<param name="movie" value="http://www.dailymotion.com/swf/xz3am" />
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always" />
<embed src="http://www.dailymotion.com/swf/xz3am"
 type="application/x-shockwave-flash"
 width="420" height="339"
 allowFullScreen="true" allowScriptAccess="always">
</embed>
</object>

The code is not valid xhtml.

Correct

Here's a valid html version:

<div>
<object
 type="application/x-shockwave-flash"
 data="http://www.dailymotion.com/swf/xz3am"
 width="420" height="339">
<param name="movie" value="http://www.dailymotion.com/swf/xz3am">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
</object>
</div>

Note that “<object>” tag must be inside a container such as “<div>” in HTML 4.01 Strict, but not in HTML 4.01 Transitional.

http://www.w3.org/TR/html401/struct/objects.html

break.com Example

Here's another example. This is a video from http://www.break.com/usercontent/2008/10/Britney-Spears-Womanizer-Uncensored-592196.html (2010-07-19)

Incorrect

<object width="464" height="283"
id="592196"
type="application/x-shockwave-flash"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
alt="Britney Spears - Womanizer Uncensored Funny  Videos">
<param name="movie" value="http://embed.break.com/NTkyMTk2"></param>
<param name="allowScriptAccess" value="always"></param>
<embed src="http://embed.break.com/NTkyMTk2"
type="application/x-shockwave-flash"
allowScriptAccess=always
width="464" height="283"></embed>
</object>
<br>
<font size=1>
<a href="http://www.break.com/usercontent/2008/10/Britney-Spears-Womanizer-Uncensored-592196.html" target="_blank">
Britney Spears - Womanizer Uncensored</a>
 - Watch more <a href="http://www.break.com" target="_blank">Funny  Videos</a>
</font>

Correct

<div>
<object
 type="application/x-shockwave-flash"
 data="http://embed.break.com/NTkyMTk2"
 width="464" height="283">
<param name="movie" value="http://embed.break.com/NTkyMTk2">
<param name="allowScriptAccess" value="always">
<param name="id" value="592196">
<param name="classid=" value="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
</object>
</div>

Womanizer by Britney Spears

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

Womanizer by Britney Spears

Womanizer (2008), a hot song by Britney Spears.

Superstar
Where you from, how's it going?
I know you
Gotta clue, what you're doing?
You can play brand new to all the other chicks out here
But I know what you are, what you are, baby

Look at you
Gettin' more than just a re-up
Baby, you
Got all the puppets with their strings up
Fakin' like a good one, but I call 'em like I see 'em
I know what you are, what you are, baby
 Womanizer, Woman-Womanizer
 You're a womanizer,
 Oh womanizer, Oh you're a womanizer, baby
 You, you, you are
 You, you, you are
 Womanizer, womanizer, womanizer

Boy, don't try to front
I, I know just-just what you are, are, are

(You) You got me going
(You) You're oh so charming
(You) But I can't do it
(You) Womanizer

(You) You say I'm crazy
(You) I got you crazy
(You) Your nothing but a
(You) Womanizer
Daddy-O
You got the swagger of a champion
Too bad for you
You just can't find the right companion
I guess when you have one too many, makes it hard
It could be easy, who you are, that's just who you are baby

Lollipop
Must mistake me as a sucker
To think that I
Would be a victim not another
Say it, play it how you wanna
But no way I'm ever gonna fall for you, never you, baby

...

Maybe if we both lived in a different world
It would be all good, and maybe I could be ya girl
But I can't 'cause we don't

...

See also a parody here: Womanizer (video).

2010-07-18

珊瑚恋 (A Coral Romance)

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

珊瑚恋 (A Coral Romance)

Xah Lee, 2005, 2010-07-18

珊瑚恋 (A Coral Romance) is a song originally sung by a Taiwanese singer 翁倩玉 (b1950, Judy Ongg) who migrated to Japan. The song is originally a Japanese song, called “海辺のMelody (海辺のメルヘン)”. Later, many have written Chinese lyrics. In particular, the song has been sung by Teresa Deng. Source

Teresa's version is my favorite.

Title: 珊瑚恋
Singer: 邓丽君 (Teresa Deng)
Lyrics: 翁炳榮 original, later versions 莊奴, 李德安
Music: 市川昭介, later 仁田
Translation: 李杀 (Xah Lee)
那一天
偶然在海边遇见了他
像蛟鱼一样地活泼又健康
从身上掏出了
洁白的一个珊瑚
悄悄地走过来
默默地递给了我
就是这样的动作
仅仅就是这样
使我有一种感觉
永难忘记
说是情仿佛不少
说是爱 还嫌太早
只像是春风
静掠过我的心胸
过完了那夏天
踏上了我的归途
他曾向我的车
挥着手大声叫喊

无情的大海浪
淹盖了他的呼唤
连那只他的手
逐渐地也看不见

在那年的冬天
突然有个感觉
好像再回到海的那方
为什么这爱的生命
这样短暂
像一场褪了色
美丽的海边的幻梦
on that day
i met him on the beach
like a playful fish
produced from his pocket
a pretty white coral
he came towards me
and given it to me without words
'tis this manner
just like that
arose a feeling in me
i'll never forget
is this affection? maybe
is it love? i can't say yet
it's like a spring breeze
caressed my heart
when summer's over
on my way back
toward my motorcar
he waved and called out

the inexorable sea
buried his callings
even his waving hand
gradually dissapeared in view

winter that year
a feeling seized me
as if i returned to that beach
why is the life of love
so brief
as if a discolored
beautiful beach dream

珊瑚恋,邓丽君

How to Quickly Switch Fonts in Emacs

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

How to Quickly Switch Fonts in Emacs

Xah Lee, 2010-04-10, ..., 2011-03-08

Quickly Switching Fonts in Emacs

When coding in Python or viewing directories in dired, mono-spaced font is necessary. However, proportional font works great in coding too. Try it. You may be surprised.

Proportional font is easier to read, and shows 20 or more characters per line. I got used to using proportional fonts for html, xml, perl, lisp. Even if you don't like proportional font for coding, it is quite useful for reading documentation, email, irc.

One problem is that it is cumbersome to switch font in emacs. Here's a elisp code that cycle fonts.

(defun cycle-font (num)
  "Change font in current frame.
Each time this is called, font cycles thru a predefined set of fonts.
If NUM is 1, cycle forward.
If NUM is -1, cycle backward.
Warning: tested on Windows Vista only."
  (interactive "p")

  ;; this function sets a property “state”. It is a integer. Possible values are any index to the fontList.
  (let (fontList fontToUse currentState nextState )
    (setq fontList (list
                    "Courier New-10" "DejaVu Sans Mono-9" "Lucida Console-10"
                    "DejaVu Sans-10" "Lucida Sans Unicode-10" "Arial Unicode MS-10" 
                    ))
    ;; fixed-width "Courier New" "Unifont"  "FixedsysTTF" "Miriam Fixed" "Lucida Console" "Lucida Sans Typewriter"
    ;; variable-width "Code2000"
    (setq currentState (if (get 'cycle-font 'state) (get 'cycle-font 'state) 0))
    (setq nextState (% (+ currentState (length fontList) num) (length fontList)))

    (setq fontToUse (nth nextState fontList))
    (set-frame-parameter nil 'font fontToUse)
    (redraw-frame (selected-frame))
    (message "Current font is: %s" fontToUse )

    (put 'cycle-font 'state nextState)
    )
  )

(defun cycle-font-foward ()
  "Switch to the next font, in the current frame.
See `cycle-font'."
  (interactive)
  (cycle-font 1)
  )

(defun cycle-font-backward ()
  "Switch to the previous font, in the current frame.
See `cycle-font'."
  (interactive)
  (cycle-font -1)
  )

Modify the section on fontList:

 (setq fontList (list
                    "Courier New-10" "DejaVu Sans Mono-9" "Lucida Console-10"
                    "DejaVu Sans-10" "Lucida Sans Unicode-10" "Arial Unicode MS-10" 
                    ))

so that you can use this function to cycle among the fonts of your choice.

You can set F6 to swich to the next font or previous font. See: Defining Your Own Keyboard Shortcuts.

Also, if you are not using emacs 23, you should upgrade, because emacs 23 switched its internal char encoding to Unicode (utf-8), and has a new font engine that supports operating system's fonts and anti-aliasing. (see: New Features in Emacs 23)

Best Fonts for Coding & Unicode

The best font i found for coding that has heavy unicode math symbols is DejaVu Sans Mono for fixed-width and Lucida Sans Unicode for variable-width. Variable-width is my normal font. I switch to mono for python, dired, calender, etc.

emacs, font DejaVu Sans Mono

Emacs using font DejaVu Sans Mono

emacs, font Lucida Sans Unicode

Emacs using font Lucida Sans Unicode.

variable-pitch-mode

Oscar Carlsson wrote to say there's a “variable-pitch-mode”. That's fantastic. When you turn that on, the buffer uses a variable width font, and sticks to that buffer only. To return to fixed-width font, just call it again. Give it a hotkey for easy toggling.

Changing Line Height

When reading a document, you may want to have extra space between lines, for easy reading. Here's a command that toggles line height.

(defun toggle-line-spacing ()
"Toggle line spacing between no extra space to extra half line height."
(interactive)
(if (eq line-spacing nil)
    (setq-default line-spacing 0.5) ; add 0.5 height between lines
  (setq-default line-spacing nil)   ; no extra heigh between lines
  ))

toggle-word-wrap

If you are using emacs 23, the command “toggle-word-wrap” is useful. When on, long lines are wrapped at white space. Otherwise, words are simply cut in the middle at the edge of window.

emacs23 word wrap

word-wrap off (top) and on (bottom) in emacs 23. Call “toggle-word-wrap” to toggle, or “visual-line-mode”.