2011-05-07

Customeze IE9: Show Tabs In a Separate Row

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

Customize Internet Explorer 9 (IE9): Turn on Menu; Put Tabs in Separate Row

Xah Lee, 2011-05-07

  • To always show the menu bar: press Alt, then in menu 〖View▸Tollbars▸Menu bar〗.
  • In the menu 〖View▸Tollbars▸Menu bar〗, you can choose to show other tool bars.
  • To make the tabs on a separate row: right click on a tab, then choose menu 〖Show tabs on a separate row〗.
  • To customize your toolbars, right click on them, then choose 〖Customize〗.

2011-05-06

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

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

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

Xah Lee, 2011-05-06

“Heineken Commercial - The Entrance”.

The music is “The Golden Age” by The Asteroids Galaxy Tour. amazon.

Here's the syrics:

The Asteroids Galaxy Tour - "The Golden Age"

I wished I lived in the golden age
Giving it up on the broadway stage
Hang with the rats and smoke cigars
Just have a break with Frank and count the stars

Dressed to the nines, we've had too much
Shiny jewels, casino cash
Tapping feet, wanna take the lead
A trip back in time is all I need

Oh!
Sing it out loud gonna get back honey
Sing it out loud get away with me
Sing it out loud on a trip back honey
Sing it out loud and let yourself free

I'm on my way, gonna make it big
Gonna make these songs for the chicks to dig
It's really hot and a little bit sour
We're getting your strength to the maximum power

Flying away from reality
Whatever-ever happened to gravity?
I see it clear, a shooting star
And I'm really gonna sing it like da-da-da

...

Ohhh silver screen on a rainy day
Sally Bowles in a cabaret
Shaking sticks, oh what a show
Fresh and jolly, from tip to toe

Rambling down the boulevard
With a fly, a bird, and a wooden heart
My mind is set, I walk the line
But I never really thought that it would feel this fine

The chick reminds me of Blondie, and the song reminds me of Lily Allen - Fuck You Very Much.

The “Sally Bowles in a cabaret” in the lyrics refers to the movie Cabaret. See: Cabaret Screenshots and Cabaret - Tomorrow Belongs to Me.

encyclopediadramatica sold out

The site 〔encyclopediadramatica.com〕 got sold out and has become 〔ohinternet.com〕. See: Encyclopediadramatica.com. The site's nature completely changed. All materials got censored and cleaned. I'm forthwith removing all links from my site to it. There are 19 of them, on the following pages:

Unicode Full-Width Characters

Perm url with updates: http://xahlee.org/comp/unicode_full-width_chars.html

Unicode Full-Width Characters

Xah Lee, 2011-05-06

This page lists full-width versions of unicode characters. A full-width char basically means that each character has the same width as a Chinese character, even using variable-width font. They are used mostly in Chinese, Japanese, Korean, texts.

0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ
abcdefghij
klmnopqrst
uvwxyz
,.:;!?
"'`^~ ̄_
&@#%+-*=<>
()[]{}⦅⦆
|¦/\¬
$£¢₩¥

In the above, there are no space between adjacent chars. No effort is made to align them, nor are monospace font specified.

The list is not complete.

Emacs: Defining Keys to Navigate Brackets

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

Emacs: Defining Keys to Navigate Brackets

Xah Lee, 2011-05-06

Here are some convenient keys to move cursor by brackets. Very useful in coding C, Java, Python, HTML, or any other languages.

Commands to Navigate Brackets

(defun forward-open-bracket ()
  "Move cursor to the next occurrence of one of ( { [ <."
  (interactive)
  (forward-char 1)
  (search-forward-regexp "(\\|{\\|\\[\\|<")
  (backward-char 1)
  )

(defun backward-open-bracket ()
  "Move cursor to the previous occurrence of one of ( { [ <."
  (interactive)
  (search-backward-regexp "(\\|{\\|\\[\\|<")
  )

(defun forward-close-bracket ()
  "Move cursor to the next occurrence of one of ) } ] >."
  (interactive)
  (search-forward-regexp ")\\|\\]\\|}\\|>")
  )

(defun backward-close-bracket ()
  "Move cursor to the next occurrence of one of ) } ] >."
  (interactive)
  (backward-char 1)
  (search-backward-regexp ")\\|\\]\\|}\\|>")
  (forward-char 1)
  )

These commands lets you move cursor around any brackets, (){}[] but also <>. You can assign them keys. See: Emacs: How to Define Keyboard Shortcuts.

What Keys to Use?

Good keys are the arrow keys, with a combination of Alt, Shift, or Win and Menu keys by mapping emacs's Hyper and Super to them. For me, i use the Win key with Super. (See: Emacs: How to define Hyper & Super Keys.) Here's my code:

(global-set-key (kbd "<s-left>") 'backward-open-bracket)
(global-set-key (kbd "<s-right>") 'forward-open-bracket)
(global-set-key (kbd "<s-up>") 'backward-close-bracket)
(global-set-key (kbd "<s-down>") 'forward-close-bracket)

Emacs's Keys To Navigate Nested Code

The above commands is a very good complement to emacs built-in keys to navigate matching brackets in lisp code and matching tags in html code.

Built-in Keys to Navigate Lisp Code

The keys to navigate lisp code are:

  • Ctrl+Alt+
  • Ctrl+Alt+
  • Ctrl+Alt+
  • Ctrl+Alt+

Highlighting Matching Brackets

Emacs will also highlight matching brackets. When your cursor is on a matching pair char, emacs will highlight the matching pair or the code between them. For detail about these, see: How to Edit Lisp Code with Emacs.

Select Code Between Matching Brackets

Also, you can define a command so that when cursor is on a opening bracket, you can press a key to have the whole code enclosed by the matching pair highlighted. See the command “extend-selection” at Suggestions on Emacs's mark-word Command.

Built-in Keys for Navigating Matching HTML Tags

For html, when in “html-mode”, it has “sgml-skip-tag-backward” 【Ctrl+c Ctrl+b】 and “sgml-skip-tag-forward” 【Ctrl+c Ctrl+f】.

For more productivity tips with html, see: Emacs and HTML Tips.

2011-05-05

Emacs Lisp: w32-shell-execute Example and Inline Documentation Bug

Perm url with updates: http://xahlee.org/emacs/w32-shell-execute.html

Emacs Lisp: w32-shell-execute Example and Inline Documentation Bug

Xah Lee, 2011-05-05

In emacs GNU Emacs 23.2.1, built for Windows, there's a documentation bug for the emacs lisp function “w32-shell-execute”. When you call “describe-function” on “w32-shell-execute”, you get this:

w32-shell-execute is a built-in function in `C source code'.

[Missing arglist.  Please make a bug report.]

Not documented.

This is fixed in emacs 23.3, the inline doc for “w32-shell-execute” is the followning:

w32-shell-execute is a built-in function in `C source code'. 

(w32-shell-execute OPERATION DOCUMENT &optional PARAMETERS SHOW-FLAG) 

Get Windows to perform OPERATION on DOCUMENT. 
This is a wrapper around the ShellExecute system function, which 
invokes the application registered to handle OPERATION for DOCUMENT. 

OPERATION is either nil or a string that names a supported operation. 
What operations can be used depends on the particular DOCUMENT and its 
handler application, but typically it is one of the following common 
operations: 

 "open"    - open DOCUMENT, which could be a file, a directory, or an 
               executable program.  If it is an application, that 
               application is launched in the current buffer's default 
               directory.  Otherwise, the application associated with 
               DOCUMENT is launched in the buffer's default directory. 

 "print"   - print DOCUMENT, which must be a file 

 "explore" - start the Windows Explorer on DOCUMENT 

 "edit"    - launch an editor and open DOCUMENT for editing; which 
               editor is launched depends on the association for the 
               specified DOCUMENT 

 "find"    - initiate search starting from DOCUMENT which must specify 
               a directory 

 nil       - invoke the default OPERATION, or "open" if default is 
               not defined or unavailable 

DOCUMENT is typically the name of a document file or a URL, but can 
also be a program executable to run, or a directory to open in the 
Windows Explorer. 

If DOCUMENT is a program executable, the optional third arg PARAMETERS 
can be a string containing command line parameters that will be passed 
to the program; otherwise, PARAMETERS should be nil or unspecified. 

Optional fourth argument SHOW-FLAG can be used to control how the 
application will be displayed when it is invoked.  If SHOW-FLAG is nil 
or unspecified, the application is displayed normally, otherwise it is 
an integer representing a ShowWindow flag: 

  0 - start hidden 
  1 - start normally 
  3 - start maximized 
  6 - start minimized 

(Thanks to Jason Rumney for telling me about this fix, and for his donations and support.)

Examples of Using “w32-shell-execute”

Here's some other useful examples of command that makes a shell call.

(defun open-in-desktop ()
  "Open the current file in desktop.
Works in Microsoft Windows, Mac OS X, Linux."
  (interactive)
  (cond
   ((string-equal system-type "windows-nt")
    (w32-shell-execute "explore" (replace-regexp-in-string "/" "\\" default-directory t t)))
   ((string-equal system-type "darwin") (shell-command "open ."))
   ((string-equal system-type "gnu/linux") (shell-command "xdg-open ."))
   ) )

For another example of using “w32-shell-execute”, see: Emacs Lisp: browse-url Function to View URL in a Web Browser.

Here's a example of similar purpose to “w32-shell-execute” but using “shell-command” for Mac OS X.

(defun open-with-textwrangler ()
  "Open the current file in Mac's TextWrangler."
  (interactive)
      (if (eq major-mode 'dired-mode)
          (shell-command "open .")
        (shell-command
         (concat "open -a /Applications/TextWrangler.app " "\"" (buffer-file-name) "\""))))

2011-05-04

Linden Scripting Language (LSL) Script Count

Perm url with updates: http://xahlee.org/sl/lsl-script_count.html

Linden Scripting Language (LSL) Script Count

Get your Xah Particle Maker today!

Xah Lee, 2011-05-04

Michael Jergens wrote to ask:

This might be worthy of a post onto your website/blog and/or as a reply via email:

Subj: Script counts

this seems to be getting more attentions in sims such as New Jessie. My AV is scanned and I get a posting as to my script count and resource usage. I can understand why they would want to do this; however, it is difficult to sometimes track down ALL of my scripts. For example: New Jessie says I am using 31 scripts and 1.4 mb. Scripts I understand, but the "1.4 mb" is a little more vague to me. Is that even within my control? Is it a result of the script counts (i.e. more scripts active means higher "mb")

Some of the scripts I can track down by right click/'inspect' on various HUD attachments and objects. I tried a similar thing on my AV and found almost all were ZERO scripts. Logically, I can conclude that either my Viewer indentifies scripts in a different way than the sim does or I am not digging deep enough to find stealthy scripts. I did learn one tidbit regarding 'stealth' scripts" clothing! Sometimes there are scripts to resize or to change color. I was told that once you get an article to appear the way you want it, you can thengo in and delete the scripts. However, this usually only amounts to 1 or 2 scripts, but it is a start. My goal is to go into SL combat and to have essential combat gear: a primary weapon, a secondary weapon, a munitions HUD and maybe a melee item (if the primary weapon does not have one). Having better educated SL users can help to trim scripts down without reducing the fun part. I will start by educating myself.

I would welcome any information you may offer!

Hope you are well and wishing you continued success in your web/blog venture (8000 hits daily??? impressive!)

Kind regards,

Mike Jergens
"Humourous Maximus"

Good question Mike.

How to Reduce Your Scripts

In Phoenix Viewer, you can right click on a item on your avatar, then 〖More▸S. Count〗. For example, for my gun it reports “Scripts Counted: 11 [512K]”

Official Viewer from Linden Labs doesn't have that menu.

If you carefully go thru all items you are wearing, including every attachment, i think it should adds up to whatever some sim's script counters is reporting. Though, this is tricky, as some attachment are invisible or hard to find or able to click on.

How Much Memory Does a Script Use?

In the older days (pre-MONO script engine; before 2008-08), each script uses 16KiB of memory (KiB = kibibyte = 1024 bytes). With Mono today, each script uses 64KiB. (i heard that the plan was that each script will have variable memory alloted for each script, depending on need, but apparantly this doesn't seem to have happened. It is not clear to me whether each mono script gets fixed 64KiB or it may grow.)

In your script, you can find the memory usage by the function “llGetFreeMemory”.

How to Write a Script Counter?

Here's the key elements.

  • Use “llSensorRepeat” and “llSetTimerEvent” to get a list of people nearby.
  • Use “llGetObjectDetails” to find the number of scripts and memory usage for each person.

Following is a basic example of using “llGetObjectDetails”.

// 2011-05-04
// http://xahlee.org/

// put the script in a prim. Then, click the prim, it'll report your script usage.

 default
 {
     state_entry()
     {
         llSetText("Touch me to see your script use.", <1,0,0>, 1);
     }
    
     touch_start(integer num_detected)
     {
         key agentId = llDetectedKey(0);
         string agentName = llDetectedName(0);

         list scriptUseInfo = llGetObjectDetails( agentId, [OBJECT_TOTAL_SCRIPT_COUNT,OBJECT_SCRIPT_MEMORY]);

         string mytext = agentName + " is hogging " + llList2String(scriptUseInfo, 0) + " scripts resource & using " + llList2String(scriptUseInfo, 1) + " memory!";

         llSay(0, mytext);
     }
 }

Put the script in a prim. Click the prim, then it'll print for example:

[02:37]  Xah Script Counter v0.2: Xah Toll is hogging 32 scripts resource & using 1753088 memory!

PS: Super thank you to Mike for much donations.

References

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

2011-05-03

Emacs Lisp: browse-url Function to View URL in a Web Browser

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

Emacs Lisp: browse-url Function to View URL in a Web Browser

Xah Lee, 2011-05-03

In emacs, there's a function “browse-url”. It sends a url to a web browser. You can use it like this:

(browse-url "http://xahlee.org/")

The function “browse-url” is defined in 〔browse-url.el〕, which is bundled with emacs. It is used by for example “html-mode”. In that mode, you can press 【Ctrl+c Ctrl+v】 and it'll call “browse-url-of-buffer”, and view the current html file in a browser.

The “browse-url” function is very useful in your own lisp program. You can define a function with a key, so that pressing a button or clicking on url lets you view that url. For examples of how it is used, see: Emacs: Perl PHP Dictionary Wikipedia Google … Reference lookup.

Sending URL to Firefox Browser

Besides, “browse-url” and “browse-url-of-buffer”, there are several others:

  • browse-url-firefox
  • browse-url-default-windows-browser
  • browse-url-default-macosx-browser
  • browse-url-kde

(See 〔browse-url.el〕 for more.) These will use a specific web browser. However, on my Windows machine, by default the “browse-url-firefox” doesn't work because emacs doesn't know its path.

To make it work, you'll need to add Firefox executable path in emacs's “'exec-path” variable, like this:

(add-to-list 'exec-path "c:/Program Files (x86)/Mozilla Firefox/")

For example, i use multiple web browsers. Google Chrome for sites i have a account, especially Google sites. Firefox for all my web dev, usually with Flash and javascript off. Internet Explorer 9 for rest, and sometimes also Safari and Opera.

In emacs, sometimes i want to sent url to a specific browser. Here's a function i defined:

(defun browse-url-of-buffer-with-firefox ()
  "Same as `browse-url-of-buffer' but using Firefox."
  (interactive)
  (let ()
    (require 'browse-url)
    ;; for the function browse-url-firefox to work, you need to have the firefox path in exec-path. e.g.:
    ;; (add-to-list 'exec-path "c:/Program Files (x86)/Mozilla Firefox/")
    (browse-url-firefox (concat "file:///" buffer-file-name))
    ))

Alternative: Launching Browser by Calling Browser's Shell Command

You can also launch a browser by making a shell call. For example:

(defun browse-url-of-buffer-with-firefox ()
  "Same as `browse-url-of-buffer' but using Firefox.
You need Firefox's in the path environment variable within emacs.
e.g.
 (setenv \"PATH\" (concat \"C:/Program Files (x86)/Mozilla Firefox/\" \";\" (getenv \"PATH\") ) )"
  (interactive)
  (let ()
    (shell-command (concat "firefox file:///" buffer-file-name))
    ))

You have to make sure that the path of firefox e.g. 〔C:/Program Files (x86)/Mozilla Firefox/〕 is in emacs's “PATH” variable. Here's a example of how to add it:

; example of setting env var named “path” by appending a new path to existing path
(setenv "PATH" (concat "C:/Program Files (x86)/Mozilla Firefox/" ";" (getenv "PATH") ) )

For more detail about environment variables with emacs and Windows, see: Emacs and Microsoft Windows Tips.

Which Solution is Better?

Of these 2 solutions of launching Firefox, the one with a shell call works best for me. I have problem using the solution provided by 〔browse-url.el〕. Here's the detail.

I have my mouse setup so that when i hover the pointer over a window, that window comes to the front. (See: Windows Auto Raise & Single Click to Open File.) This is a super convenient setup. It saves you many clicks when switching windows. I highly recocommended it.

However, when using the 〔browse-url.el〕 solution, when i view a url, it also for some reason moves the mouse point, so that emacs will switch me to the browser but then some other program behind it will come to the front. Very annoying. I'm not sure why emacs does that. Looking at the code of “browse-url-firefox”, it's some 49 lines, with lots of variables controlling the behavior, such as controlling whether to open in a new window or tab. It seems overkill.

With shell call, the solution is very simple. Emacs simply makes a shell call and the shell launchs the browser.

AutoHotkey key notation & syntax problems

Updated AutoHotkey Key Notations and AutoHotkey Syntax Problems.

AutoHotkey language is the most idiotic among langs i know of. I think it's even worse than perl or unix shell.

2011-05-02

AutoHotkey: Script to Toggle Maximize Window

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

AutoHotkey: Script to Toggle Maximize Window

Xah Lee, 2011-05-02

This page is a simple AutoHotkey script to toggle the current window's size. If you don't know what AutoHotkey is, see AutoHotkey Basics.

; 2011-04-30
; from http://xahlee.org/
; A toggle. maximize current window, or restor size if already maximized.

#NoTrayIcon
WinGetPos, winWidth, winHeight, , , A  ; "A" to get the active window's pos.
if ( winWidth == -8 and winHeight == -8) {
WinRestore, A
} else
{
WinMaximize, A
}

ExitApp

Save the above in a file, name it 〔toggle window maximize restore.ahk〕.

Then, in your main AutoHotkey file, you can assign a key to it, like this:

$ScrollLock::Run "toggle window maximize restore.ahk"

Or, you can use your Microsoft or Logitech software keyboard driver software to assign a key to launch the script.

Linden Scripting Language (LSL) Unicode Support

Perm url with updates: http://xahlee.org/sl/lsl-unicode_support.html

Linden Scripting Language (LSL) Unicode Support

Get your Xah Particle Maker today!

Xah Lee, 2011-05-02

Seems that LSL supports unicode in function names. Here's a example:

string tασ∑♥() { return "var with unicode char in name";}

string aασ∑♥ = "var with unicode char in name";

default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }
    
    touch_start(integer num_detected)
    {
        llSay(0, (string) tασ∑♥() + "; " + (string) aασ∑♥);
    }
}

Note: it seems that function/variable names must start with a english letter. Else it's a compiler error.

See also: Unicode Support in Ruby, Perl, Python, javascript, Java, Emacs Lisp, Mathematica.

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