2012-03-10

Emacs Tip: Set Line Number to Start at 0

If you want line number to start at 0, put this in your emacs init file:

(setq linum-format (lambda (line) (propertize (number-to-string (1- line)) 'face 'linum)))

For detail about linum-mode feature, see: New Features in Emacs 23.

Setting line number to start at 0 is useful because some editors do that. See: bug#4274

Emacs Package Repository: MELPA

For Emacs Package System, there is another package repository melpa.milkbox.net. Am not sure what's its distinctive features from other repo such as Marmalade. You might try it. Let me know.

MELPA is written by Donald Ephraim Curtis (home page milkbox.net)

(melpa is suggested by Ozan Sener from Jon Snader's blog.)

2012-03-09

blogger UI change causes traffic surge?

xahlee blogger traffic 2012-03-09
xahlee blogger traffic 2012-03-09

I stopped blogging in Jan 28th, and started in Feb 29th, and changed my blogger interface from a statc template to blogger's new dynamic template on March 5th.

For reasons unknown to me, my blogger traffic is about 8 times more starting on March 5th.

Is it due to the dynamic UI?

  • Dynamic Views: seven new ways to share your blog with the world By A Googler. @ Source buzz.blogger.com

web design: gray text idiocies continued

web design idiocies continued

arstechnica screenshot 2012-03-09
arstechnica screenshot, 2012-03-09. Can you read those orange texts?

Things get worse:

solarized text
Do you find the text easy to read?

read more at http://xahlee.org/js/web_design_gray_on_white.html

Programing: Are int, float, long, double, Side-Effects of Computer Engineering?

Xah Lee wrote: Programing: Why Idiomatic Programing Are Bad. Quote:

… One easy way to measure it is whether a programer can read and understand a program without having to delve into its idiosyncrasies. …

Chris Angelico wrote:

Neither the behavior of ints nor the behavior of IEEE floating point is a “quirk” or an “idiosyncracy”. …

They are computer engineering by-products. Are quirks and idiosyncracies. Check out a advanced lang such as Mathematica. There, one can learn how the mathematical concept of integer or real number are implemented in a computer language, without lots by-products of comp engineering as in vast majority of langs (all those that chalks up to some IEEEEEEE. (which, sadly, includes C, C++, perl, python, lisp, and almost all. (Common/Scheme lisp idiots speak of the jargon “number tower” instead IEEEE.) (part of the reason almost all langs stick to some IEEEEEEEE stuff is because it's kinda standard, and everyone understand it, in the sense that unix RFC (aka really fucking common) is wide-spread because its free yet technically worst. (in a sense, when everybody's stupid, there arise a cost to not be stupid.)))).

A friend asked:

Can you enlighten us as to Mathematica's way of handling numbers, either by a post or a link to suitable documentation? …

read more at http://xahlee.org/comp/int_long_float_double_pests.html

emacs vs vi power drill

emacs vi power drill cartoon
“vi vs emacs”. By Laurent Grégoire

Emergency vi (vi tutorial).

See also:

2012-03-08

What's “closure” in Programing Language?

Perm URL with updates: http://xahlee.org/UnixResource_dir/writ/closure.html

Closure means a few things.

  1. In non-programing contexts, it means something is “closed”, or, a sense of completeness. For example: “I'm returning to my hometown for a sense of closure.”.
  2. In math, algebra, it means a property of a algebraic structure, namely: a function with input from elements of the set, whose result is always also a element in the set. (i.e. the set is closed under this operation) For example, it's common to hear: “the addition operation is closed over integers.”. It means, adding 2 integers results in a integer. Division, for example, is not closed under integers. That is, diving 2 integers may result in something that is not a integer. e.g. fraction.
  3. In programing, it means a mechanism/feature in a language such that a function/subroutine can maintain a state. (in a clean way. e.g. without using global var)
  4. A function/subroutine that maintains states using the above feature.

and, of course, the Clojure, spelled with a “j”. A functional programing language of the lisp family.

For a example in python, see: Python: Function with State (closure).

Web Design 2012: Minimal Windows Width of Popular Sites

Perm URL with updates: http://xahlee.org/js/web_design_minimum_width.html

Quite annoyed that Google in past month assume your window size must be quite wide.

Meaning: the page is designed to assume a minimal display width as optimal. For example, if your window is not that wide, a horizontal scrollbar shows up.

Here's some minimal sizes for each site.

  • Gmail = 994 (mininum); 1290 (no horizontal scroll bar)
  • g+ = 994 (mininum). 1080 for nav bar to float.
  • Twitter = 900 (mininum); (990 to show all items in nav bar)
  • Google Reader = 952
  • Facebook = 1014
  • apple.com = 1014
  • google.com = 1014
  • microsoft.com = 1000
  • Yahoo! = 1014
  • amazon = 1033
  • DISQUS = 1180

Here's sites that used a flow approach.

  • Wikipedia = flow
  • hootsuite = flow

A Guide on Emacs Package System

Emacs package system lets you auto-update and manage emacs packages. It lets you easily see packages available, update to latest version, install/remove packages. So you don't have to manually track what's installed, each package's home page, whether there's new version, etc.

It is bundled with emacs 24 (currently in beta as of 2012-03-05). You can wait for it, Or, you can just install it now and use it. (it wouldn't be a issue when you switch to emacs 24)

emacs packages elpa screenshot
Emacs “list-packages” screenshot

read more at A Guide on Emacs Package System

2012-03-07

Xah Emacs/Elisp Tutorial Update 2012-03-07

New version of my emacs tutorial ready.

If you've bought it before, please just email to xah@xahlee.org with subject “emacs tutorial upgrade”.

If you haven't bought it, you can get it for just $10. See: Buy Xah Emacs Tutorial. As far as i know it's more complete and detailed tutorial than any emacs book, printed or not, especially the elisp section.

Also, you can subscribe my emacs blog from g+, facebook, twitter, or Google Reader. See: Xah Lee Feeds.

Thank you for support! and thanks to those of you who have made comments or helped spread the word on social networks. Also, much thanks to Jon Snader (jcs) (irreal.org) who made many private corrections and suggestions.

CSS Text Alignment and Justification

New: CSS tutorial: CSS Text Alignment and Justification

logical song

Fan video featuring “Supertramp - The Logical Song”

lyrics at http://xahlee.org/music/logical_song.html

2012-03-06

Billy Idol - Sweet Sixteen

“Billy Idol - Sweet Sixteen” amazon

Note here, it's sweet 16, not sweet 18, 21. Nor sweet 30, 40.

SIXTEEN. This is when, girls have just became sexual for a couple years. As to a peach that become ripe.

Also note, sweet 16 refers to females, not males. Males, is never sweet, at 16, 26, 36, or 46. Males, are sweet when there's money and power.

for lyrics, see: http://xahlee.org/music/sweet_sixteen.html.

blogger layout update: do you like it?

so, i updated the blogger appearance, using now the fashionable web2/javascript/ajax based dynamic style.

mouse over the top line to see several interactive layouts.

mouse over the black line on right edge to see the archive, subscribe button, etc.

do you like the new look?

In Emacs 24: Any Elisp Script Using copy-directory is now Broken

in emacs 24, there's this major backward-incompatable change

** `copy-directory' now copies the source directory as a subdirectory
of the target directory, if the latter is an existing directory.  The
new optional arg COPY-CONTENTS, if non-nil, makes the function copy
the contents directly into a pre-existing target directory.

this means, all existing elisp scripts will break. (it broke mine)

basically, it's trying to follow the behavior of unix “cp” command. There are 2 problems:

  • ① this is a fundamental change on a language function. It will break any emacs lisp script that uses “copy-directory”.
  • ② the behavior of unix “cp” is actually worse. Emacs's original behavior is more logical and predictable. (See: Idiocy Of Unix Copy Command.)

here's a workaround:

(if (>= emacs-major-version 24)
           (if (file-exists-p toDir)
               (copy-directory fromDir (concat toDir "/../"))
             (copy-directory fromDir toDir) )
         (copy-directory fromDir toDir) )

Lulzsec Got Bursted, Leader Betrayed Team

Perm URL with updates: http://xahlee.org/Periodic_dosage_dir/lulzsec_bursted_leader_betrayal.html

Lulz Security

So, the lulzsec got bursted. The entire gang of ~6.

It turns out, the leader got bursted by FBI, and then since secretly worked for FBI for several months to betray the whole, so he can reduce his jail time.

  • EXCLUSIVE: Infamous international hacking group LulzSec brought down by own leader By Written Jana Winterpublished. @ Source www.foxnews.com

See also: Sabu (hacktivist), Topiary (hacktivist), LulzSec.

Chinese language articles

Chinese language related articles now has a index, at: Index to Chinese Language Articles.

Also, be sure to follow/subscribe Wordy English @ http://wordy-english.blogspot.com/.

If you use twitter, or g+, you can follow there too, see: http://xahlee.org/subscribe.html

Emacs 24: Spell-Checking on Windows is 25 Times Faster!

Just discovered something incredible. For emacs on Windows, calling flyspell-buffer usually takes 5 seconds for a small file (e.g. 8k sized).

But in emacs 24, it is now less than a second!

Was there a change in emacs 24 that effected this or am i smoking something?

Here's a exact timing, on a 80k HTML file:

  • emacs 23.2.1 on Windows (with Cygwin aspell): 80 seconds
  • emacs 24.0.93 on Windows (with Cygwin aspell): 3 seconds

the release notes (aka emacs NEWS) didn't mention anything about spell, but has the following:

** The default value of redisplay-dont-pause is now t
This makes Emacs feel more responsive to editing commands that arrive
at high rate, e.g. if you lean on some key, because stopping redisplay
in the middle (when this variable is nil) forces more expensive
updates later on, and Emacs appears to be unable to keep up.

however, setting “redisplay-dont-pause” to t, didn't help in emacs 23.

2012-03-05

Parallel Programing Problem: asciify-string

here's a interesting parallel programing problem.

the task is to change this function so it's parallelable.

(defun asciify-string (inputStr)
  "Make Unicode string into equivalent ASCII ones."
  (setq inputStr (replace-regexp-in-string \\|à\\|â\\|ä" "a" inputStr))
  (setq inputStr (replace-regexp-in-string \\|è\\|ê\\|ë" "e" inputStr))
  (setq inputStr (replace-regexp-in-string \\|ì\\|î\\|ï" "i" inputStr))
  (setq inputStr (replace-regexp-in-string \\|ò\\|ô\\|ö" "o" inputStr))
  (setq inputStr (replace-regexp-in-string \\|ù\\|û\\|ü" "u" inputStr))
  inputStr
  )

for detail, see: Parallel Programing Problem: asciify-string.

The Best Redo Mode for Emacs

There are a few packages for redo. Of the ones i've used are:

  • 〔redo.el〕 by Kyle E. Jones, 1997.
  • 〔redo+.el〕original by Kyle, updated by S Irie, 2008.
  • 〔undo-tree.el〕 Toby Cubitt 2009-.

The redo.el works ok, but occasionally it corrupts your undo… meaning that you know there's more undo/redo but wasn't able to get to it. This happens perhaps once a month.

The redo+.el is supposed to update/modernize the code. Unfortunately, i didn't have luck with it. These Kyle based redo modes are ~200 lines of elisp, each.

read more at http://xahlee.org/emacs/emacs_best_redo_mode.html

Firefox: How to Unhide/Disable the Auto-Disappearance of Forward Button

Firefox 10 decided to auto hide the Forward button when there's no forward.

Firefox 10 Forward button autohide screenshot 1 Firefox 10 Forward button autohide screenshot 2
Firefox 10 Forward button autohide screenshots

Very annoying. Because, as you navigate among the pages, the movement of these icons is distracting.

there doesn't seem to be a built-in way to disable this auto-hide. But, one work around is to set the icons to be small. Right click on a empty area in the tool bar, then choose 〖Customize…〗. Then check mark 〖Use Small Icons〗.

Reference: Source Firefox 10 release notes.

2012-03-04

Camille Paglia on Lady Gaga

Perm URL with updates: http://xahlee.org/Periodic_dosage_dir/t2/camille_paglia_on_lady_gaga.html

OMFG, every time i hear Camille Paglia talk, i get excited. Her intellectualism, is like a high-voltage electric charge. It made me feel life is worth living.

listen to her commentary about Lady Gaga.

what is SEXY? Camille Paglia is.

Camille Paglia on Lady Gaga.

The Brazilian star she mentioned is Daniela Mercury.

Magic Polyhedrons

My favorite type of physical puzzles are the Rubik-type puzzles called Magic Polyhedrons. These puzzles screams: “group theory” and “combinatorics”!

cube 2x2x2 pocket cube cube 5x5x5-professors cube
pyramorphix-scrambled
Pyraminx-3
kawai mp9000 dodecahedron

for lots more, see Magic Polyhedrons.

Web Design: Say No to Gray Text on White Background

Perm URL with updates: http://xahlee.org/js/web_design_gray_on_white.html

i dunno wtf is going on with web design crowd, but more and more idiots have websites that's hard to read. Such as using gray text on white background.

example:

web design gray text on white 2
web design: gray text on white background.
web design gray text on white 2
Black on Gray!

Programing: LISP is Not Functional!

Perm URL with updates: http://xahlee.org/comp/lisp_non-functional.html

Dear lispers, brace yourself, stinging damnation is coming forthwith!

the more i learn about Common Lisp, the more i think it's one fuckedup soup. (setf, rotatef, are recent examples)

also, the more i code in lisp (elisp), the more i find it non-functional.

lots, lots, of mutations built-in in the lang in a way that forces you to be non-functional. Quick 1 minute typing:

• destructive sort.

• setq setq setq.

• tons of global vars, not just for emacs environment such as buffer, mode states, etc, which are arguably necessary. But, for things like “match-string”.

• lisp's list, of cons, is one fucking DAMNATION. Along with it comes rampant use of pop, push. Any non-trivial coding in lisp is fucking like perl now, except that dealing with list and nested list in perl is actually much more easier than in lisp.

there's a good solution to lisp's non-functional ways.

BAN lispers from using list or cons. Everything should be vector/array instead.

everytime a cons is involved, lispers should get a electric shock.

that will immediately fix majority of lisp's non-functional programing in practice.

though, i'll have to say, the more i read about Clojure, the better it seems. It is very functional, the savior of the lisp name.