Posts

Showing posts from January 11, 2009

html microformat

perm url: HTML MicroformatHTML MicroformatXah Lee, 2009-01-17Learned about the term Microformat↗. Basically, you just use your html's “class” attribute and tag structure to represent structured data, so that you can parse and manipulate them easily. It is more or less a home-cooked method of using html/xhtml to achieve the purposes of specialized XML. (The concept of microformat is similar to many software's ad hoc line-based text file formats. (e.g. unix config files)) I've been using microformat for my English Vocabulary project. For example, see the source code for this page: Vocabulary Study: Hyphenated Wonders. Effectively, i created a microformat for vocabulary citation. Namely, each entry is a word entry, with container for usage example, cited source, definition. Here's a example: <divclass="ent"> <pclass="wd">‹a word›</p> <divclass="ex"> <divclass="bdy">‹some example usage involving the …

Suggestions on Emacs's Inline Doc

perm url: http://xahlee.org/emacs/modernization_inline_doc.htmlSuggestions on Emacs's Inline DocXah Lee, 2009-01-17In emacs, you can press “Ctrl+x h ‹function name›” to see any elisp function's inline documentation, and if the cursor is on a function, it defaults to lookup that function. This integrated facility is extremely convenient. Some other scripting languages such as Perl, Python, Ruby, Javascript etc do provide such lookup too, often thru their command-line interface, but is nowhere near as convenient as in the emacs environment.However, some improvement can be made. Here are some suggestions:(1) make elisp-index-search's default prompt to be the symbol under cursor. This seems useful and consistent with other emacs lookup commands.(2) make describe-function display a link to the elisp manual's node on that function.(3) make describe-function display related functions as in “See also: ...” For (1), few people have suggested implementations here: http://groups…

A Ruby Illustration of Lisp Problems

perm url: http://xahlee.org/UnixResource_dir/writ/lisp_problems_by_ruby.htmlA Ruby Illustration of Lisp ProblemsXah Lee, 2009-01-17Here's a interesting toy problem posted by Drew Krause to comp.lang.lisp:OK, I want to create a nested list in Lisp (always of only integers) from a text file, such that each line in the text file would be represented as a sublist in the 'imported' list.Example of input 3 10 2 4 1 11 18 example of output:((3 10 2) (4 1) (11 18))Here's a emacs lisp version: (defunread-lines (file) "Return a list of lines in FILE." (with-temp-buffer (insert-file-contents file) (split-string (buffer-substring-no-properties 1 (point-max)) "\n" t) ) ) (mapcar (lambda (x) (mapcar (lambda (y) (string-to-number y) ) (split-string x " ") ) ) (read-lines "xxblob.txt") ) The above coding style is a typical maintainable elisp.In a show-off context, it can be reduced to by about 50%, bu…

Neal Stephenson at Google Talk

perm url: http://xahlee.org/Periodic_dosage_dir/Neal_Stephenson.htmlNeal Stephenson at Google TalkXah Lee, 2009-01-16Was chatting on freenode's irc #rcirc channel out of boredome. I asked out in the open for suggestions on some sci-fi movies to watch. Sabetts (Shawn Betts, author of Ratpoison↗ and Stumpwm↗) mentioned that Neal Stephenson↗ has a google talk.Neal Stephenson talk at Google on 2008-09-12. I watched the entire 58 min of it. In the beginning 5 or 10 min, you see this boring guy, humorless, self-absorbed, absent-minded nerd, going on monotonously. The entire talk is a emotionless monotone, somewhat demeaning and self-abasing too, entirely devoid of any high points, energy, constantly letting out a subdued sigh. Can't find a single gleam of a smile on his face thru the entire talk.I've of course heard of him, first time in 1998 thru a colleague (Jon Frisby↗), who named his coding projects after his books. Neal is this sci-fi novel writer, famous for titles like Sno…

2 php tutorials

Two PHP tutorials: How To Send HTML Mail With PHP, How To Send Mail with Attachment in PHP (computing; computer language) How To Send Mail with Attachment in PHPXah Lee, 2009-01-14This page shows you how to send email with attached file, using PHP.Sending email in php is extremely easy. All you have to do is call the “mail” function. But how do you send out email with attachment?There are php packages that allows you to do that, however, they will often need installation of the package, and if you are using a web hosting service provider, sometimes that is not possible. Luckily, it is not difficult to write a simple code that does it. All you have to do is to encode your mail payload as multipart MIME↗.Here's a simple working example of sending html mail with attached file:<?php $fromAddr = 'staff@example.com'; // the address to show in From field. $recipientAddr = 'jane@example.org'; $subjectStr = 'Thank you'; $mailBodyText = <<<END89283<!…

using USB Flash Drive on mac

Perm url http://xahlee.org/Periodic_dosage_dir/t1/zip_mother-son.html.USB Flash DriveI just bought a 18GB usb flash drive. Its speed seems to be 20 times slower than my 8 years old external 20GB firewire drive (which is 10 times as bulky). USB 2 should be as fast as Firewire. So, my initial guess is that flash drive's format is not native ... Wikipedia comes to the rescue:USB flash drive↗Flash file system↗Some points of personal interest:Because flash drive are solid state storage devices, it doesn't have disk fragmentation issues as do magneto disk based mechanical drives. (It does has its own issues)Flash drive does have a life span, in number of write operation and in storage permanence too.Flash drives uses file systems just like normal drives. In fact, it's just a storage device with usb interface.Most flash drives are pre-formatted with FAT32. If you use it for Mac exclusively, you might want to reformat it to a Mac native format (e.g. HFS+, use Disk Utilities). I ha…

Emacs Should Adopt HTML To Replace Texinfo

Perm url: http://xahlee.org/emacs/modernization_html_vs_info.htmlEmacs Should Adopt HTML To Replace TexinfoXah Lee, 2009-01-12Dan Davison wrote:What does this syntax mean? “See Info node `(viper)Top'.”Is there some way of using it to immediately access the info node referred to?Lennart Borgman wrote:M-: (info "(viper) Top")Note: the “M-:” above means “Alt+:”. See: Emacs's M-‹key› Notation vs Alt+‹key› Notation. it'd be much better if emacs adopted html as its standard doc format.It would than just be: “http://gnu.org/doc/emacs/viper/top.html”in this format, every programer understand what it is. In “(info "(viper)Top")” or “(viper)Top”, maybe 0.001% of programers knew what it is. If we count among all emacs users who used emacs for at least 1 year, the percentage is perhaps 10%.Personally, i use emacs daily, staying in emacs most of the time when using computer, since 1998, and have been using text terminal based emacs exclusively from 1998 to 2005. I…