Killing Google Instant (November 3rd, 2011 edition)

This morning, I woke up to find that Google had made another change which broke my solution for disabling Google Instant badly enough for Firefox to give me a blank page. Since Google seems to delight in trying to force people to log in to disable their misfeatures and most of the solutions are out of date, I thought I’d share what I came up with.

Please note that, in Chrome, I just disable JavaScript on Google sites and use the Incognito Window as a way to fake “Temporarily Allow” for parts of the site with no Basic Mode. (enabling JavaScript in an Incognito Window via the address bar icon will be forgotten along with the rest of your browser history) This solution is for Firefox, where I’m used to having everything Just Work™.

First, get NoScript. You can still turn off the JavaScript whitelisting using the “globally allow” option if it bothers you but this solution uses its surrogates system to patch the Google Search page.

Second, open up either your user.js or about:config. We need to create two new string keys. (Thanks to al_9x for the code I started from. I’ve modified it to also work on encrypted.google.com)

Here are the surrogates you need to add. (My apologies for the form they’re in. WordPress insisted on mangling them if I embedded the code right in the post in a prettier form.)

Posted in Geek Stuff | 1 Comment

Learning French: Qui vs. Que As Relative Pronouns

Since I’ve been learning French recently, I’ve decided to start a series of blog posts to share insights I’ve had which helped me to grasp things more quickly.

Let’s start with “qui” and “que” in their roles as relative pronouns since, unless you’re the right kind of geek (which I’m not), it can be difficult to juggle technical grammatical terms and make sense of another language at the same time.

Subject and Object

As a quick refresher, in a sentence, the subject verbs the object. For example, in the phrase “I like it,” I am the subject because I’m doing the liking, “like” is the verb, and “it” is the object because “liking” is being done to it.

A relative pronoun is a pronoun which replaces either the subject or the object so you don’t have to say it twice using two sentences.

For example, I like the guy who pays me is easier to say than I like the guy. The guy pays me. and more clearly conveys the meaning.

Who and Whom

Before grasping French relative pronouns, it helps to get a good understanding of “who” and “whom” first.

Modern, everyday English doesn’t have a clear distinction between relative subject and object pronouns for things (you use which/that for both), but the distinction for people is still alive enough that “whom” hasn’t (yet) gone the way of “thee”, “thou”, “thy”, and “thine”1.

Here’s a little rule of thumb I came up with: “Who” verbs nouns but “whom” is verbed by them.

I like the guy who pays me.
My sister invited a friend whom I don’t like.

In the first sentence, “who” replaces the subject of the second clause while, in the second, “whom” replaces the object.

In French, “qui” replaces the subject (who/which/that) and “que” replaces the direct object (whom/which/that)2.

Inversion

The previous example becomes much more clear if you break things down.

For my first example, you can break it into two sentences like this:

I like the guy. The guy pays me.

…but for my second (the one with whom), you have to do this:

My sister invited a friend. I don’t like the friend.

Notice how the word ordering within the second sentences differ. Combined with a strong but basic understanding of the meaning of subject/object and grasping the differences between “who” and “whom”, learning “qui” and “que” becomes a lot easier.

Good luck.


1. It used to be that “ye/you/your/yours” were plural/formal like “vous” and friends while “thee/thou/thy/thine” were singular informal like “tu”. More on that in another post.

2. As you can guess from the term “direct object”, it can be more complicated, but let’s take things one step at a time. For the curious, the most recognizable “indirect object” relative pronoun in English is “to whom“.

Posted in Geek Stuff, Writing | Leave a comment

Quick Firefox Workaround for YouTube’s Over-Sensitive Flash Detection

If you’re anything like me, you’ve got some mix of Firefox, the current version of Adobe Flash, and a bunch of extensions like AdBlock and NoScript which normally don’t cause problems… and then suddenly a YouTube video insists on giving you messages like “You need to upgrade your Adobe Flash Player to watch this video.” and “Upgrade to Flash Player 10 for improved playback performance.”

If you’re thinking “Oh! I’ll use FlashVideoReplacer!”, no. I use that and it just gives me a black square in these circumstances, so here’s a trick that’s never failed me:

  1. Install Greasemonkey
  2. Install the YousableTubeFix userscript.
  3. Install the InlineDisposition addon.

Now, whenever you want to view a video that’s acting up, just click the Download button that YousableTubeFix provides and choose your format of choice. InlineDisposition will then ensure that, for any format the browser can handle, it to opens in the browser rather than downloading. In this case, that’ll mean either Firefox’s built-in WebM support or a plugin like VLC‘s plugin or gecko-mediaplayer or the QuickTime plugin. (If you’ve only got the built-in WebM support, FLV and MP4 files will fall back to offering to download)

YousableTubeFix also provides a bunch of other nice features for customizing your YouTube experience when the Flash player isn’t acting up. (For example, killing auto-play and/or auto-buffer and automatically sizing the video player in ways that YouTube doesn’t offer even if you are logged in)

Enjoy.

Note: YousableTubeFix is available for Chrome but, since InlineDisposition isn’t, you get a download dialog, which makes it a lot less comfortable as a quick workaround.

Posted in Geek Stuff | Leave a comment

Fanon And The Hazards of Source Amnesia

a guest post by weebee

Fanon is a rather odd entity. It’s often looked down on entirely, with those who think themselves the ‘best authors’ sneering at any use of it and claiming that you should never resort to such obviously flawed and factually incorrect items. Of course, it does have a purpose and one that, if it’s not noble, at least makes sense.

Some fanon, such as the name “Kimiko”, established for Soun Tendo’s wife in the Ranma 1/2 universe, is simply there because there is absolutely no canon data on the subject, but it’s handy to be able to refer to her by that shorthand and to always have a name to use if you need it.

Other fanon, like the explanation that a Sailor Senshi’s transformation naturally includes a disguise field, helps a person who needs explanations for normally unexplained phenomena, or helps bolster a story if it’s already stretching your suspension of disbelief and doesn’t want you thinking about the why. For example, if Usagi executes a perfectly coordinated wall run and Shingo doesn’t recognize her when she did it while holding him in her arms.

There is a third type of fanon, one that ascribes hitherto vaguely hinted (or not hinted at all) motivations to a character or amplifies (what TVTropes would call flanderizes) established traits such as the insistence on having Minako Aino flub a line every chapter, or having Akane Tendo chase everyone who accidentally sneezes in her direction with a mallet.

These last two types, while occasionally literarily useful, can be somewhat dangerous. For example, there is the habit of an author latching onto one of them as a device that they enjoy using in their work and, through that use, forgetting that it was an author-created device. For example, I often have to remind myself that, in the Anime and Manga, Ranmaverse characters very rarely show any ability to detect the life force of others, and that usually occurs when an aura is being clearly displayed, or a hostile action is being taken against them. It is important to keep track of these devices, as you can find yourself correcting another author on a point of fact that is, in fact, only one of your personal plot devices, or failing to enjoy a story because it violates it.

The strangest effect that modified devices or characters can have on a series is what, for the purposes of this example, I’m calling pervasive fanon, and since it is the thing that brought it to my attention, I will be using Sailor Pluto, and her relationship with the timeline and time gates for the example.

Taking only Sailor Moon, the Anime series as a basis, Sailor Pluto’s limitations and job are rather clearly spelled out. She is to guard the gates of time, ensure that she is standing at them and guarding them at all times (barring earth-shattering emergencies), and not to abuse her powers, most particularly the time stop, the penalty for which is death.

At some point (I have absolutely no idea when or who was responsible), a fanfiction author wished to write a story either revolving around Sailor Pluto, or the act of changing the past. To that end, this author thought that it would be neat if Pluto could open the gates without passing through them, to use them as a sort of temporal viewer rather than a time travel device, explaining that, in his fic, the gates had that function built in to better facilitate her guarding of the timeline.

This plot device was actually quite a good one. It allowed a whole new character interpretation for Pluto. No longer simply the grim guardian of time who stood vigil over one of the most dangerous forces in existence to keep it under control, this Pluto could actually shape events, could enforce her will on the timestream. This is fanfiction, after all, and the possibilities of that are endless, depending on how her character was played.

I’m guessing that the sheer number of possibilities from this plot device, the time gates as a monitoring device, resulted in a wave of fics that used the same premise for various effects and even fics that used it for side or background effects that would help a main story.

This is where things get interesting. The human mind tends to suffer from something called “Source Amnesia.” That is, we sometimes have trouble determining where we heard or learned a piece of information. In a case where we are reading and writing fanfiction about a series that we may not have all of the episodes of, or that we may only be catching once a week, this source amnesia tends to kick in pretty hard, and that’s why things like Pluto’s extra powers over the time gates tend to seep into our knowledge of the series. It’s obvious Pluto can do that, it’s obvious Youma and Dark Generals can absorb large amounts of life force with a single touch, it’s obvious that Sailor Jupiter is actually a dryad… wait, what?

All of these things seem obvious because we’ve seen them so often, as they become popular fanon devices, and we simply cannot go over the canon nearly that much. There are 200 episodes of Sailor Moon, each of them 22 minutes long, and the fifth season is only subbed. Let’s not even talk about the differences caused by the editing done during the dubbing process, and the trick some people (including me), do of assuming that X thing I could have sworn was canon must happen in the subbed version.

All of this seems kind of annoying, but not really that bad, right? Unless someone takes something as fanon that you find really annoying, it shouldn’t bother you. Well, that’s not exactly true. Getting back to Sailor Pluto and the Time Gates. Over the more than a decade that her abilities have been changing in fanon, the generally accepted version of her is capable of monitoring the timeline for change, sometimes remotely, and ensuring that the most likely outcome, right down to decimal point probability, remains crystal Tokyo. If you want to change something, add a major character that shakes things up, many authors will catch themselves wondering, “How would Sailor Pluto let this happen? It would cause X to happen wrong!” and then come up with a long, complex explanation as to how she could tweak things so everything worked out.

But let’s put things back into perspective, here. Recall her original list of abilities? She guards the gate of time, which is a corridor that lets you travel through time. Her only temporally dangerous ability is a timestop that will straight up kill her if she uses it. So you can go ahead and put your new character, scene, or reaction in, because canon Sailor Pluto has no inclination to stop you… unless you’re trying to blow up Usagi or something, anyways. And then she’ll do it by teleporting out of the gates when something or someone else informs her and hitting you upside the head with her staff, not going back to last Tuesday and re-arranging gum wrappers so you never have the idea.

In short, fanon is a useful thing for authors, it lets them do pretty much anything they want with a series and its characters, determined only by the writer’s ability and imagination. But when a stumbling block comes up from what you feel is a well established plot point, don’t be afraid to go back and check the source. If it’s fanon that’s blocking your way, you don’t need it.

Ed.: If you have any ideas as to where in the fandom the expansion of Sailor Pluto’s powers originated, please share them in the comments. Inquiring but overworked minds want to know.

Posted in Otaku Stuff, Writing | 1 Comment

Functional Programming Concepts for the Lay Programmer – Part 2

Update: Part 3 is finally available.

After languishing in the drafts folder for over a year and a half,  Functional Programming Concepts for the Lay Programmer – Part 1 now has a friend.

The Easy Stuff, Continued

Mutable/Immutable
In many languages, there are certain data types where, once an instance created, it cannot be changed. That is, any attempt to change the value produces a new object, leaving the old one unaltered. Such data types are known as “immutable” (unchanging).
Generally, functional languages apply this principle to all data types to limit programming with side-effects to things like disk and network access.
Conversely, data structures which can be altered (eg. Lists/Arrays in pretty much any language which supports imperative programming) are known as “mutable”.
Lambda
Also known as anonymous functions, lambdas are functions which can have their definitions placed anywhere a function name would normally be expected as an argument (See “Higher-order Function” in part 1) and, unlike regular functions, don’t need to be assigned a name. While Python’s lambdas are very limited compared to more functional languages, being more reusable expressions than proper functions, this example should still help to clarify the utility of one-off functions:

myList.sort(key=lambda x: abs(x.delta))

In one line, that lets you perform an in-place sort on the absolute values of the objects’ “delta” member variables. I also ran across a slightly more technical explanation in case you want it. I’m told that the implementations of many Ruby APIs are also an excellent example of the utility of lambda-like constructs thanks to Ruby’s anonymous block construct.

Tuples

In every functional or multi-paradigm language I’ve had personal experience with, lists have certain restrictions. For example, in Haskell, the type signature of every element in a list must be the same while, in Python, lists are mutable which, as a side-effect, means they cannot be used as dict (a.k.a. hash/mapping) keys.

The tuple is a list-like data structure which provides a different set of limitations. In Python, tuples are immutable but can be used as dict keys. In Haskell, you can create a tuple with any combination of elements, but every tuple will have a unique type signature. (If you’re familiar with C-like languages, think of a list as an array and a tuple as a simple struct. The implications for function type signatures are essentially the same.)

In both languages, the most common use I’ve found for tuples is allowing a function to return multiple values of varying types without having to define a new, single-use data type.

Generators

Imagine a function which you can leave and re-enter without losing its internal state. That’s what generators are. They’re most commonly useful anywhere you want to iterate over something without having to generate the entire set of values before you start.

Python implements generators, so this bit of example code should make it a bit clearer:

def find_first(thing):
    for fldr, dirs, files in os.walk('/home/me/stories'):
        for fname in files:
            if thing in fname:
                return os.path.join(fldr, fname)

os.walk is a generator which wraps up a depth-first tree traversal as an iterator so you have the option to abstract away the recursion. Each time it resumes, it traverses one iteration further into the algorithm.

What makes generators so special is how simple they are to use:

def thumbnails(img_paths):
    for path in img_paths:
        base, ext = os.path.splitext(path)
        yield base + '_tn' + ext

for thumbpath in thumbnails(list_of_millions_of_paths):
    # Do something

Think of that yield keyword as “return, but let me resume execution where I left off”. I use them for writing things like for block in parse_png(file_handle):

Coroutines

Coroutines are basically the next generalization up from generators. While generators give you a way to return multiple times from a single function, coroutines give you a way to exit and enter a block of code, receiving and sending data as you go without relying on side-effects (see pure function). Wikipedia has examples of how this is useful.

Python 2.5 and above support coroutines using these extensions to the generator syntax:

def coroutine():
    # ...
    input = (yield output)
    # ...

co = coroutine()
while I_am_looping:
   # ...
   return_value = co.send(new_argument)
   # ...

Continuations

If you take one more step from coroutines, you get to continuations. As a friend put it, “continuations are what system calls do”. The operating system saves everything about your program’s current state and goes off to do something else. Then, when the return value of the system call is ready, it restores that saved state and resumes your program where it left off. When a programming language has good support for continuations, you can arbitrarily choose to save the state of a thread of execution, pass it around, and then come back to it later. As another friend put it, “continuations are what you’d use to, say, implement the ‘yield’ keyword”.

If JavaScript had continuations, for example, you wouldn’t need to write so many callbacks. You’d just write what appears to be a blocking code but works asynchronously under the hood. TameJS (JavaScript continuations for Node.JS using C# syntax) and F# (Example 4: Asynchronous programming) provide good examples of how this looks and works.

Alongside anonymous functions and tail recursion, continuations are one of the few functional-programming features that basic, bog-standard Python doesn’t support… but there is a Python web application framework named Nagare (built on Stackless Python) which uses them to provide a very unique approach to writing Python web applications.

Still to Come…

  • Map/Reduce/Filter
  • Closures
  • Metaclasses

Let’s hope that, this time, it doesn’t take me a year and a half to write it.

Posted in Geek Stuff | 1 Comment

Just a Few Little-Known REAL Mysteries (and other interesting things)

Around the time I wrote “A Few Suggestions/Pleas to Authors of Mystery-oriented Fiction“, I started work on a little post about some of the real mysteries that don’t get much attention. It’s not as long as I’d like, but I don’t think I’ll have time to extend it any time soon.

The Devil’s Kettle
Located in Judge C. R. Magney State Park in Minnesota, U.S.A., this unique waterfall sends half the flow of the Brule river underground. Nobody knows where the water ends up and scientists have no idea how a tunnel capable of carrying that much water could have formed in that kind of rock.
Metro-2
Supposedly, Moscow is home to a secret subway, begun in Stalin’s time and buried deep underground, which interconnects politically important buildings like the Kremlin and the Government Airport and links them to a secret bunker described as an “underground city”. Various current and former members of the government have given various (sometimes conflicting) bits of information but there is nothing reliable on what really does exist and what is exaggeration.

…and since the list is so dissatisfyingly short, I’ll also throw in some…

“Merely” Fascinating Places

Karst Towers
If you’ve ever looked at a traditional Chinese painting (or Super Mario World) and wondered where they got the idea for their exaggerated (sometimes almost phallic) hills, look no further. Essentially nonexistant in North America and Europe, these steep, rocky spires dominate the landscape in various locations in Southeast Asia, most distinctively around the Li River in China, but also in less striking forms in Vietnam.
Hashima, Japan (A.K.A. Gunkanjima)
From 1887 to 1974, this island provided coal for Japan’s industrial needs. At its peak in 1959, it had a hellish population density nearly five times that of Macau, and ten times that of Singapore or Hong Kong. Today, this tiny island is a crumbling concrete ghost town, known mostly to enthusiasts, tourists, and fanfiction authors.
Neft Daşları
Around the end of the 1940s, the Soviet Union was running out of easily-accessible oil, so they decided to drill for it in the Caspian sea… but this was the ’50s and this was the Soviet Union. Rather than build a compact little platform like we do now, they picked a spot with shallow water and Oil, built islets, connected them with causeways, and built a full-blown city on the site. Now part of Azerbaijan, it still produces oil and natural gas.
Unit 731
Everyone knows of the Nazi death camps, but what most people don’t know is that, in World War 2, the Japanese had a branch of the Imperial Army which went even further. Officially known as the Epidemic Prevention and Water Purification Department of the Kwantung Army, Unit 731 was tasked with kidnapping members of the local Chinese population and performing sickeningly cruel experiments on them and on captured prisoners of war to test weapons and to study the progress of various diseases.
Perhaps equally surprising is that we might not have known about this if not for two notable details: First, when the Russian army forced them to abandon their work, participants were ordered to destroy the facilities and commit suicide but it turned out that they’d been constructed too well for the former. Second, while everyone working on the project had been ordered to take the secret to their grave and prohibited from returning to civilian life in Japan, General MacArthur secretly offered immunity to the medical personnel in exchange for granting America exclusive access to their biological weapons research… an offer which they accepted.
Ilha de Queimada Grande (A.K.A. Snake Island)
A small island off the coast of Brazil so densely populated with venomous snakes that, aside from the odd scientist with a waiver, the Brazilian navy forbids civilian visitors. Thanks to Cracked.com for cluing me onto this one.

Got any more real mysteries or little-known fascinating places? Leave a comment and I may amend this list.

Update: As he is wont to do, xkcd did a comic and it’s a chart on the topic of mysterious things.

Posted in Web Wandering & Opinion | Leave a comment

Floating Flattr Buttons in TiddlyWiki

As you’ve no doubt noticed, I’ve started to add Flattr buttons to my various creations. However, given that none of my other attempts to get other people to pay for my hosting have worked, I’ve learned to care more about aesthetics, tact, and tastefulness than about the actual effectiveness of my attempts.

That meant that, when I decided to add a Flattr button to the list of TiddlyWiki plugins I’ve created, I insisted on it looking good and not disturbing the rest of the layout.

My first attempt was to use the standard “dynamic counter” button in the large, rectangular form that Digg originally popularized. It turns out that something about TiddlySpace keeps it from showing and I don’t have time to fool around. On to the static button.

Flattr this

Flattr gave me code that looks like this:

<a href="http://flattr.com/thing/416932/TiddlyWiki-Plugins-by-ssokolow" target="_blank">
<img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a>

Unfortunately, embedding raw HTML in TiddlyWiki using <html> is messy, inelegant, and wraps the HTML in a span with no ID or class to set float: right; on. Therefore, I started translating the markup into TiddlyWiki’s syntax:

[>img[Flattr this|http://api.flattr.com/button/flattr-badge-large.png][http://flattr.com/thing/416932/TiddlyWiki-Plugins-by-ssokolow]]

According to the documentation, that should’ve been enough… but unlike their demo, I was getting align="right" rather than float: right;… so I wrapped the thing in a div using TiddlyWiki’s custom class markup and floated it by adding a line to the StyleSheet tiddler:

{{flattrFloat{
[>img[Flattr this|http://api.flattr.com/button/flattr-badge-large.png][http://flattr.com/thing/416932/TiddlyWiki-Plugins-by-ssokolow]]
}}}
.flattrFloat { float: right; }

That just left one problem: TiddlyWiki was inserting a <br> tag that was throwing off my layout. A quick adjacent sibling rule solved that.

.flattrFloat + br { display: none; }

You can see the result in the wild on my TiddlyWiki Plugins list.

Posted in Geek Stuff | 1 Comment