Archives July 2008

Unicode Input in Emacs

One question that had been bugging me for a while is, how does one
input a character in Emacs, given its Unicode hex code?

Answer: use the ucs input method, then use
uHHHH to input, where HHHH is the character’s
hex code.

Unfortunately, it doesn’t look as though there’s a way to input a
character by its decimal code.

Also, C- toggles an input method on and off, rather than
cycling through a list. So if you’re writing HTML (and therefore want
the default input method) with French text (for which you want the
latin-1-postfix input method), but need to insert box-drawing
characters (for which you need ucs), you’ll wind up using
M-x set-input-method a lot.

Connections

It occurred to me that humorists and magicians have something in
common: they both rely heavily on misdirection.

Disclaimer: I’m neither a magician nor a comedian (as you can tell from my
previous post)
so I may not know what I’m talking about.

Magicians use misdirection in their tricks, to draw the audience’s eye
away from the card being palmed, or to trick the mind into thinking
that the coin was dropped or the ball passed to the other hand.

A lot of humor also relies on misdirection, in that the setup to a
joke establishes a certain mental image of a situation, and the
punchline destroys that image and puts another in its place.

Where it gets interesting, I think, is when the audience knows how
things work. Comedians tell jokes to each other, and I’m pretty sure
magicians do tricks for one another. This brings another level of
difficulty to both crafts: how do you misdirect someone who knows
they’re being misdirected?

I’m not sure what magicians do to impress each other — perhaps
something along the lines of “Wow, while we were watching his hands to
see him palm the card, he was actually distracting us from noticing
that his assistant changed from a white outfit to a black one”. But
I’ve noticed a fair amount of meta-humor in The Simpsons and Futurama.
For instance:

[Fry is being Zoidberg’s Cyrano]
Fry: Start with a compliment. Tell her she looks thin.
Dr. Zoidberg: [calling to Edna] You seem malnourished. Are you suffering from internal parasites?
Edna: [pleased] Why, yes. Thanks for noticing.

Here, Zoidberg’s line leads us to believe that in his bumbling manner,
he has misunderstood what Fry was telling him. But Edna’s line reveals
that no, what he said is actually a compliment on this planet.

Of course, in order to make misdirection work, both the magician and
the comedian have to know how their audience thinks, in order to make
them think a certain way. I know that humor doesn’t travel well at
all: what’s hilarious in one country is merely absurd or
incomprehensible in another. I wonder if magic tricks suffer from the
same thing, or whether they tend to rely more on (presumably)
universal psychological elements, like the fact that an object moving
from A to B passes through all the points in between.

Also, are there types of brain damage that prevent one from being able
to appreciate a magic trick?

Metamathematical Teakettle

Problem: you want to make coffee. In front of you is a coffee maker with freshly-ground coffee, and filled with water. It is turned off. What do you do?

Answer: define a mapping from coffee to tea, thus reducing the problem to a previous joke.

Catholic Idiocy Roundup
Behind PZ Myers, a priest inhales helium through a bong.
(Photo:
Catholic News Agency)

The blagosphere has been abuzz over the story of a
eucharist held “hostage”.

Read More

Friday Playlist, Blasphemous Edition

A celebration of first amendment freedom.

  1. Depeche Mode, Blasphemous Rumours
  2. XTC, Dear God
  3. John Lennon, Imagine
  4. Roger Waters, What God Wants, Part II
  5. Filter, Dose
  6. New Model Army, Christian Militia
  7. Spinal Tap, Christmas with the Devil
  8. X-Fusion, Jesus Hates You
  9. Assemblage 23, Let Me Be Your Armor
  10. H.F. ThiƩfaine, La nostalgie de dieu
  11. Renaud, Pourquoi d’abord
  12. Sarcloret, Dieu est une magouille de l’opposition

Read More

A Better Way to Toggle

(Warning: what follows may be obvious or trivial to many.)

One of the cool things about AJAX is switching parts on and off: you
can make an element visible simply by

myElement.style.display = "block";

or hide it with

myElement.style.display = "none";

But the problem with this is that it requires the JavaScript script to
know a lot about the document. The example above doesn’t look too bad,
but what if you have something like a pulldown menu that appears when
you click a button?

Let’s say that originally, the button is gray and has a “+” icon next
to the text. When you click on it, the menu becomes visible, but the
button also changes to red, and the “+” icon changes to “-“, to show
that the menu is active.

Now you have all sorts of CSS resources that you have to keep track
of. It would be nice to put them in the .css file, with the
rest of the style stuff.

Read More

The Good Shepherd

One thing that’s always bugged me with the
good shepherd
metaphor is that while a good (or at least competent) shepherd will
protect sheep from predators, disease, weather, etc., he does so
mainly because he doesn’t want wolves to eat his sheep before he gets
a chance to turn them in to lamb chops himself.

Of course, that’s probably not something he wants to tell the sheep.

Pink Floyd
lyrics
below the fold.

Read More

Different Stylesheets for Browsers With and Without JavaScript

As hacks go, this one is pretty obvious, but I thought I’d throw it
out there anyway.

Let’s say there are three stylesheets you want to use on your web
page: one for all browsers (style.css), one for browsers with
JavaScript enabled (style-js.css), one for browsers without
JavaScript (style-nojs.css). This can be useful for things
like “display the fancy drop-down menu only if the browser supports
JavaScript; display the plain-HTML menu only if the browser doesn’t
support JavaScript”.

The common stylesheet is pretty standard:

<link rel="stylesheet" type="text/css" href="style.css"/>

The one for browsers that don’t support JavaScript is also pretty
easy: that’s what <noscript> is for:

<noscript>
  <link rel="stylesheet" type="text/css" href="style-nojs.css"/>
</noscript>

Finally, what’s the best way to have different behavior in browsers
that support JavaScript? Why, run a script, of course:


  document.write('n');