Showing posts from May 22, 2011

Twitter's url shortner

Twitter's url shortner t.coOld news. Twitter is now using “” to shorten url posted thru However, url will be displayed as the original following ellipsis.For example, go to this page:, click on the tweet button. Then, twitter generates a link like this 〔〕, but when viewed in, it is displayed as 〔…〕. And when you copy the text, the shortened url is copied.According to twitter, quote:Twitter's link service ( is used on all links included in Direct Message notification emails …If you just use to post a normal tweet, it's not shorterned. For example, if you post 〔〕 or〔〕 it'll come out as is.See:t.co Shortening is BAD

ErgoEmacs v1.9.3.1 lisp packages released

ErgoEmacs v1.9.3.1 lisp packages released. See announcement here: Source be installed on any OS with a working emacs 23.2.ErgoEmacs v1.9.3 Release Notes HighlightDownload at:

Linux/Unix X11 Mouse Button Numbering Scheme

Perm url with updates: X11 Mouse Button Numbering SchemeXah Lee, 2011-05-28For some odd reason, if you have a 5-button mouse, the 5th button (aka “forward button”) in emacs has syntax <mouse-5> in Windows and Mac, but on Ubuntu 10.04 Linux running Gnome 2.x, it's <mouse-9>. In unix X11, here seems to be how they assign the mouse buttons.1 = left button 2 = middle button (pressing the scroll wheel)3 = right button4 = roll scroll wheel up5 = roll scroll wheel down6 = push/tilt scroll wheel left (some mouse only)7 = push/tilt scroll wheel right (some mouse only)8 = 4th button (aka backward button)9 = 5th button (aka forward button)In emacs, you can find out the mouse button or wheel syntax by calling “describe-key” then press the button.In X11, you can call “xev” to see any keyboard/mouse event and their naming.Mouse Numbering on Windows and MacThe numbering also depends on OS and mouse driver.For example, o…

programing: yada yada operator

I haven't really programed perl for like 5 years (except running my old programs weekly). Today, while browsing the perldoc perlop, i noticed this:Yada Yada OperatorThe yada yada operator (noted ... ) is a placeholder for code. Perl parses it without error, but when you try to execute a yada yada, it throws an exception with the text Unimplemented :LOL. That must be new, or i totally forgot about it.

Emacs Lisp Scripting Quirk: Relative Paths

Perm url with updates: Lisp Scripting Quirk: Relative PathsXah Lee, 2011-05-28Here's a useful function, and also a little detail on a quirk of elisp scripting about relative paths.Suppose you have 2 scripts, B and C. You are coding file B. You know the relative path from B to C. (Suppose C in is in a sub-directory of B.) You do not know the absolute path at run time because these scripts may be installed anywhere. Your B can call C by the fact that you know the relative path. In Perl, Python, and perhaps most other scripting langs, we can rely on this to work.However, in emacs lisp, when a file A calls your B, emacs doesn't update its notion of current dir, so B's call to C by relative path will be broken, because emacs will assume it's relative to A.The following function solves this problem. (defunfullpath-relative-to-current-file (file-relative-path) "Returns the full path of FILE-RELATIVE-PATH, relative t…

emacs lisp util; benefits of compiling your elisp code

Spend 6 hours in past 2 days to clean up my custom emacs init files. Turns out there is just a lot to clean. I have 6.5k lines. (not counting elisp libs.) Most of my custom elisp code has to do with html for my website.A compiled elisp code will load ~6 times faster, AND run ~6 times faster. But also, i realized it's good to compile your lisp code because it'll tell you errors such as using free variable (that is, you are using a var that you forgot to put inside “let”). I found ~5 instances of leaked vars. Surprising, it'll also tell you that you are using “equal” with only one argument. Normal loading of code won't tell you that.Now there are sizable number of utils you might grab. Get at: Xah Lee's Emacs Customization Files.See also: Organize Your “dot emacs” Init File in 5 Minutes.

Emacs on Ubuntu Linux

Perm url with updates: Ubuntu Linux recently, together with emacs 23.2.1 on it. Of course, then i grabbed ErgoEmacs. I was half expecting whatnot bugs or at least some frustration, but actually, it's quite smooth! I've been using ErgoEmacs for about 4 years now and it'd be quite painful to fall back to plain old GNU Emacs.Still, i did find a few problems.Emacs Dired Recursive Load ErrorOnce you loaded ErgoEmacs, everytime you try to open a file or directory, you get a “Recursive load” error:expand-file-name: Recursive load: "/usr/share/emacs/23.2/lisp/net/tramp.elc", "/usr/share/emacs/23.2/lisp/shell.elc", "/usr/share/emacs/23.2/lisp/net/tramp.elc", "/usr/share/emacs/23.2/lisp/shell.elc", "/usr/share/emacs/23.2/lisp/net/tramp.elc", "/usr/share/emacs/23.2/lisp/shell.elc", "/usr/share/emacs/23.2/lisp/net/tramp.elc", "/usr/share/emacs/23.2/lis…

Computing: mega vs mibi, kilo vs kibi

Perm url with updates: mega vs mibi, kilo vs kibiXah Lee, 2011-05-26You know what kilo, mega, means right? like, a kilogram is one thousand grams. It's quite simple, going by the powers of 10, adding 3 zeros for each higher level. kilo = 10^3 = 1000^1 = 1,000 mega = 10^6 = 1000^2 = 1,000,000 giga = 10^9 = 1000^3 = 1,000,000,000 But in computing, there's a abomination. kilo doesn't mean 1000, it means 1024, and mega isn't a million, but 1048576. WTF?In your blogs, please do not say kilobyte to mean 1024 bytes. Use the following terms: kibi = 2^10 = 1024^1 = 1,024 mibi = 2^20 = 1024^2 = 1,048,576 gibi = 2^30 = 1024^3 = 1,073,741,824 Let the terms: kilo, mega, giga, be what they always meant universally, that is, powers of 10. See: Binary prefix and Timeline of binary prefixes. Interesting quotes:One source of consumer confusion is the difference in the way many operating systems displa…

Determine OS Type (Windows/Mac/Linux) in Emacs

Determine OS Type (Windows/Mac/Linux) in EmacsMany of us work with several operating systems. When you write your emacs customization (the 〔.emacs〕 file), sometimes you need to know what OS you are on. Here's how to do it.;; make the mouse 5th button (forward button) do close buffer. (cond ((string-equal system-type "windows-nt") ; any flavor of Windows (global-set-key (kbd "<mouse-5>") 'close-current-buffer) ) ((string-equal system-type "gnu/linux") (global-set-key (kbd "<mouse-9>") 'close-current-buffer) ) ((string-equal system-type "darwin") ; Mac (global-set-key (kbd "<mouse-5>") 'close-current-buffer) ) ) For some odd reason, if you have a 5-button mouse, the 5th button (aka “forward button”) in emacs has syntax <mouse-5>, but on Ubuntu 10.04 Linux, it's <mouse-9>. On Windows and Mac, scrolling mouse wheel down is <wheel-down>, but in linux it's &l…

Functional Programing: stop using recursion, cons. Use map & vectors

Functional Programing: stop using recursion, cons. Use map & vectorsThis is important but i think most lispers and functional programers still don't know it.See: Guy Steele on Parallel Programing.Lists (as cons, car, cdr) in the lisp world has always been some kinda cult. Like, if you are showing some code example and you happened to use lisp vector datatype and not cons (lists) and it doesn't really matter in your case, but some lisper will always rise up to bug you, either as innocent curious question or attacking you for not “understanding” lisp. (just as other idiocies happen in other lang that lispers see but other langs don't see)It's interesting to me that all other high level langs: Mathematica, perl, python, php, javascript, all don't have linked list as lisp's list. It's also curious that somehow lispers never realises this. I've been having problems with lisp's cons ever since i'm learning Scheme Lisp in 1998 (but mostly the reaso…

Windows: is Your USB Drive Fast Enough for ReadyBoost?

Perm url with updates: is Your USB Drive Fast Enough for ReadyBoost?Xah Lee, 2011-05-20, 2011-05-22Windows Vista and 7 has a Readyboost feature. Basically, if you have any flash drive on your system (such as usb drive), the OS will use it as a cache system to speed up any file access operations. Quote from Wikipedia:ReadyBoost is a disk cache component of Microsoft Windows, first introduced with Microsoft's Windows Vista in 2006 and bundled with Windows 7 in 2009. It works by using flash memory, a USB flash drive, SD card, CompactFlash or any kind of portable flash mass storage system as a cache.So, i though i just plug in my usb drive and my computer will be faster. That's not the case. There are few requirements. Quote:For a device to be compatible and useful it must conform to these requirements:The removable media's capacity must be at least 256 MB (250 MB after formatting). Windows Vista x86 & x86-…

What's Windows CLSID? Second Life UUID?

Perm url with updates:'s Windows CLSID? Second Life UUID?Xah Lee, 2011-05-22you know how on Windows you see this strings like this {838f9f38-f241-11de-a663-002421597a5c}? For example, on my PC, i have these files generated by Windows Vista: NTUSER.DAT{838f9f38-f241-11de-a663-002421597a5c}.TM.blf NTUSER.DAT{838f9f38-f241-11de-a663-002421597a5c}.TMContainer00000000000000000001.regtrans-ms NTUSER.DAT{ac2d24f1-7d46-11e0-b16f-002421597a5c}.TM.blf NTUSER.DAT{ac2d24f1-7d46-11e0-b16f-002421597a5c}.TMContainer00000000000000000001.regtrans-ms NTUSER.DAT{bc030bf2-8ab8-11de-a498-002421597a5c}.TM.blf NTUSER.DAT{bc030bf2-8ab8-11de-a498-002421597a5c}.TMContainer00000000000000000001.regtrans-ms NTUSER.DAT{c328fef0-6a85-11db-9fbd-cf3689cba3de}.TxR.0.regtrans-ms NTUSER.DAT{c328fef0-6a85-11db-9fbd-cf3689cba3de}.TxR.blf NTUSER.DAT{c328fef1-6a85-11db-9fbd-cf3689cba3de}.TM.blf NTUSER.DAT{c328fef1-6a85-11db-9fbd-cf3689cba3de}.TMContainer0000000000…