Sitemap and License. Everything on this site falls under the license unless otherwise noted.
and-let*
An emacs-lisp implementation of SRFI-2, srfi-2.el. and-let* is a
combination of and and let, which (optionally) binds the result
of each form in the let block. It stops on the first false result,
and executes the body only if all the forms are true.
(and-let* ((val (member 'foo '(a b c foo d e)))
((listp val))
(val (car val)))
val)
If foo was not found in the list, the form would return false
rather than raising an error.
by Lang.
My version of html-script.el. This code is originally from http://www.dur.ac.uk/p.j.heslin/Software/Emacs/, and is a simplified alternative to the various multi-modes.
Using the region definitions (each a list of starting regexp,
ending regexp, and mode symbols) the keystroke (by default F12)
will narrow to the region and invoke the first bound function.
F12 a second time will widen the buffer and return to HTML mode.
I hacked up the code a bit to exclude the text matched by the
starting and ending expressions. js2-mode flags any invalid
syntax, and the script tags are certainly that. This seems like a
workable solution for mixed javascript, at least until js2-mode
can play nicely with multi-modes.
Fluid bindings follow the flow of control rather than the lexical order of a program. See wikipedia on Dynamic Scoping.
The code: fluid.js.
Posted by Ben on .
The HTML5 specification allows custom data attributes to be added to any DOM element. This jQuery plugin provides methods to retrieve and manipulate custom attributes.
Read More: The jquery.dataset Plugin
Download: jquery.dataset.js
This is an incomplete implementation of SQL in JavaScript objects. It's in the spirit of LINQ, but adds an additional layer of abstraction; clauses are interpreted with late-binding. It's possible to use the same set of where clauses in multiple contexts.
This is (sadly) the first implementation that occurred to me, it's got warts. Squash.
REQUIRE special form for Gambit-C Posted by Ben on .
The REQUIRE special form includes libraries only once. It is
implemented using Gambit-C's INCLUDE and LOAD forms with
COND-EXPAND to prevent a library from being loaded again (which is
an error) or re-evaluated.
REQUIRE accepts a sequence of requirement specifications that
identify libraries. The specifications are mapped onto the filesystem
to find the corresponding source files or compiled modules. For
example:
(require (srfi 1)
(lib util))
;; Library code here...
See require#.scm for additional documentation. An easy way to
integrate REQUIRE into a project is to include require#.scm from
`.gambcini' or `~/.gambcini'. For more details, see Customization in
the Gambit-C documentation.
Source: require#.scm _require.scm
ContentHandler Posted by Ben on .
This ContentHandler provided generates PrefixMapping and ElementNS events from Element events. This can be used to act on namespace events when the underlying XMLReader is not namespace aware.
A subclass of this ContentHandler can implement the PrefixMapping and ElementNS event handlers and behave as if the underlying reader supports namepsaces. One caveat is that the qualified names of opening and closing tags must match since the reader is not namespace aware.
Source: saxns.py
Posted by Ben on .
kqueue() is a kernel event notification mechanism. This example
uses it to drive a non-blocking "hello world" webserver without
polling. The Python epoll() HOWTO and kqueue() tutorial are
helpful references.
Source: httpd-kqueue.py
libev webserver Posted by Ben on .
libev is an event loop that provides a uniform interface to
operating system specific event mechanisms such as kqueue() and
epoll(). This example uses pyev to drive a non-blocking "hello
world" webserver. Simple tests with httperf show performance is
similar to the kqueue() webserver.
Source: httpd-pyev.py