The Yetimology of Vaseline

To fill the void, here’s a silly little crosspost.


vaseline

As is well known, most Dutch-American women in the early American republic were called Eline, including all of Martin van Buren’s female relatives. After the Revolutions of 1848, many Germans emigrated to the United States, and they all quickly fell in love with these attractive Dutch-American women. In turn enamored with the sculpted musculature of these Prussian emigrees, many an Eline answered in the affirmative following a marriage proposal. Unfortunately, as the romance wore off so did the ability to surpass the linguistic distance between Dutch and German, and throughout New York City calls of “Was, Eline?” could be frequently heard.

When Robert Chesebrough first came to America, he was welcomed by a German-immigrant greeter. Unfortunately for Robert, the unknown German-American had become rather used to saying “Was, Eline?” instead of simply “was” or “what”. So when Robert asked our immigrant to describe the spirit of American optimism in one word, he answered “vaseline?” The German immigrant hadn’t understood the question, but Robert thought he’d obtained the perfect brand name for a future product. And the rest, as they say, is history.

Comments

Stop Hijacking Annoyances

Here’s another rescue from My Opera. The script was compiled by the user pehage on February 3, 2012, after a quick pointer by me. It is Opera UserJS, so it won’t work in any other browser. Don’t forget to enable User JavaScript on HTTPS if you so desire. In Opera 12 it no longer pops up a warning all the time.

// ==UserScript==
// @name Stop Hijacking Annoyances
// @include *
// ==/UserScript==

var annoyances = ["focus", "focusin", "focusout", /*"click",*/ "dblclick", "mousedown", "mouseup", "mousemove", "mouseover", "mouseout", "mouseenter", "mouseleave", "select", "submit", "keydown", "keypress", "keyup"];

for (var i=0; i<annoyances.length; i++) {
	//opera.postError(annoyances[i]);
	window.opera.addEventListener("BeforeEventListener." + annoyances[i], function (e) {
		e.preventDefault();
		//opera.postError(e);
	}, false);
}

And here is a simple testcase I created.

<!DOCTYPE html>
<html>
<head>
<title>keypress hijacker</title>
<script>
document.addEventListener('keypress', function(e){alert('document.addEventlistener on keypress ' + String.fromCharCode(e.which))}, false);
window.onkeydown = function(e){alert('window.onkeydown ' + String.fromCharCode(e.which))}
</script>
</head>
<body>
This page hijacks keypress events in order to display an alert message.
</body>
</html>

Comments

Soft Cheese

A play for two actors.

Act 1

A rustic village in Normandy. Candide, a recent émigré from the big city, has become quite fond of the rural lifestyle.

Candide enters the local cheese shop. Gaute, the store owner, looks up at the sound of the bell.

Gaute
Good morning, Candide! It’s so nice to welcome you again to my humble realm.
Candide
I inspected my garden this morning and some wonderful champignons matured nicely. Last week I ate mushrooms with Vieuxchatêl as per your suggestion, but I’m looking for a different type of local soft cheese today. Do you have any recommendations?
Gaute
Certainly, a new cheesemaker opened up shop in this area recently! They call it La Vache Qui Pleure. Would you like to sample some?
Candide
No thanks Gaute, that’s alright. Your judgment in these matters has been absolutely impeccable in these past few months, and whatever you recommend is always a culinary delight.
Gaute
Very well! That’ll be €3 please.
Candide
Here you are. Thank you so much!

Candide exits the store.

Act 2

The next morning, an angry Candide rushes into the store. The bell jingles violently.

Candide
Why didn’t you tell me this was processed cheese?! Why did you lie to me?
Gaute
Lied? But monsieur Candide, this is locally produced soft cheese, just like you asked for.
Candide
I don’t care if it’s technically soft and produced locally. You knew very well I wanted a real local cheese and you gave me this mass-produced junk.
Gaute
But the product I sold you already had artificial penicillium camemberti flavor added to it!
Candide
Artificial fungus flavor? Are you insane? You lied to me.
Gaute
You will quit making these libelous remarks! And besides, the cheese was never truly without fungus. You could have sprinkled some fungus on it yourself and it might’ve taken to the cheese.
Candide
You’re insane. This is no proper cheese.
Gaute
Sir, I will take you to court for libel and slander.
Candide
Do your worst. The truth is plain for all to see.

Act 3

A courtroom. Candide is down on his knees in front of a judge in court dress with his eyes toward the ground.

Judge
Are you Candide, the man who libeled against Gaute the cheese store owner?
Candide
I am Candide, but I did not libel against Gaute. He promised me a local soft cheese and he gave me mass-produced processed cheese.
Judge
But it was a local product. Your libelous lies make a mockery of this court.

Candide finally looks up at the judge. His face changes into a shocked expression of understanding.

Candide
You!
Gaute
In a small rural village such as this, I have to take on the role of judge, jury, and sometimes executioner.
Candide
This is a travesty of justice!
Gaute
The accused shall not yell in court.
Candide
You did not sell me proper cheese!
Gaute
The defendant is found guilty of libel. Gaute did sell cheese.
Candide
But proper cheese does not contain emulsifiers! It has the right fungus growing on the outside! It does not stay good for weeks while unrefrigerated!
Gaute
The defendant is also found guilty of trolling.
Candide
You cannot be serious. Until this very week you never sold me cheese with such artificial properties and additives. You sold me real cheese.
Gaute
The court finds itself obliged to forgive you for your ignorance of what is technically allowed to qualify as cheese. But by insisting on your own definition of this so-called proper cheese, you have proved yourself guilty of conceitedness. Bailiff, this man shall hang for the crime of being full of himself. Prepare the gallows.

Fade to black.

Comments (1)

Torn Apart

Here’s a silly “children’s story” I wrote around mid December. It’s a bit rough around the edges, probably a bit odd, and too graphical. So it goes.


It was a perfectly nice day when Esprit stumbled and broke his front right leg. When the little boy did not find the horse at his trough a few hours later he thought nothing of it; sometimes Esprit would run off and play and forget about dinner. To make up for lost time, the boy promised himself he’d visit the horse the next morning as early as he could.

The next day he noticed with mild consternation that the horse did not appear to be in his stable. The boy went out to search the property, trying to remember what were Esprit’s favorite spots. He remembered the open hill, where Esprit would often lie in the sun.

Time stood still when the little boy discovered what had happened. Whether running back to his house, alerting his parents, and calling the veterinarian helicopter emergency service took minutes or hours was not a question he’d be able to answer, but the sky was already turning red as a thunderous cavalcade of chopped air signaled the arrival of the helicopter. Esprit was harnessed in with great care so the broken leg wouldn’t shift, was given a sedative, and was swiftly lifted up. The little boy waved at the horse, certain the veterinarian would be able to mend and properly set Esprit’s leg.

Unbeknown to the helicopter pilot, distracted by the glint of the setting sun in her eye, the rescue pulley system malfunctioned and started lowering the horse just as the helicopter was starting to pick up speed. The little boy stared in wide-eyed horror as Esprit started bouncing left and right from tree to tree. Gapes and gashes appeared and started to bleed, and despite the sedative the poor horse woke up when its broken leg got stuck between the top branches of a particularly sturdy evergreen tree and was torn off like a cocktail pricker. The horse started to howl the most agonizing scream the little boy would ever hear, but that was not the end of Esprit’s misery. A particularly sharp branch a few trees over impaled the horse, which consequently produced a guttural, almost stuttering, and above all angry sound. The pilot finally noticed that something was awry when the helicopter refused to go forward anymore, but it was already too late. The surprisingly elastic tree finally gave up under the barrage of the helicopter’s brute force and snapped like a twig, propelling the helicopter on its now downward trajectory into the trees. Like in the Hollywood movies the little boy loved so much, the rotored machine made a squealing noise before exploding in a fiery ball of death.

The little boy was finally able to break out of his trance, and he collapsed into a sobbing mass. For months after he was bedridden, and each night he claimed Esprit came limping to his window while floating through the air, on three legs and a bloody stump, with mad, bloodshot eyes. The boy’s parents were worried sick, and their little boy’s German-accented psychiatrist was having the time of his life writing article after article about the little boy’s disturbed unconscious. When they found the broken window and the little boy’s dead body with the missing right arm, the autopsy report bluntly stated he had inflicted all these injuries on himself—that he had torn off his own arm. The hoofmarks all over his body were left out of the official report. The estate was up for sale the next day already, and no one’s lived there in sixty years. The locals are still weary of the place where the little boy died, but a real-estate developer drove by the other day and is planning to turn it into a hotel. The organization he represented put up a sign already: “The Hillcrest Hotel. Opening in May 2016, just in time for the holidays!”

Comments (1)

Data URI Bookmarklet

This is a repost of something I wrote on My Opera forums on 8 January 2013. The My Opera forums will be shutting down on 1 March 2014.


The easiest method [to base64 encode an image] might be to use the newly supported (since v12) FileReader object, which has a readAsDataURL method. I wrote a quick proof of concept using XHR because I’m not really sure how else to get data to it (aside from a file input which is no good here). Alternatively you could load the image in a canvas and call toDataURL, but then you’ll lose stuff like metadata and I’m not even sure if the compression and such will remain the same.

var xhr = new XMLHttpRequest(),
	reader = new FileReader();
xhr.open('GET', location.href, true);
xhr.responseType = 'blob';
xhr.addEventListener('load', function () {
	if (xhr.status === 200) {
		reader.addEventListener('load', function (e) {
			location.href = e.target.result;
		});
		var responseWithMimeType = new Blob(new Array(xhr.response), {
			'type': xhr.getResponseHeader('Content-Type')
		});
		reader.readAsDataURL(responseWithMimeType);
	}
});
xhr.send();

It does seem a bit roundabout, so I’d love to hear it if anyone has more efficient suggestions.

I just realized you may not be aware of how to make a bookmarklet. To save myself the effort of removing comments and such I used http://chris.zarate.org/bookmarkleter to obtain the following result:

javascript:(function(){var%20xhr=new%20XMLHttpRequest(),reader=new%20FileReader();xhr.open('GET',location.href,true);xhr.responseType='blob';xhr.addEventListener('load',function(){if(xhr.status===200){reader.addEventListener('load',function(e){location.href=e.target.result;});var%20responseWithMimeType=new%20Blob(new%20Array(xhr.response),{'type':xhr.getResponseHeader('Content-Type')});reader.readAsDataURL(responseWithMimeType);}});xhr.send();})();

Create a new bookmark, paste that into the URL and give it a nickname of your choice.

Easier still, just drag this or right-click, bookmark link: To Data URI. There might be some security restrictions on MyOpera against javascript links, so I’m not sure if it’ll work.

But for local files a simple page would do just fine. All you need is input type=”file” and a tiny bit of scripting similar to the above. Something like this should do:

<!DOCTYPE html>
<html>
<head>
<title>File to Data URL</title>
</head>
<body>

<form>
<input type="file">
</form>

<script>
var file = document.querySelector('input[type=file]'), reader = new FileReader();

file.addEventListener('change', function(e) {
	reader.readAsDataURL(e.target.files[0]);
});

reader.addEventListener('load', function(e) {
	location.href = e.target.result;
});
</script>

</body>
</html>

Comments

Adding a User Font Size Preference to Simple Machines

Users should be able to choose their default font size easily through their browser, and their choice should be respected. But because all browsers default to 16px and most people never change the default, many sites—including Wikipedia—set their font-size to about 80% of that value to end up at a font size of 12px or 13px. Thus users might be prevented from lowering their font size on a site that actually respects their preferences if they so desire.

Because I don’t believe that either joining the 80% crowd or specifying a size in pixels is generally the right answer, I decided to add a user preference that overrides the font-size on the HTML element. For this to work as intended, your stylesheet needs to be entirely in percentages, em, rem, or use equivalent keywords like small and large.

First, in Admin > Configuration > Core Features, enable Advanced Profile Fields. Then, you can add custom profile fields in Admin > Configuration > Features and Options > Profile Fields. I added one named “Font size” with an input mask of /^[0-9]{1,3}(\.[0-9]{1,2})?(em|pt|px|%)$/.

Assuming your theme is based on the default, start editing index.template.php. Then, under the linked stylesheets you can put the override:

	// Custom user font-size
	if ($context['user']['is_logged']) {
		global $user_profile;
		loadMemberData($context['user']['id']);
		
		if (!empty($user_profile[$context['user']['id']]['options']['cust_fontsi'])) {
			echo '
	<style>', 'html {font-size: ', $user_profile[$context['user']['id']]['options']['cust_fontsi'], '}', '</style>';
		}
	}

To find out exactly what kind of useful values you can obtain from e.g. $context and $user_profile, you can use var_dump($user_profile).

Comments

Get Back Control of Ctrl+F1-12 in Xfce

It’s quite simple. Go to ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml and comment out the relevant properties.

Comments

On Upgrading (X)Ubuntu

  1. sudo do-release-upgrade doesn’t crash like the GUI and properly shows you errors. There’s probably a log you could hunt down somewhere, but why make life harder on yourself?
  2. Removing a bunch of old linux-image-* and linux-headers-* files can literally free up gigabytes, in case you were wondering what happened to all your space.

Comments

Pandoc Markdown Over Straight LaTeX

I familiarized myself with LaTeX because I like HTML better than word processors. In fact, I disprefer word processors. LibreOffice Writer can do a fairly decent job of WYSIWYM (What You See Is What You Mean), but in many ways I like it less than HTML. So why don’t I just use HTML, you ask? Quite simply, HTML isn’t necessarily the best option for print.

Prince does a great job generating printable PDFs, but even though writing straight HTML is easy enough and adds many benefits, I mostly only prefer it over your run of the mill text editing software. Besides, I wanted to profit from BibTeX reference management, which tends to come along with LaTeX.

Clearly then, LaTeX has some nice features. Unfortunately, it shares many of HTML’s flaws and adds some others: \emph{} is at best marginally easier to type than <em></em>, but I find it somewhat harder to read. Besides which, converting LaTeX to other formats like HTML can be a pain.

On the good side, LaTeX and HTML also share many features. Both depend on plain-text files, which is great because you can open them on any system, and because you can use versioning software. Binary blobs and compressed zip files are also more prone to data loss in case of damage. The great thing about versioning software isn’t necessarily that you can go back to a former version, but the knowledge that you can go back. Normally I’m always busy commenting out text or putting it at the bottom, but when it’s versioned I feel much more free about just deleting it. Maybe I’ll put some of it back in later, but it lets the machine take the work off of my hands. I know, Writer, Word, et cetera can do this too, but did I mention I prefer plain text anyway?

Where LaTeX really shines is its reference management, math support without having to use incomprehensible gibberish like MathML or some odd equation editor, and its typographical prowess. On top of the shared features with HTML, those features are why I looked into LaTeX in the first place. So how can I get those features without being bothered by the downsides of HTML and LaTeX? As it turns out, the answer is Pandoc’s variant of Markdown.

In practice, I rarely need more than what Pandoc’s Markdown can give me. It’s HTML-focused, which I like because I know HTML, but you can insert math (La)TeX-style between $ characters. It also comes with its own citation reference system, which it changes to BibLaTeX citations upon conversion to LaTeX. As these things go, I wasn’t the first with this idea.

Of course it won’t do to repeat myself on the command line constantly, so I wrote a little conversion helper script:

#!/bin/bash
#generate-pdf.sh

BASENAME=your-text-file-without-extension
# I compiled an updated version of Pandoc locally.
PANDOC_LOCAL=~/.cabal/bin/pandoc

if [ -x $PANDOC_LOCAL ];
then
   PANDOC=$PANDOC_LOCAL
else
   PANDOC=pandoc
fi

# Output to HTML5.
$PANDOC \
$BASENAME.md \
--to=html5 \
--mathml \
--self-contained \
--smart \
--csl modern-language-association-with-url.csl \
--bibliography $BASENAME-bibliography.bib \
-o $BASENAME.html

# Output to $BASENAME-body.tex
# $BASENAME.tex has this file as input
$PANDOC \
$BASENAME.md \
--smart \
--biblatex \
--bibliography $BASENAME-bibliography.bib \
-o $BASENAME-body.tex

# Pandoc likes to output p.~ or pp.~ in its \autocite, but I just want the numbers.
sed -i 's/\\autocite\[p.~/\\autocite\[/g' $BASENAME-body.tex
sed -i 's/\\autocite\[pp.~/\\autocite\[/g' $BASENAME-body.tex
# It would probably suffice to just do this but I don't want any nasty surprises:
#sed -i 's/p.~//g' $BASENAME-body.tex
#sed -i 's/pp.~//g' $BASENAME-body.tex

# If ever bored, consider adding something to change \autocite[1-2] into \autocite[1--2]

# Generate the PDF.
lualatex $BASENAME
biber $BASENAME
lualatex $BASENAME
lualatex $BASENAME

# Remove these files after the work is done.
rm  \
$BASENAME.aux \
$BASENAME.bbl \
$BASENAME.blg \
$BASENAME.bcf \
$BASENAME.run.xml \
$BASENAME.toc \
#$BASENAME-body.tex

Something that may not be immediately obvious from the script is that I’ve also got a $BASENAME.tex file. This contains all of my relevant settings, but instead of the main content it contains \input{basename-body.tex}. There are some prerequisites for working with Pandoc-generated LaTeX, for instance:

%for pandoc table output (needs ctable for 1.9; longtable for 1.10)
\usepackage{longtable}

I haven’t yet made up my mind on what to do about splitting up chapters in different files, but it hasn’t bothered me yet.

There you have it. That’s my way of keeping thing simple while still profiting from LaTeX typesetting.

Comments

Textarea Backup Localstorage v1.21

I figured I’d drop a note that I updated my Textarea Backup UserJS last month. What follows is the description from ExtendOpera.

Textarea Backup Localstorage

Retains what you type into textareas and contentEditable elements.

This script is only compatible with Opera 10.50 and up. If you need to use it with an older version use Textarea Backup but be advised that it comes with some disadvantages.

  1. Can automatically place previously typed text in textareas.
  2. Can add an unobtrusive menu in the top right corner of textareas

Actions menu screenshot (note the transparent object in the top right corner of the textarea):

Development can be followed on GitHub. Don’t be shy, open an issue or send me a pull request if you think you have something to contribute! ;)

Changelog

1.21 July 25, 2013. Sorry, I was a bit hasty about that last one. I passed my testcase, but only noticed that many contentEditables work differently in practice on this very site.

  • Fixed a bug that occurred when BODY was contentEditable, as is typical in iframes.
  • Properly compare initial value of contentEditable element to backed up value so you’ll only get prompted to overwrite when relevant.
  • Full changelog.

1.20 July 25, 2013. I wasn’t going to make yet another release in three days, but these new features could be implemented much faster than I initially predicted.

  • Trustworthy old persistent preferences support added. I also uploaded a sample settings file.
  • Fixed the keep_after_submission bug, so setting it to false is safe again.
  • Removed the form requirement.
  • Support contentEditable. This is a pretty big one, seeing how it was the most obvious missing feature.

1.11 July 24, 2013. Added configuration switches for the new feature.

  • For Opera 11.6x and Opera 12.x it now defaults to off because of potential performance concerns.

1.10 July 23, 2013. Added support for dynamically added textareas.

  • This new feature will only work in Opera 11.6x and up.

Comments

Older Entries »