blog

Archive for December, 2007

Yet Another Related Posts Plugin

Saturday, December 29th, 2007

UPDATE:

This posting is now outdated… for the latest information on YARPP, please visit YARPP’s very own page on my site, or its page on wordpress.org. If you have questions, please submit on the wordpress.org forum. Thanks!

Description

Today I’m releasing Yet Another Related Posts Plugin (YARPP1) 1.0 for WordPress. It’s the result of some tinkering with Peter Bowyer’s version of Alexander Malov & Mike Lu’s Related Entries plugin. Modifications made include:

  1. Limiting by a threshold: Peter Bowyer did the great work of making the algorithm use mysql’s fulltext search score to identify related posts. But it currently just displayed, for example, the top 5 most “relevant” entries, even if some of them weren’t at all similar. Now you can set a threshold limit2 for relevance, and you get more related posts if there are more related posts and less if there are less. Ha!
  2. Being a better plugin citizen: now it doesn’t require the user to click some sketchy button to alter the database and enable a fulltext key. Using register_activation_hook, it does it automagically on plugin activation. Just install and go!
  3. Miscellany: a nicer options screen, displaying the fulltext match score on output for admins, an option to allow related posts from the future, a couple bug fixes, etc.

Installation

Just put it in your /wp-content/plugins/ directory, activate, and then drop the related_posts function in your WP loop. Change any options in the Related Posts (YARPP) Options pane in Admin > Plugins.

You can override any options in an individual instance of related_posts using the following syntax:

`related_posts(limit, threshold, before title, after title, show excerpt, len, before excerpt, after excerpt, show pass posts, past only, show score);

Most of these should be self-explanatory. They’re also in the same order as the options on the YARPP Options pane.

Example: related_posts(10, null, 'title: ') changes the maximum related posts number to 10, keeps the default threshold from the Options pane, and adds title: to the beginning of every title.

There’s also a related_posts_exist) function. It has three optional arguments to override the defaults: a threshold, the past only boolean, and the show password-protected posts boolean.

Examples

For a barebones setup, just drop <?php related_posts(); ?> right after <?php the_content() ?>.

On my own blog I use the following code with <li> and </li> as the before/after entry options:

<?php if (related_posts_exist()): ?>
<p>Related posts:
<ol>
<?php related_posts(); ?>
</ol>
</p>
<?php else: ?>
<p>No related posts.</p>
<?php endif; ?>

Coming soon (probably)

  1. Incorporation of tags and categories in the algorithm. I’ve gotten the code working, but I still need to think about what the most natural algorithm would be for weighing these factors against the mysql fulltext score currently used (and works pretty well, I must say).
  2. Um, something else! Let me know if you have any suggestions for improvement. ^^

Version log

1.0 Initial upload (20071229)

1.0.1 Bugfix: 1.0 assumed you had Markdown installed (20070105)


  1. Pronounced “yarp!”, kind of like this, but maybe with a little more joy:
     

  2. Did you know that threshold has only two h’s!? I’m incensed and just went through and replaced all the instances of threshhold in my code. It’s really not a thresh-hold!? 

Great news! You can opt-out from Omniture’s 192.168.112.2o7.net

Saturday, December 29th, 2007

Omniture’s disgusting 192.168.112.2o7 tracking url and Adobe CS3’s use of it has been picking up some dirt recently, starting with uneasysilence, and propagated through DF, ZDnet, and more.1 And then it was discovered that the Apple iTunes MiniStore does the same. But ValleyWag gives you the good news:

Don’t want to be their guinea pig? Omniture lets you opt out.

Oh wait, really? You can? That’s great! This opt-out link gives you a cookie called omniture_optout on .2o7.net with a 1 value. But wait, it’s a cookie? That means…

Omniture opt-out explains (emphasis mine):

…it is necessary to install a cookie on your browser. This cookie identifies that you have opted-out. If you delete the opt-out cookie, or if you change computers or Web browsers, you will need to opt-out again.

That’s right. Cookies are stored in your browser. So if you opt-out in Safari or FF, will you be opted-out in a CS3 app? Um, no. Or in the iTunes MiniStore? No.

In the case of the MiniStore, you can just turn it off. But in the CS3 case (and for any other apps that build such communications in) things are trickier. As a commenter suggests on the ValleyWag, it looks like Little Snitch is the best way of clearly opting-out of communications like this. Unless, of course, you want to switch to Vista.


  1. It’s important to give props to our man John Gruber. The ZDNet article jumps on the John Nack train of “you can’t call this disgraceful without looking into it!” But you clearly can see something is suspicious about a 192.168.112.2o7 url, which was the main impetus for Gruber’s harsh claims. John Nack hath since repented

dvipng color trouble

Friday, December 28th, 2007

I still have yet to find a fix to the dvipng discoloration mystery I ran into back at The Academic Approach, even with the latest MacTeX version, so I’m going to repost the problem here.

In May 2007, I wrote the following to the OS X TeX listhost:1

Hi all,

I’ve recently run into what I believe is a rare bug in dvipng: here’s the setup. (To play along, you can get my test files: http://mitcho.com/discolor.zip .) I am using MacTeX… in fact, it’s today’s release.

The LaTeX source file (discolored.tex) loads just two packages: color and graphicx. The body does two things: an \includegraphics with a local PNG file (with the bb option to specify the BoundingBox explicitly) and a \textcolor command introducing some green text, using the green defined there.

pdflatex produces the expected result: the figure and the green text.

Original color

But when you run the following commands…

latex discolored.tex

dvipng -D 200 discolored.dvi

you get a PNG (discolored1.png) which shows the text in a brownish color… the green is gone!!

Discolored version

There are two quick ways to fix this that I’ve found: one is to not include the image… if you comment the \includegraphics command out, the color comes out fine. The second is to not specify a -D (output resolution) parameter in the dvipng… this also gives you the expected output. However, in my current project, neither of these are available options…

I am frankly not very familiar with the inner workings of dvipng… does anyone have any thoughts? Can this bug be reproduced?

Any hints or suggestions are welcome!

Ditto.

discolor.zip
496 kb - zip

  1. Inline cropped images added to this web version, just to spice things up. 

The Gift That Keeps On Giving

Thursday, December 27th, 2007

Christmas in Yilan just keeps on trucking. Two days ago I wrote about my Christmas lessons and the special event at Penglai. But Christmas didn’t end on Christmas… I’ve continued to take part in festivity after festivity.

(more…)

I’m Seriously Dreaming of a White Christmas

Tuesday, December 25th, 2007

Today we finished up all our Christmas lessons at school, spread over the past week. The lesson involved some basic Christmas vocab, making Christmas cards, and my retelling of The Gift of the Magi.

(more…)

It’s That Time of Year!

Monday, December 24th, 2007

Time to apply for summer 2008 with Concordia Language Villages! I just applied—you should too!

Make sure to read up on the new position descriptions before applying (no more Junior and Senior Counselors… take a look), as well as the important policy clarifications. Good luck to all who apply!

Setting Language Research to Music

Monday, December 24th, 2007

Via LinguistList:

‘Setting Language Research to Music’ is a Newcastle University project whose aim is to compose orchestra and choral music to demonstrate infant perception and production. The first piece of music to emerge from the project, ‘Swing Cycle’, mimics babies’ experience of discovering word boundaries, taking work by Peter Jusczyk and colleagues as a starting point.

It’s the craziest thing I’ve seen in a long while… it reminds me of the Music: Materials and Design course I took a couple years ago. My final project was an electronic composition building a rhythm with political speech samples and echos and cracking noises, representing the hollowness of political rhetoric. It was one of my academic low points at Chicago, for sure.

Maybe it’s because I’m an artist, but I’ve never understood the drive for modern art, including compositions like these. I would much rather listen to some music and read about language acquisition separately… the motivation to combine the two eludes me.

You can listen to The Swing Cycle and read the lyrics (or their approximation) on the Setting Language Research to Music website.

New phone! Sony Ericsson J110i

Saturday, December 22nd, 2007

My Motorola PEBL that I bought a year or two ago (used on eBay, of course!) has recently started to die, so I walked around the Guanghua (光華) Electronics District1 near National Taipei University of Technology and bought a new one. I asked around for the cheapest, simplest phones, and settled with this one: an unlocked Sony Ericsson J110i. It’s ridiculously simple, but that’s what you get for NT$1700 (≈$50). No pictures, and no Bluetooth, but it does display Chinese and I can type in bopomofo (ㄅㄆㄇㄈ). The phone is about the same size as the PEBL, but much lighter (and thus feels cheaper).

IMG_0164

The one single annoyance thus far is that it doesn’t have a little hook for the strap that was given to me. :(


  1. It’s Akihabara, but in Taipei! Take Exit 1, the elementary school exit, at the Zhongxiao Xinsheng (忠孝新生) MRT stop, go straight, turn right after the school, and walk down a block or so. The district opens up on the right. The big shops line the main road, but the crazy little specialized bargain stands/stores are within a block or two north and south of there.

    One of my favorite places around there is Youth, the local Apple Authorized Reseller and Repair place (they helped me out earlier this summer…) and also have a cute café with free wifi on the second floor. In fact, I’m there right now! 

Family in Taiwan

Saturday, December 22nd, 2007

As all my visitors leave, I should take some time to document all the adventures of the past month or so: here’s a quick post on my family’s visit to Taiwan last month.

Day 1: Shilin night market

I met my mother, father, and sister at the Cosmos Hotel where we were staying Friday night. I took them out to the Shilin night market, a Taiwanese tradition. We bought t-shirts, ate lots of things on sticks, saw a man pushing a cart full of guava, and people picking up their stands and running from the cops (technically, the “I’m going to set up a table on the street and sell stuff” part of the night markets are illegal).

IMG_1463IMG_1449IMG_1456IMG_1456

Day 2: Exploring Taipei

We went on a Japanese bus tour of Taipei, led by this older Taiwanese guy with great Japanese, though sometimes just a bit off (Bailey would have called him “precious”). We visited:

Longshan Temple (龍山寺);

IMG_1491_2IMG_1469IMG_0087

Chiang Kai-shek Memorial Hall National Taiwan Democracy Hall;

IMG_0094

a market with various traditional foods;

IMG_1476IMG_1475

a Taiwanese tea demo and explanation, which was really interesting;

IMG_1481

the changing of the guard at the National Martyr’s Shrine (kind of like Yasukuni Shrine), where the guards aren’t allowed to move or blink (I think) for about 40 minutes at a time, and then a guy comes up and covers their face and says some spell so they can move;

IMG_0100IMG_1482IMG_1486IMG_0098

and of course the National Palace Museum, where we weren’t allowed to photograph anything. After the tour we went to the top of Taipei 101 and got to enjoy a great night view of the city.

IMG_1492IMG_0106

Taipei 101 features an open view of its tuned mass damper, which they’ve named “Damper Baby.” It’s neat, actually, how they took something that is normally only interesting to engineers and tried to make it cute and sexy. It even has a bio, complete with blood type (O, in case you were wondering).

IMG_0114IMG_0121

Day 3: Rainy day in Yilan

On Sunday we went to National Center for Traditional Arts (國立傳統藝術中心) near Luodong. We saw some crazy show with all different sorts of animals which I’m sure made more sense if you understood what they were saying and an exhibit on paper craft of all different sorts, including origami. The main attraction there is the traditional arts street, a red brick street with all sorts of stores selling traditional food and crafts. The leather shop had a pig mask.

IMG_1503_3IMG_1500 IMG_1508IMG_1501IMG_1506

We then had dinner in central Luodong: some delicious hot pot while sitting on a glass floor above koi fish.

IMG_1515IMG_1516IMG_1511IMG_1514

We got some deserts and took them back to the hotel they were staying at. Naomi was excited by the 苺大福 (traditionally, mochi with strawberry and red bean paste inside) from 85°C.

IMG_1519

Day 4: Nanao and Jiufen

On Monday I took the morning off from school and showed them around Nanao a little bit. The weather kept getting worse as typhoon Mitag came rolling through. My family still got to see where I live, one of the schools I work at, and have a nice lunch before heading out.

IMG_1534IMG_1529_2IMG_1524_2IMG_1525IMG_1527

On the way back out to Taipei, my family (without me) stopped in Jiufen (九份), a touristy town atop a mountain on the northeast coast of the island. The town, originally populated due to a gold rush, has some beautiful mountain alleys and tea houses. The city is now popular with Japanese tourists, as some parts of the city were used as models in Spirited Away. My family went to one tea house and enjoyed the tea and atmosphere.

IMG_1557IMG_1547_2IMG_1549_2

My family went back to Japan Tuesday (Day 5), with my parents leaving later back to the US. It was really nice to be with all of them, even for such a short time.

Hot Sleeves

Wednesday, December 19th, 2007

A great example of Taiwanese customer service: I recently bought a hot drink at a 7-11. After paying at the register, the cashier put a hot beverage sleeve on it for me. Very kind.

IMG_0136

But then later I looked a the sleeve. It has some non-verbal instructions on one side…

IMG_0138

and, just in case that didn’t work for you, there’s an image of the end goal as well:

IMG_0140

Recall that the cashier put the sleeve on for me. That’s just crazy.

Eats, shoots, and leaves

Monday, December 17th, 2007

I just read Clause and Effect (via DF), a great editorial discussing commas in the second amendment and their effects on interpretation of the law. I found this timely as Bailey and I just watched Institutional Memory, the penultimate episode of The West Wing, where Toby Ziegler discusses a comma in the fifth amendment’s takings clause: “nor shall private property be taken for public use[,] without just compensation.” BBC’s H2G2 has a pretty good write-up and there’s a listing of relevant links as well.

The funny thing about all of these is that we don’t speak commas. It’s used to graphically represent pauses in speech, but are often used according to certain artificial rules which, when used systematically, aim to help the reader parse the sentence or help disambiguate between different readings.1

I’m surprised Language Log hasn’t picked up this new piece yet. UPDATE: Yup, they got to it. Great coverage, as always.


  1. We use pauses in spoken language to do this too, but not necessarily in the same places that we place commas in “good” written language. 


© 2006-2010 mitcho (Michael 芳貴 Erlewine).
Proudly powered by WordPress.
Entries (RSS) and Comments (RSS).
The views expressed on these pages are mine alone and do not
reflect those of my employers and clients, past and present.