Lexicon WordPress Plugin v1.1

By Shamus Posted Saturday May 27, 2006

Filed under: Programming 8 comments

I’ve been thinking more about the wordpress plugin I released a few days ago and how to improve it. This project started with this post at haibane.info, where Fledgling %Otaku talked about making a blog useable for for people familiar with your subject matter and at the same time making it accessable to newbies.

I wanted a plugin that would provide dictionary links for all of the jargon on my site but wouldn’t require any extra effort on my part (because I’m big on energy conservation, particularly my own) and that wouldn’t clutter up my posts with HTML tags.

The first try was a little rough. Fledgling %Otaku has some good suggestions for using wiki-style tags which I really liked at first, but I moved away from this for a few reasons:

  1. Using wiki tags would mean going back and adding those tags to old posts, or accepting that the jargon on old posts would remain . Meh.
  2. There are already plugins that use wiki-style markup tags, and I may want to use them someday. Right now I could combine the two with no conflicts, but if I adopt wiki standards then those plugins with conflict with my own.
  3. If for whatever reason I drop usage of the plugin in the future, my posts would suddenly be filled with brackets and markup text. I’m very commitment-shy when it comes to software, even stuff I’ve written myself.

I realized I could parse things much better if I used some PHP 5-specific code. I honestly don’t know if this is a problem or not. This site has been running on PHP 4.4 and I had to request that Hosting Matters (my host) move my site to a machine with PHP 5. (Which they did quickly and seamlessly, BTW.) I have no idea how widespread PHP 5 is or how much this will limit the usefulness of the plugin to others. PHP 5 has been out for nearly two years, but there are still some holdouts, and I assume they have good reasons for this. Comments on this are welcome.

Using PHP 5 I was able to eliminate almost all of the shortcomings of the original version. It won’t insert unwanted spaces. It will pick up links even if they are bracketed by HTML tags. It WON’T mess with keywords that are inside of HTML tags. It won’t mess with the case usage of the original word.

The only bit of markup I did add was that you can now preceed a keyword with a percent to prevent it from becoming a link. This enables me to say, “Fledgling %Otaku is one of my favorite otaku”, and not have his name become a link to my dictionary.

For those interested, you can download the plugin here.

 


 

8th Grade Math

By Shamus Posted Friday May 26, 2006

Filed under: Personal 23 comments

Another stupid internet test…


You Passed 8th Grade Math


Congratulations, you got 8/10 correct!

An 80% is humiliating and shameful, particularly since I’m a programmer who focuses on 3d. The questions I missed were related to statistics, which I’ve never taken. I couldn’t tell you how “median” differs from “average”. (More to the point, I know how to obtain an average, but not how to obtain the median. Now that I’ve taken the test, I think I’m going to google around and spackle over these gaps in my learning.) I knew that info was just a hop away with Google when I took the “test”, but I wanted to see how I could do using what’s in my head. How did I end up 34 years old and ignorant of some low-level areas of mathematics?

It’s a bit strange, really. In high school I hated, hated the numbing repetition of math. I was of the opinion that any teacher who would assign 60 nearly identical problems as homework was a demented sadist, and any student who would sit down and do all 60 was a fool.

But this was the way of things. Learning long division? Monday you’ll do a few dozen single-digit problems. Tuesday you’ll do a few dozen more, but they add a digit of complexity. Wednesday will be more of the same, with a few three-digit problems to “challenge” you. Thursday you get another batch of problems that mix them all together. Friday is the test. Rinse. Repeat.

By the end of class on Monday you had all the tools you needed for dealing with Friday’s test, but you were doomed to waste the next three days doing the same problems over and over again. The homework was extreme overkill. If I can do seven of them, then surely I can do the next fifty-three with no difficulty.

So I never did homework. Never. I would score an A or B on the test (I was sloppy, and didn’t like to show all my work) but since homework was part of the grade, I usually pulled a C or D in math. I dreaded hearing the words, “Just do the homework and I promise you will pass this class.” I took this to mean, Just make sure you do the busywork and I’ll pass you even if you don’t really learn anything. The fact that lots of people got better final grades than me when their understanding of math was not as strong only confirmed in my mind that the whole thing was a joke.

This sounds like I’m warming up for a screed against the American education system, but really the fault was my own. The fact that know-nothings can pass with decent grades is regrettable, but more important is the fact that there was still a decent education available for those who were willing to work for it. I got out of high school exactly what I put into it. Sadly, I didn’t put much into it.

I made a point of taking the easiest classes available – particularly in math. Not content with taking the regular algebra, I took the courses that watered it down and presented it in two seperate classes: Elementary Algebra 1 and Elementary Algebra 2. With all the various offerings of algebra at varying speeds, I was able to “learn” algebra three times during high school, while getting credit for doing so each time. In the end I expended a lot of effort avoiding work.

A few times people suggested that I would do well to shoot for the harder courses. This sounded insane. To me the hardest part of the course was the overload of mind-numbing work. I expected harder courses to simply be more of the same, but with more digits and larger problem counts. I found out later that the “harder” courses would have been far more interesting, and they often assigned just a small handful of (large, challenging) problems a night.

It wasn’t until a few years after graduation that I really began to see what I’d missed. I got into 3d programming, and found I needed triginomitry. More to the point, I found I liked trig. I’d never set foot in a trig course. I’d never done any calculus. I’d never taken geometry. I’d wasted all that time on re-learning stuff I already knew because I was afraid of work. Now I needed it and had to learn it on my own.

I’ve done fairly well at grasping the concepts, although since I’m self-taught a lot of the language of mathematics eludes me. I don’t know how to properly use the greek symbols, even though I’m sure I’m writing computer code for formulas that would require greek to express properly on paper.

Let’s try this again…


You Passed 8th Grade Math


Congratulations, you got 10/10 correct!

Sadly, no questions on how to normalize a vector or build an orthographic projection matrix.

 


 

Ai Yori Aoshi: Second Thoughts

By Shamus Posted Friday May 26, 2006

Filed under: Anime 0 comments

Pete Zaitcev has a great post on Aoi Sakuraba with lots of screenshots. It reminds me of how charming that character is and how much I enjoyed watching her. He also talks about some of the major shortcomings of the series.

I’m sort of avoiding watching it again. I remember the series fondly, but it was one of the first anime I’d ever watched. The show is full of cliche’s and predictable situations, but since I was new to anime it all seemed fresh and new to me. I have a feeling that if I were to go back and re-watch the story it would look quite different.

 


 

Adventure!

By Shamus Posted Thursday May 25, 2006

Filed under: Game Reviews 4 comments

Mark has an interesting bit on old-school Atari games, wherin he asserts:

The games will be covered in separate posts, but I will say that while they were fun at the time, I can see why people lost interest until the NES. Most games primarily involved manipulating various elements on the screen to get a higher score. Period. There really weren’t any goals other than running the score up as high as possible (there were exceptions to this which will be covered in later posts).

I had an Atari and was obsessed with it. But then I missed the following years as console gaming evolved to the NES / Super NES. In fact, once I moved away from the Atari I didn’t really play console games until nearly 20 years later when I got my hands on a PS2. (What happened was that I got my hands on a personal computer, and once I started coding there was no going back.)

So, I never really thought about the fact the the big innovations on the NES might not have been the graphics technology, but gameplay. Looking back, this does make sense and explains why the NES is still such a landmark in gaming all these years later. Makes me sorry I missed it.

But not all Atari games were run-up-the-score drool-fests. I’ll bet Mark was going to mention this, but I’ll leap ahead and say that Adventure is one of the rare exceptions that broke from the Atari formula.

This was about the most interesting game to show up on the Atari. I didn’t have a game appeal to me in the same way until I discovered Hack (later Nethack) sometime in 1988.

Here is a bit of trivia about the game that I’ve never seen documented anywhere: You could select the difficulty of the game, and the difficulty-selection screen looked pretty much like the screens you see above. It was walled in on all sides, with an opening at the bottom of the screen identical to the one you see below the castle in the first picture. In the middle of this area was a number from 1 to 3, showing what difficulty you had selected. Simple.

Except, if you sat there and moved the joystick around for long enough you could get your little character (the square) to enter through that opening in the bottom. This sometimes took a few minutes of stick-wrangling, which makes me wonder how I discovered it in the first place. I tried to figure out what pattern of movements would get the little guy to appear. Sometimes I would make circles with the stick. Sometimes I’d move it around at random. Eventually it would emerge from that opening. You could run up and bump into the selection number. (Why on earth did they have collision on a number?)

Not very interesting, except that I don’t know if anyone else has ever discovered it. It should be possible to duplicate it if you get your hands on the original ROM and an emulator.

 


 

Happay Mommay?

By Shamus Posted Thursday May 25, 2006

Filed under: Links 2 comments

So Technorati is going totally nuts and reporting links that aren’t there. For example, it tells me that this woman linked me twice today, which is a nice trick since she only posted once, and that post did not link anywhere. (This is clearly a fluke. I’m sure there are no links here from that site.)

But what’s REALLY freaking me out as I sit here in a 4a.m. insomnia-induced daze, is that the photograph on the left side of her site looks almost exactly like my son. It’s very odd to visit the blog of a total stranger and see a picture of my own son, looking the way he did about 18 months ago, wearing clothes he’s never owned.

I really should get some sleep.

LATER: I did. It still freaks me out.

 


 

Spins a web, any size

By Shamus Posted Thursday May 25, 2006

Filed under: Nerd Culture 4 comments

It is now about 4a.m. here and I can’t sleep for some reason. So, I’ve decided to inflict this on you:

Note that in the movies Spider-Man now has organic webbing. He doesn’t make it in a lab. It comes from inside his body. This means that when he webs you up, he’s covering you in his bodily fluids.

I just thought you should know that.

 


 

Lexicon WordPress Plugin

By Shamus Posted Wednesday May 24, 2006

Filed under: Programming 19 comments

This is a wordpress plugin I’ve made that will find certain words – which you define – and turn them into links which lead to your dictionary. The user can mouse over the word to see a short definition, or they can follow the link to see the full definition. This is handy if you have a lot of jargon on your blog which might confuse newcomers.

Example:

According to Steven Sempai, the TV series of Read or Die differs greatly from the OVA. Meganekko agent paper is only in the OVA, and contrary to common practice, the OVA has less fan service than the TV series. There is no ecchi, and most otaku will be glad to hear there isn’t a lolicon character, either. The cast is mostly female, but this isn’t a harem comedy. Agent paper is a sort of quasi-mahou shojou who can manipulate paper to form weapons and tools. There aren’t any mecha, and while agent paper is sometimes kawaii you won’t find any slapstick chibi humor here. The Seiyuu in the series are all excellent. I thought the story was silly, but some people liked it. If you did, then akanbe!!

In the above text, I didn’t create any of the tooltops or hyperlinks, I just typed the words and the plugin handled the rest. If I edit the post, I don’t have to deal with the dense clutter required to make all of that work. Editing that paragraph in HTML would be a nightmare, but with the plugin I just edit the plain text and the links happen as if by magic.

Installation:

Note that this plugin requires PHP5. If your webserver does not have this, the plugin won’t work!

First, download the plugin here. Unzip the files. You’ll need to edit lexicon.php (just a bit!) and then make your dictionary.

This plugin isn’t very advanced, and requires a little more setup than most plugins to get it working right. Deep breath, you can do it.

  1. Create the dictionary
    The first step is to create the dictionary file you will use, which is called dictionary.txt by default. You can see my dictionary here. There is an example dictionary included in the zip as well.

    For each word in your dictionary, there are 4 lines, the last of which is optional. Line 1 is the word (or even phrase) itself. Line 2 is a short definition that will be used as a tooltip. Line 3 is the full definition. Line 4 is optional, and can specify an image to use for the dictionary entry. Then you must have at least one blank line, and then the process starts over with line 1 of the next word, until the end of the file is reached. If you omit the last line (the image) then the entry just won’t have one. No biggie.

    For each entry in the dictionarty there are several lines:

    • Line 1 is the word itself.
    • Line 2 is the short definition used as a tooltip when the mouse hovers over the word
    • Line 3 is the full definition. Remember, it all has to be on one line!
    • Line 4 is the “see also”. Just put words seperated by commas and the dictionary will use them to cross-reference. Leave a BLANK LINE if you don’t want this.
    • Line 5 is the image, including path. Leave a BLANK LINE if you don’t want an image
    • Leave one more BLANK LINE before you list the next entry.

Note that you don’t need to sort the entries. The plugin will sort them into alphabetical order for you.

Note that if the word in your dictionary is defined in ALL CAPS, then it is treated as an acronym, and it will only turn into a link if it is written in all caps. If you do not define the word in all uppercase, it will be treated normally and any case combination of that word will become a dictionary link.

  • Add the dictionary to at least one post on your blog

    Make a new post. In this post add the following text:

    :LEXICON:

    That is a colon, the word “LEXICON” in all caps, and then another colon. The plugin will replace this word with the contents of your entire dictionary, complete with links and images. You can see mine here.

    Now edit the lexicon.php. If you don’t know PHP this might be a little scary. Be brave. Just a few lines down you’ll see:

    $ad_dictionary_url = "www.example.net/somepage";

    This is where you tell the plugin how to find your dictionary. Inside of the quotes, put the address of the entry you just created. If the permalink to that post is www.myblog.com/wordpress/my-dictionary/ then change the line to say:

    $ad_dictionary_url = "www.myblog.com/wordpress/my-dictionary/";

  • Place lexicon.php and dictionary.txt into your wordpress /plugins directory

  • Enable the plugin in the wordpress control panel

  • All done! Any of the words that appear in your dictionary will become links. You can add or change the contents of the dictionary at any time.

    Using Lexicon

    Dictionary words which appear inside of HTML tags are ignored. Words appearing after a < and before a < are assumed to be an HTML tag and the plugin won’t mess with them.

    If you do NOT want a word to become a dictionary link, preceed the word with a percent symbol. For example:

    Sempai!
    %Sempai!
    

    Would yield:

    Sempai!
    %Sempai!

    Note that you should do this if the word appears within a link! If you don’t, the plugin will still turn the word into a dictionary link, which will break the link you were trying to create and make a mess of the HTML.