Posts

Showing posts from March 21, 2010

Joey Dyser, 100 years

Perm url with updates: http://xahlee.org/Periodic_dosage_dir/sanga_pemci/Joey_Dyser_100_years.htmlJoey Dyser, 100 yearsXah Lee, 2010-03-27A beautiful song. The song name is “100 years”, the singer is Joey Dyser. I don't know who she is though. Wikipedia doesn't have a entry of her. The song seems to be around 1975. The other day I felt so young but now you made me 100 years If you turn 'round, look what you've done you'll see my eyes, you'll see my tears My friends all say: don't cry too long there is another love to come They may be right, they may be wrong But still I love you hear my song You disappeared without goodbye knowin' so well, you made me cry but troubles you could never face so you just left an empty place The first kiss made a fool of me it struck me but I couldn't see For you this love was just the same I'm asking now, am I to blame? Joey Dyser, 100 years

emacs: command to insert date or random number

perm url with updates: Emacs Misc Tips.2010-03-27 Another short elisp tip. I needed a fast way to insert random numbers. So i wrote: (defuninsert-random-number () "Insert a 4 digits random number." (interactive) (insert (number-to-string (random 9999)) ) ) If you are new to lisp... notice that elisp does not automatically convert number to string. So, number-to-string is very convenient. There's also string-to-number.Once i defined this function, i can either give it a Keyboard Shortcut, or define a alias. I have already too many shortcuts, so i just define a alias, by “(defalias 'irn 'insert-random-number)”. Then, when i need to have a random number inserted, i just type “Alt+x irn”. Exercise: write a command that insert current date/time. (answer can be found at: How To Update Web Feed With Elisp)

What Determines a Computer Language's Popularity?

Perm url with updates: http://xahlee.org/UnixResource_dir/writ/language_popularity.htmlWhat Determines a Computer Language's Popularity?Xah Lee, 2007-08-18[Note: The following is a online forum post, in which i posit a aspect that a computer language's popularity depends on.]Xah Lee wrote:The Haskell community, would benefit greatly (say, as tripling its popularity or number of users), by forbidding literature associated with its teaching, of using the term Currying.Chris Smith wrote:Even when teaching the meaning of the standard library routines “curry” and “uncurry”?umm... that seems unfortunate. I think things like this, effectively functions like a damnation on the language's reach.It is not surpring, since Haskell is made by academics, who have little contact and understanding of the real, daily, average programers in the computer industry. (and Haskell wasn't intented that it might be a language for general industrial use)Similar problem cripples the Schemers. Pe…

A Exhibition Of Tech Geekers Incompetence: Emacs whitespace-mode

Image
Perm url with updates: http://xahlee.org/UnixResource_dir/writ/emacs_whitespace-mode_problems.htmlA Exhibition Of Tech Geekers Incompetence: Emacs whitespace-modeXah Lee, 2009-08-13Just wanted to express some frustration with whitespace-mode.Emacs 23, just released, has this whitespace-mode feature. It renders spaces, tabs, newlines characters with a visible glyph. This feature, is in Microsoft Word since about 1992.This feature is important in practical ways. For example, when you work with Delimiter-separated values file format (CSV, TSV, ...) that's a common format for importing/exporting address books or spreadsheets. It's also important in whitespace-significant langs such as Python. Or, in text processing when placement of space and tabs matters in input or output.All i wanted, is to make Space and Tab and Newline chars visible.However, the emacs whitespace-mode does much more than that. It is designed for tech geeking control freaks to tune every aspect of white space …

Function Application is not Currying

Perm url with updates: http://xahlee.org/UnixResource_dir/writ/apply_func_examples.htmlFunction Application is not CurryingXah Lee, 2009-01-28In Jon Harrop's book Ocaml for Scientist at http://www.ffconsultancy.com/products/ocaml_for_scientists/chapter1.htmlIt says:CurryingA curried function is a function which returns a function as its result.LOL. That is incorrect.Here are some examples of a function that returns a function as result, but is not currying.Mathematica example: f[n_]:=Function[n^#]; f[7][2] (* returns 49 *) Emacs lisp example: (defmacrof (n) (list 'lambda (list 'x) (list 'expt n 'x) ) ) (funcall (f 7) 2) Perl example:subf {$n=$_[0]; sub { $n ** $_[0]} }; print &{ f(7) } (2); Javascript example:functionf(n) {returnfunction (x) {return Math.pow(x,n);}; } alert (f(7) (2)); In the above, a function returns a function, and the result function is applied to a value. They demonstrate 2 things:The ability of the lang to have a function that returns a fu…

Emacs: What's Region, Active Region, transient-mark-mode?

Perm url with updates: http://xahlee.org/emacs/emacs_region.htmlEmacs: What's Region, Active Region, transient-mark-mode?Xah Lee, 2008-06, ..., 2010-03-25This page is a tutorial on emacs's concept of region, active region, transient-mark-mode, for those who want to write emacs lisp commands.RegionThe last Mark position to the current cursor position is called a Region.Once a user sets a mark in a buffer (“Ctrl+Enter” or “Alt+x set-mark-command”), a region exists. So, almost always, there exists a region in a buffer.By convention, commands ending in the word “-region” acts on the region, regardless whether the region is active. For example: kill-region, comment-region, fill-region, indent-region. This system worked well before emacs introduced the region highlighting feature around late 1990s.You can get the position of region beginning by the function “region-beginning”, similarly “region-end”.transient-mark-mode, Active Region, Highlighting of Regiontransient-mark-modeEmacs h…

Womanizer (video)

Image
Perm url with updates: http://xahlee.org/funny/womanizer.htmlWomanizer (video) “Britney Spears - Womanizer - Parody” by “VenetianPrincess”. I LOL.Who's this VenetianPrincess? Apparantly, a real chick that rose to fame on youtube. Dubbed “Female Weird Al Yankovic”, and is the most subscribed female on YouTube. She made several parodies that are highly popular. Her real name seems to be Jodie-Amy Rivera. Her website is vprincess.com. See also White and Nerdy.and the original version by Britney Spears.Womanizer - Britney Spears White and Nerdy

Emacs Lisp: Count Words, Count Chars, Count Region

Perm url with updates: http://xahlee.org/emacs/elisp_count-region.htmlEmacs Lisp: Count Words, Count Chars, Count RegionXah Lee, 2010-03-23A little elisp tip. Here's a short elisp i have been using since about 2006. It reports the number of words and chars in a text selection. (defuncount-region (beginning end) "Print number of words and chars in region." (interactive "r") (message "Counting ...") (save-excursion (let (wCnt charCnt) (setq wCnt 0) (setq charCnt (- end beginning)) (goto-char beginning) (while (and (< (point) end) (re-search-forward "\\w+\\W*" end t)) (setq wCnt (1+ wCnt))) (message "Words: %d. Chars: %d." wCnt charCnt) ))) This code is largely from Introduction to Programming in Emacs Lisp by Robert J Chassell, when i was reading it sometimes in 2005. That tutorial is for people who never programed. It was quite frustrating to read, becaus…

CSS “position” Tutorial

Image
Perm url with updates: http://xahlee.org/js/css_positioning.htmlCSS Position: static, relative, fixed, absolute, ExamplesXah Recommends:

Amazon Kindle. Read books under the sun. Review Xah Lee, 2010-03-20, 2010-10-27This page explains the “position” element of CSS, with examples.The “position” element has 4 possible values: static, fixed, relative, absolute. The css positioning is difficult to understand, but they are also quite powerful.position:staticThe “position:static” is the default for all tags. If you don't specify a “position”, its default value is “static” (if it hasn't inherited anything from ancestor tags). That means, the positioning of the tag's rendered box goes with normal flow.position:relativeUse “position:relative” to adjust a tag's position relative to the parent block.Use “top”, “bottom”, “left”, “right” to specify the offset, and “width, height” to control the size.See: CSS “position:relative” Example.position:fixedUse “position:fixed” to specify th…