An AJAX page loading script for WordPress

I have been experimenting with a custom AJAX page loader for my WordPress blog in recent months. Today I broke this project out into its own repo, available here: WP AJAX Page Loader. It is readily installed via Bower: bower install wp-ajax-page-loader. Some additional work is required to integrate and configure this script for your own projects.

I starting working on this project after learning about some of the many problems associated with history.js, a polyfill that many infinite scrolling implementations rely on to this very day. After having a look at some of the options I decided to adapt one of my own scripts to achieve pretty much the same effect with a much smaller payload size and a bit of a smoother user experience (or one that suits my needs anyway).

This script requires jQuery (already included in WordPress), HTML5 History API, and spin.js. Without jQuery (but with the other dependencies) it clocks in at about 15.5 Kb minified (comparable to the 21 Kb of Paul Irish’s Infinite Scroll).

Read the documentation or peruse the source code for more information or have a look at Pendrell for an example of integration and configuration. This script is currently active on this site so you should be able to demo it by browsing around any of the archives and clicking on “next” (or simply positioning the viewport near—but not at—the bottom of the page, for I’m running the script in “footer safe” mode).

Taiwan from above

Taiwan from above
Southern Taiwan at 30,000 feet.

I recently returned to Taiwan 台灣 after spending a few days in Chiang Mai เชียงใหม่ connecting with the #nomads community and otherwise enjoying the warm sun and hospitality of the land of smiles1. Thanks to a happy accident of seating the hourlong descent into Táoyuán 桃園 was like something out of a dream. Our flight path closely followed the western coastline affording impeccable views of the island from the southern tip to the point of landing.

This photograph captures the urban sprawl of Kaohsiung 高雄, Taiwan’s great southern metropolis, framed by Qíjīn 旗津, the slim island guarding the entrance to one of the busiest ports in the world, and the knobby hill of Gǔshān 鼓山, a rare patch of green space amidst the concrete jungle. On the distant horizon one can see the spine of the immense Central Mountain Range 中央山脈 which rises out of the sea in Pingtung 屏東 (to the right) and runs the entire length of the island, trapping ample amounts of haze emitted by the many factories in the area (as well as pollution blown over from neighboring China).

The remainder of the flight showcased what a jewel of an island Taiwan 台灣 is—as well as the incredible scale of human activities along the coastal plains. Tainan 台南, Yúnlín 雲林, Changhua 彰化, Taichung 台中 all rolled by, invoking countless memories of adventures and experiences. I had biked the length of this beautiful isle—and now I’ve seen it from the sky too. It was a bit like watching Beyond Beauty: Taiwan From Above 看見台灣2, a fantastic documentary showcasing the natural splendor of Taiwan—as well as the industrial-scale depredations imposed upon her by the local populace.


  1. In case you’re curious I was flying Tigerair Taiwan (hence the electric orange wingtip) on a route described in my guide to cheap flights from Taiwan
  2. This should be required viewing in all public schools in Taiwan as far as I’m concerned. 

House of Success, Chiang Mai

Mere minutes after setting out to explore Chiang Mai เชียงใหม่ I stumbled upon a bizarre building in a mostly empty lot just inside the old city walls. I swear I don’t always go looking for abandoned places—sometimes they find me instead. And in this case I couldn’t very well say “no”, now could I? I walked up the stairs to take a closer look at this ostentatious ruin…

House of Success, Chiang Mai
On days like today I feel like these places find me, not the other way around.

Continue reading →

Hazy memories of Chiang Mai

I am just about to zip off to Chiang Mai เชียงใหม่ for the second time and I realized—I still haven’t shared any photos from the first time I went! The reason for this is simple: I was sick every day I was there in early 2012. I made the mistake of visiting during burning season and could hardly breathe the entire time I was there. I didn’t even know what was going on at the time, a consequence of my inexperience with extreme air pollution and the lack of a cell phone (on which I would have certainly read about it in the news as I did after returning to Bangkok กรุงเทพมหานคร) a few days later. “National Haze Crisis Declared”, the headlines read. Just my luck!

At any rate, I thought it might be interesting to dust off some of those old photos, retouch them a little, and share what little I saw of the most culturally significant city in northern Thailand ประเทศไทย before succumbing to the miasma. And here they are—a few images captured in those fleeting moments of lucidity between bouts of illness. May my next trip be much more fortunate than the last!

Wat Chedi Luang, Chiang Mai

Continue reading →

A little foreshadowing

A little foreshadowing
A little hint of Thailand along the main highway through Huatan Township.

I have been doing a fair amount of riding back and forth between Changhua City 彰化市 and Yuánlín 員林 as of late. I often take country roads, hoping to run across something interesting, but most of rural Changhua 彰化 is an unremarkable industrial wasteland.

Today I gave up on those explorations and took the main highway for a change. On the edge of Huātán 花壇, just before entering Changhua City 彰化市, I was amused to find an ordinary sheet metal building with Thailand ประเทศไทย emblazoned on the garage. This is a curious synchronicity—for I will be landing in Chiang Mai เชียงใหม่ a few days from now for a visa run. While doing the research my article about cheap flights from Taiwan I found out about Tigerair Taiwan, a new low-cost carrier offering dirt cheap flights to the land of smiles—and at USD$105 for a return flight I really couldn’t say no.

There is another reason for returning to Thailand ประเทศไทย, of course (for I almost never do anything without there being an alignment of multiple reasons). Two years ago I had a terrible time in Chiang Mai เชียงใหม่, a place that most people I know recommended highly. I happened to visit during burning season and was laid up in my hotel the entire time I was there. It didn’t help that I had just found out my girlfriend had been cheating on me—but that’s another story entirely. I mean to give it another shot and have a positive experience on my own terms, just like I did with Hong Kong 香港 last year. My operating philosophy is that the best way to overcome disappointment and adverse experiences is to try again and—hopefully—overwrite bad memories with good ones.

A brief stopover in Beigang

Běigǎng 北港 is a historic town on the riverside border between Yúnlín 雲林 and Chiayi 嘉義 in southern Taiwan 台灣. I made a brief, unplanned stopover in Beigang while riding north to Changhua 彰化 in the summer of 2014. I was only vaguely aware of Beigang’s existence, having at some point read something about Cháotiān Temple 朝天宫, one of Taiwan’s most famous Mazu 媽祖 temples, but I had a hunch that there might be more to see—and I was right! If you enjoy visiting traditional towns with a lot of history then Beigang should definitely be on your list.

Beigang tourist bridge 北港觀光大橋

Continue reading →

S2 translation, an early work of protein music

One of my hobbies is musical archaeology: sifting through the archives in search of obscure, overlooked tracks from a bygone era. This virtual crate digging occasionally turns up intriguing results though I seldom post anything about it. People don’t seem to have much time for music sharing these days—and besides, I hardly expect most people to find this stuff interesting.

Even so, I am moved to post about one track I found recently. The Shamen, if you recall, were a late 1980s/early 1990s electronica act responsible for some truly awful hit songs. Unbeknownst to me, they burst their own hype bubble at some point and started pursuing more serious musical explorations, most of which seem to have been completely overlooked and disregarded (as their fans were expecting more radio-friendly garbage and everyone else had already written them off). Anyway, in 1995 they put out an album, Axis Mutatis, that included a number of interesting works, among them this piece of DNA/protein music, in which an actual protein-coding sequence is MIDI mapped to synthesizers to produce the sounds you hear. The description by frontman Colin Angus gives more context:

The track ‘S2 Translation’ was generated from the DNA sequence and the amino acid characteristics of the S2 protein. The time signature of the piece is given by the codon: 3 base pairs per codon gives one codon per bar, hence the time signature is 3/4 or waltz time. The ‘top line melody’ comes directly from the base pair sequence itself (the bases cystosine, adenine, guanine and thymidine being mapped to the notes C, A G and E respectively) while progressions in the bass are reflective of the characteristics of the amino acids which are the result of translation. The number and nature of bass notes per codon/bar were determined by the hydrophobicity/hydrophilicity, ionic charge (positive or negative) and size of each amino acid residue (Proline, for example,which has no characteristics other than its small size, can be identified easily as the bars where the bass line ‘drops out’). The musical output resulting from these rules was further processed by mapping the notes onto different tonalities, both to make the piece more interesting, and to suggest the organisation of the protein molecule into regions of different secondary structure (although since S2 is a membrane protein and thus impossible to crystallise outside the lipid bilayer, this was definitely creative licence).

S2 is the receptor protein for 5-hydroxy tryptamine (Serotonin) and presumably for other tryptamines as well. It is thus one of the most important molecules in the mediation of both ordinary and non-ordinary (or “Shamanic”) states of consciousness, which is why the molecule was chosen for this piece.

Colin Angus

Also of interest: ProteinMusic, the Java-based software used in the production of this song, is still online. The New York Times has more about it in case you’re curious.

Colony collapse disorder and the pollinator-industrial complex

Everyone seems to be concerned about colony collapse disorder but I doubt most people know the first thing about industrial-scale beekeeping. This article is a real eye-opener—read it and see for yourself.

A historic residence in rural Changhua

A mansion in rural Puxin Township

This beautiful western-style house is located along a country road in Puxin 埔心, a rural township in the heart of Changhua 彰化, central Taiwan 台灣. It was built in 1940 by a man by the name of Huáng Yì 黃義, a wealthy employee (presumably an executive) of the Japanese colonial era Taiwan Sugar Company 台糖公司. If this government source is to be believed Huang Yi had five wives who bore him five sons—and some unknown number of daughters. No wonder he needed such a large house!

Continue reading →