Showing posts with label language. Show all posts
Showing posts with label language. Show all posts

Tuesday, April 30, 2013

Essential jQUERY

Recently, I picked up the bare essentials in jQuery from the book, jQUERY Visual Quickstart Guide by Steven Holzner, Peachpit Press, 2009.

However, a word of warning: the book is somewhat badly edited, and there is no corrected edition (still as of this writing).

From the core jQuery source code, this page also is useful. Here are my brief notes:

JQuery refers to a certain syntax $(thing) for any thing as 'jQuery-wrapping'.

The keyword $ is an alias for jquery. Both are used in the following ways:

  • $(function)  –  Append a function to the list to be run when the document is ready: a shortcut for $(document).ready(function).

  • $(CSS-selector-string)  –  Select some nodes in the document.

  • $(HTML-string)  –  Create HTML for insertion.

  • $(DOM-node)  –  Like saying simply DOM-node, but change the value of this and set context (an attribute used by jQuery). Examples are:
    •   $(document)  –  The document.
    •   $(this)  –  this.

  • $.method  –  (This one has a dot and no parentheses.) Run a utility method.

The jQuery methods selected for explanation in the book are:

  • Methods on jQuery-wrapped collections of HTML elements:
    • addClass,  after,  alt,  animate,  append,  attr,  before,  bind,  clone,  css,  each,  (event binder methods),  fadeIn,  fadeOut,  fadeTo,  height,  hide,  hover,  html,  is,  (jQuery-UI methods),  length,  load,  one,  serializeArray,  show,  size,  slice,  slideDown,  slideToggle,  slideUp,  text,  toggle,  toggleClass,  unbind,  val,  width,  wrap

  • Event binder methods:
    • Keyboard   –   keydown,  keypress,  keyup

    • Mouse   –   mousedown,  mouseenter,  mouseleave,  mousemove,  mouseout,  mouseover,  mouseup

    • The rest   –   beforeunload,  blur,  change,  click,  dblclick,  error,  focus,  load,  resize,  scroll,  select,  submit,  unload

  • jQuery-UI methods:
    • accordian,  datepicker,  dialog,  progressbar,  slider,  tabs

  • Methods on jQuery-wrapped HTML strings:
    • insertAfter,  insertBefore

  • Utility methods:
    • ajax,  browser,  each,  get,  grep,  inArray,  isArray,  isFunction,  makeArray,  map,  post,  support,  trim,  unique

Copyright (c) 2013 Mark D. Blackwell.

Tuesday, January 10, 2012

Lisp & Ruby metaprogramming

I just reread Paul Graham's article, Beating the Averages, on Lisp being the most powerful computer programming language because of Lisp macros (which, BTW, are not like assembly language macros). It led me to the obvious perception that because Ruby lacks Lisp macros, metaprogramming in it is weaker than in Lisp.

He explains the essence of Lisp macros: '[I]n general, for application software, you want to be using the most powerful ...language you can get, and using anything else is a mistake. ...Lisp code, after it's read by the parser, is made of data structures that you can traverse. If you understand how compilers work, [in Lisp you] write programs in the parse trees that get generated within the compiler when other languages are parsed. But these parse trees are fully accessible to your programs. You can write programs that manipulate them. In Lisp, these programs are called macros. [P]ower ...refers to features you could only get in [a] less powerful language by writing an interpreter for [a] more powerful language in it.'

So, for someone who wants to know where to go next after Ruby, and thinks that, in a Ruby code base, having a high proportion of metaprogramming code, like some say Rails 3 has these days, results in awkwardness, the next step is Lisp. Lisp apparently is perhaps a better metaprogramming language.

Copyright (c) 2012 Mark D. Blackwell.

Thursday, September 22, 2011

Learn You a Haskell for Great Good!

Following is a note I wrote to the author of a wonderful book:

Hi, Miran Lipovača,

Thanks for your wonderful, _Learn You a Haskell for Great Good!_. Just now, I am resuming reading it, after completing a project (in another language).

For many people, it is important to be refreshed by beauty, as of mathematics in your book!

Copyright (c) 2011 Mark D. Blackwell.

Sunday, February 20, 2011

Installing Prolog on Puppy Linux, howto

From the book, Seven Languages in Seven Weeks, I notice a trend toward specialty languages being glued together by Ruby, or any scripting language. We can use the right tool for the right purpose instead of one "sledgehammer" only! Some examples are Prolog for rules (or logic) and Io (w/s "io language") for parsing.

Today I installed the package SWI Prolog, useful for developing in Prolog, the logic computer programming language, on a computer running Puppy Linux (Quirky Retro 1.2).

Here's how I did it:

o From Debian.org, download two 'lenny' packages:

swi-prolog_5swi-prolog_5.6.58-2_i386.deb
libgmp3c2_4.2.2+dfsg-3_i386.deb

o In the ROX-Filer file manager, click their icons to install them.

o Create a file, ~/.plrc containing the single line:

:- set_prolog_flag(editor,'geany').

o Within ~/my-documents, create and change to the directory, 'prolog'.

o Associate the file extension, '.pl' with SWI Prolog. Create a file like 'any.pl'. Right-click it in ROX-Filer and edit the run command to be:

urxvt -e swipl -s "$@"

Now you can click on a file with extension '.pl' and it will be loaded by the interpreter.

To make changes, type, 'edit.'. The interpreter will re-read the file when you close the editor. Type 'halt.' to end the session.

One example to get you started: if you type 'alice.' into a file, and in the interpreter type 'alice.', it will respond with, 'true'.

For further information, the SWI Prolog user manual is available off-line at:

file:///usr/lib/swi-prolog/doc/Manual/index.html

Their FAQ is:

http://www.swi-prolog.org/FAQ/

Some tutorials appropriate to beginners:

http://www.bitwisemag.com/copy/programming/prolog/intro/firststeps.html
http://www.learnprolognow.org/
http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/contents.html
http://www.doc.gold.ac.uk/~mas02gw/prolog_tutorial/prologpages/

Copyright (c) 2011 Mark D. Blackwell.

Tuesday, July 20, 2010

Swahili

(January 20, 2010.) This morning, after leaving M's car to be worked on, I conversed with an INTP long-time slight acquaintance, who typically wears Moslem robes, while returning home by bus. He seated himself beside me, seemingly unawares.

After surprised greetings, observing him reading Latin and Arabic alphabetical writing, I asked politely, "What are you reading?"

He informed me, "Swahili", (the lingua franca of central East Africa).

I prompted him, "For long, I have wanted to learn Swahili. I just know one word: Uhuru."

Pleased, as I predicted, he said, "That means, 'Freedom!'"

I explained, "I have read the grammar is very interesting." He proceeded to teach, and from him, I learned:

Ni - I.
Ni na kula. - I am eating.
Ni na soma. - I am reading.
Ni da kula. - I will eat.
Ni li kula. - I ate.
Ni si na kula. - I am not eating.
Ni na kula chakula. - I am eating food.
Ni na kula chakula moto. - I am eating hot food.
Ni na kula chakula moto haraka. - I quickly am eating hot food.

Thus far, it follows Greenbergian word-order correlations, in that adverbs are placed on the same side of verbs, as adjectives are of nouns. (Here, both 'hot' and 'quickly' come afterward.)

More about Swahili and Word order.

I find it interesting, BTW, that we can communicate more easily with a fellow INTP, of limited English from Africa who is Moslem, than with a person from here, of some other Myers-Briggs type!

Copyright (c) 2010 Mark D. Blackwell.