Garfield Nate

Big Fat Hairy Programmer

Japan Is a Great Place to Be

| Comments

So, it happened again: you meet up with some gaijin friends, and it turns into a big Japan-bashing fest. Every thing that’s been bugging them for the past several months comes flooding out, and the back-and-forth between gaijin experiencing similar issues brings the criticism to an uncomfortable peak. The evening has become less of pleasurable conversation and more of a giant therapy session.

To be sure, living in a foreign country, even a 1st world country, can be a frustrating experience. Technology followed a slightly different path of advancement, and you find yourself loving convenience stores and pay-by-phone vending machines but hating the lack of insulation. Being a foreigner, you have to jump through extra hoops to do basic things like getting an apartment, opening a bank account, or getting a job. And with such a different culture, you find yourself unsure of when to be insulted or to laugh, how to make a joke instead of insulting, or how to correctly navigate a myriad of other “simple” social situations.

But there’s a reason my wife and I live in Japan: it happens to be an awesome place to live. To my gaijin friends having trouble getting settled, here’s why you should be happy to be here.

  1. Food. Food in the US may seem great because you grew up with it. I happen to miss decadent ice cream and peanut butter M&M’s, big steaks and bacon cheeseburgers. However, we’re all fat and sick because of the way we eat, and we have no idea how to change. The problem we have is that we don’t make our own food from fresh ingredients. Every fruit and vegetable at most supermarkets was bred to ship well and has sat in a silo for a year, and thus tastes horrible. Americans think “healthy” is a cuisine that sacrifices happiness for the good of their bodies. This is all wrong. America, unfortunately, has no cuisine, and makes up for it in quantity. Japanese cuisine is tasty and good for you, and when you really want a sweet-tooth fix, there’s plenty of chocolate at the convenience store and high-quality sweets at the bakery. Japanese people just don’t eat as much of it because they can feel satisfied after eating a good meal. So go buy some mikan and eat a few after your meal. You might not need a candy bar after that. P.S. Good restaurant food in the US is often very expensive, especially after tipping. Good restaurants in in Japan are generally decently priced and you don’t have to worry about the tip.
  2. Transportation. Yes, in the US most families have two cars. But you have to have a car to go anywhere. Personally, I find that prohibitively expensive and rather inconvenient. I’ve never owned a car in my life, and in Japan I can finally go anywhere I want. I’m saved the expense and inconvenience of random break-downs, and I don’t have to worry about gas prices. Trains are often faster, too!
  3. Peace. I don’t just mean that Japan doesn’t go to war; I mean that individuals are polite and don’t argue over things simply for the sake of “having an opinion”.

{begin rant}

Living in a foreign country really provides the perspective that you need to understand your own culture. I understand that Facebook might not be a good representative of an average day of conversation in the US, but it is still quite disconcerting to have your feed filled with raging of all sorts. The funny thing is that the raging comes in waves regarding particular trending topics, so that most individuals who think they are being righteous and counter-culture are really just caught up in the flow of raging. The most American thing seems to be to have an opinion and to duel with words, intelligent or not.

On top of that, in US culture we always seem to need a villain and a hero: this is reflected in every movie that comes out of Hollywood (which I do enjoy), and it is reflected constantly in political rhetoric. People blame the hicks or the rich, the Evangelicals or the gays, the politicians or the immigrants. And of course the politician playing the blame game makes themselves out to be the hero.

{end rant}

If any of this ever stresses you out (hello there, introverts and Seattleites), Japan will be a welcome change. Controversial topics are avoided in normal conversation because contention is a Bad Thing. We can leave it to its proper time and place, where it is actually required to find a solution to an immediate problem. Japan is a nation state and they place great importance on being united, trusting eachother, and showing consideration for the feelings of others.

So there you have it: in Japan I have good food and health, freedom, and peace of mind. What more could anyone ask for? You can still have your Snicker’s bar, you just have to bike to 7-Eleven to get it.

Now, I understand there are exceptions to every rule, and that there is a giant barrier to getting to this point: getting used to Japan and learning to speak Japanese. I may post on these another time.

My Dream Planner, Come True, Almost

| Comments

I say almost because I haven’t printed it yet. But I have a PDF!

When I was in college I had a favorite planner. It was the perfect size for my hand, and just had lines for each day, with one week visible in a two-page spread. It had a space in the front for schedules, and some blank pages in the back for notes and adresses. Nice and simple. I looked forward to buying it every year, and the last one I bought I also laminated and rebound so it would last longer.

Now that I’m not at BYU, though, I can’t get that planner. I can’t even buy it on the bookstore website, gosh darn it. So I took the opportunity to try a different technology out and make my own, hopefully this time my dream planner.

What makes it my dream planner? Well, let me tell you! It has graph paper note pages. That would have been nice when I was thinking about lattices all the time for analogical modeling. Best of all, it comes with both Japanese and American holidays, so I can know what’s going on in both of my home countries. It’s even got birthdays and my wedding aniversary, so I have no excuse to forget! I also gave the covers a personal touch: a mario star on the front, and a Garfield on the back!

What’s this “different” technology I tried out, you ask? It’s HTML/CSS. I know, it’s not that different, but it was new to me, and it turned out to be pretty difficult to make a nice, printable document with CSS that worked in any one browser. This was an unfortunate finding, because after my honor’s thesis I’m burned out on LaTeX.

The entries of the planner, though, are generated using Perl and a bunch of CPAN. This was mostly fine. I used the very simple XML::Writer for HTML generation, but for date handling I had to use a combination of Date::Simple, Date::Calendar, Calendar::Japanese::Holiday, and Calendar. Date::Simple gave me a quick way to cycle through all of the days in a year. $date++ is the next day. Pretty simple, as the name implies. To handle holiday lookup, I needed Date::Calendar. This gives me the date of Easter, as well as letting me specify holidays with changing dates, like Mother’s Day. Calendar::Japanese::Holiday gave me Japanese holidays, which I didn’t feel like specifying in Date::Calendar and keeping track of myself, especially since they might change (“Mountain Day” is a new holiday starting next year, for example).

The last one, Calendar, I used because it came with a Chinese calendar and I wanted to know when to mark 十五夜 (juugoya, fifteenth night), or 月見 (tsukimi, moon viewing) on the calendar. That’s one that you can’t really do tsuki-okure with. The conversion wasn’t straight-forward, but I came up with this for giving me the best Gregorian calendar day for looking at the moon and eating rice cakes:

my $year = 2015;
# start with any date near the middle of the year just to initialize
# the Chinese cycle/year correctly
my $temp_date = Calendar->new_from_Gregorian(7, 1, $year);
# get tsukimi date from cycle and year found above, and date 8/15
my $tsukimi = Calendar->new_from_China(-cycle => $temp_date->cycle, -year => $temp_date->year, -month => 8, -day => 15);
print "Schedule moon-viewing party for $year/" . $tsukimi->month . '/' . $tsukimi->day;

And of course I marked this in my planner with the emoji for moon viewing ceremony: 🎑.

Modules added to my wish list (or find list, if they already exist):

* an emoji converter that would take :bear:, :corn:, etc. and give back either the unicode character or code point.
* Calendar module that allows specifying holidays in different calendars. For example, specifying that tsukimi is on 8/15 in the Chinese calendar, and being able to check whether a day matches regardless of what calendar the day was created with. My trick above worked for tsukimi, but further gymnastics would be required for the new year, since there might be more than one in a Gregorian year.

I’ll cover my CSS woes another time.

Hacking Through an Octopress Update

| Comments

A while back I watched a neat presentation from Justin Searls called The Social Coding Contract. He has lots of good things to say, but there was one comment that really hit home: my Jekyll blog was easy to setup 6 months ago, but now it’s impossible to maintain. Heh. Most of my trouble could have been avoided with more careful management of dependencies, but alas I am not a Ruby person and I did not realize that bundle update would completely sink my publishing abilities for 4 months. When I update Perl modules, cpan runs their tests on my machine and refuses to install unless they pass. bundle just installs them!

I think I ran into every possible problem, which was actually a good learning experience. Like uncle said, that’s what I get for using Windows! Some of the problems were my being a noob, and others were problems with various ruby modules. Honestly I don’t think that anyone with this many problems should even be using the platform, but gosh darnit I wanted it to work. And while I was at it, I updated to Octopress 3.0, which I believe will be much more manageable (I can freeze the gem version, instead of having to track Git commits). Here’s to the next person struggling with Octopress or Jekyll on Windows:


  • jekyll serve exits silently
    • See
    • Solve by specifying gem 'listen', '2.7.8' in your Gemfile. I tried 2.7.6 first, but ran into other problems.
    • Don’t forget to delete Gemfile.lock when changing your gem versions
  • Build Warning: Layout 'nil' requested in atom.xml does not exist
    • The layout specified in the YAML front matter in the given file apparently says nil, meaning don’t use any template in the _layouts folder.
    • The correct way to specify it is null
  • When trying to install Pygments you get LookupError: unknown encoding: cp65001
    • Python doesn’t normally accept cp65001 as utf-8, but they’re close enough, probably
    • Do set PYTHONIOENCODING=utf-8 before running python -m pip install pygments; if that doesn’t work (it broke for me on a Japanese computer), set the code page to ascii via chcp 437 instead.
  • Error: undefined method '[]' for nil:NilClass in pygments_code.rb
  • celluloid/calls.rb:48:in 'check': wrong number of arguments (2 for 1) (ArgumentError)
  • When you run octopress deploy, you get error : src refspec master doesn't match any
    • In my case, I had deployed once with the wrong branch name was trying to redeploy to the correct branch. The result of a deploy is cached and currently the branch is not changed properly.
    • Fix the problem by deleting .deploy and redeploying
    • See
  • octopress deploy does not first run a build; you must do jekyll build first.
  • octopress new draft Title, etc. gives cannot load such file: octopress/draft.
    • I don’t know why this is happening yet
    • For now the fix is to run bundle exec octopress new draft Title
    • See
    • “Such file” is a very Japanese expression, by the way: そのようなファイル
  • linklog entries don’t work properly (I don’t think they ever have).
  • Regenerating appears to take forever, so I just have to restart every time. That’s annoying. Unfortunately I don’t currently have any solution to that. It’s also not a show-stopper.

After smoothing out all of the real errors, the (currently) permanent workarounds I need are 1) to set MENTOS_TIMEOUT to a large number and 2) to run commands with bundle exec.

Hope this helps!

Notes on Writing a Syntax Highlighter for Sublime Text

| Comments

I recently released the Soar Tools package for Sublime Text, and I took a few notes that might help the next author. Sublime Text is pretty awesome in a lot of ways, but the documentation is more tutorial + forums than it is a thorough explanation. I mainly followed the directions here. My tips are as follows:

  • Don’t try to copy that BNF grammar into tmLanguage format. It’s not designed for specifying grammars, it’s designed for highlighting. That means that it’s robust and will highlight while you’re typing instead of waiting until you have a compilable program to highlight. This is a big advantage, especially for Soar, where there’s a lot of typing to get a production sourcable. Instead of making a fully recursive grammar, pick out the few big areas that should be treated differently, such as the inside of a class or other curly-braced section, and detect them in the main patterns list, parsing the insides with patterns in the repository.
  • Be careful about the YAML syntax. It looks simple, but you can mess it up easily. For example, paterns is the ONLY item that takes an array for a child. That means that you should have

      - comment:...

    but no other keyword will have a child starting with a dash (-).

  • You need to write the rules in order of application. No two rules will apply to the same section of text, so it’s first come, first served. For example, you can’t match a JavaDoc comment block starting with /** in one rule and then match @arg, etc. in a separate rule. The proper way to do that is to use a begin/end rule with a nested patterns section. Put quoted strings first, and then comments. That way `“this is a //string”`` doesn’t turn into half-string, half-comment.

  • Regexes are for the most part Perly; lookahead ((?!xyz))works, but I haven’t tested other look-arounds. One gotcha to keep in mind is that * and + do not match greedily, unlike Perl.
  • include: sections must be inside patterns: sections.
  • You’ll do lots of re-loading and restarting. An error box popped up saying something strange when you converted/saved the grammar? Restart sublime after trying a fix. If you get a fail message when Sublime reloads, then you didn’t fix it and you need to try again, with another restart. Highlighting will not work at all until you’ve done a restart with it working. (This has apparently been improved in build 3068, but I don’t have access as a trial user.) You changed something in one syntax file that’s included in the rule of another? Compile/save both grammars (compile meaning turn your YAML into plist XML).

I hope this saves the next developer some time. Overall, the biggest gotcha for me was just realizing that I wasn’t writing a BNF-style grammar to completely validate the syntax in a file, but a list of patterns and the scopes that they create or match in. Once I understood this, actually writing the rules was not too difficult a task.

My New Toy: Algomation

| Comments

Lately I’ve been losing sleep trying to understand an algorithm I read about in an academic publication. Part of the problem was that the application I was applying it to required a sort of reversal, which was confusing. But a bigger part of the problem was that I just couldn’t “see” it. I’d lay in bed, trying to imagine working with ping-pong balls on a string, or marbles on fishing line, or anything I could really get my “mind’s hands” on.

A few days ago I thought to myself, “there has to be a better way; there has to be a tool to help me do this.” In my life time I’ve done very little visual work, all of it bad, and I know I can’t be alone. But after taking Robert Sedgewick’s algorithms course and seeing all of the lovely visualizations from his lab, I knew there must be tools out there for visualizing algorithms, at least for educational use. Surprisingly, I didn’t find too many quick ways to do this, but one recently created service fit the bill.

It’s called Algomation. Lots of algorithms are available just for viewing on the home page. Each algorithm gets a viewing window for whatever visualization is provided, and the user can rewind as needed. A handy info box on the side gives information on the current operation, variables, and even code location. The visualizations themselves look very nice.

Once you’re registered, you can create new algorithms or fork from others' creations. Here’s mine:

Granted, this is a little rough around the edges (and I have used the heck out of the feedback form); however, this is way better than imagining ping-pong balls on a string, and now I really understand how AddIntent works. The service is still young, and I have high hopes for this becoming an expansive library of algorithm visualizations.

Here’s my wishlist (in no particular order):

What’s on your wishlist?

The Oh So Exotic Grocery List

| Comments

Since Erika is working and I am not, I try to take care of the apartment by shopping for food, cleaning and cooking as much as possible. I wrote out a list of everything that was needed and headed to Hallow’s to do the week’s shopping.

While I was picking out some tofu for mabodofu, two little 7 or 8-year-old girls ran up to me and started talking excitedly. I felt a little weird; a grown man talking to little girls at the super market might be considered a little creepy in the US. They asked me if I would be their friend and I thought “what the heck, sure, we’re friends” thinking that would be the end of it. They ran off excitedly and I resumed my shopping.

As I was looking at chahan (fried rice) mixes they ran up again. I think they were playing tag but became distracted by my foreign-ness. They asked what my terribly scribbled shopping list was, and I told them it was just a list. They were excited to see something so exotic, and ran off to play some more tag.

Then, when I was looking at soy sauce, they ran up with another little girl to introduce us. This girl was more shy. They told her, “watch! he’s SOOO good”, and then turned to me and said “say it!”. “Say what?” “English.” “What English?” She was a little frustrated that I didn’t know what she was talking about, and she stuck her finger into my shopping list. “This English!” “Oh, oh, uh, sure. Ahem. Sour cream. Olive oil. Chicken Thighs…” This elicited impressed squeals from the girls. “Wow! He’s so good!” They than ran off again.

They came back again later to ask me how to say “hide and seek”, which they could not pronounce, so I gave it to them again in katakana-English (haido ando shiiku). They knew cat and dog, though. They came back one final time when I was looking at onions to asked me the darndest question. “Hey, um, sensei [they assumed that because I was a foreigner that I was an English teacher], how did you get SOOO good at English?” This caused me to laugh heartily. I explained to them that I spoke English as a child, as did my family, and I didn’t learn Japanese until I was 20. This elicited only puzzled looks from them. English is so hard; why wouldn’t you just speak Japanese? They obviously learned English without learning about other countries in school. They then ran off again to continue their game of かくれんぼう (kakurenbou).


| Comments

I haven’t written as much lately as I should have, so here are some things that happened in August.

The most important Kasaoka event in August was the Yotchare festival. Summer in Japan is when most of the festivities happen, and students get August off of school. Kasaoka has a parade where everyone dances the Yotchare, or their choreographed version of it. A thousand people gathered on main street, and 30-40 groups danced down the street. A camera crew from the local Kasaoka TV station was there.

Erika and I had originally planned on participating with KIEA (the international organization in town), but we didn’t make it to the practices. We drove downtown with Misao’s family and walked along the street watching the performances. Misao took us to the back of the parade where the groups start, and suddenly we were pushed out with the rest of the members from KIEA and had to figure out the dance, while of course being recorded and broadcasted live. Misao was nice enough to lend Erika a kimono for the event, but I was especially embarassed because I was wearing a junkie t-shirt, cargo shorts, and my sandals with holes in them (as if being tall and blonde don’t make me stand out enough!). Most of the rest of the group were wearing either a nice kimono or nice traditional dress from their country (looked mostly like India or Thailand?). We did manage to figure out the dance, though, and the KIEA group won the 一生懸命で賞, or the “you did it with all your might” prize!

There are some other cool pictures online. This one from facebook shows some people dressed as Ebisu, the god of commerce, and some in Kabuni suits (the local mascot is Kabuni, a cartoon horseshoe crab).

Weeks later, some people who meet me for the first time still say “oh yeah, you were in the parade!”

“Yotchare”, by the way, means “welcome” in the local dialect.

Later in the month was the annual fireworks festival, done in every city across Japan around the same time. This event is also attended by many wearing kimono and geta. They actually distributed a complete program for the show, describing the size of every firework that was to be ignited every minute of the show, and who paid for it. I had to make a quick trip back to the apartment because I forgot my earplugs!

Bentley took me on a long bike ride to Asakuchi. It has a nice beach and an interesting formation of three islands:

The view from Yorishima park is also amazing, if you can get there:

Erika and I went back to eat at the cafe and take pictures later:

We celebrated Misao’s birthday at her daughter, Sayo’s, house:

That was particularly fun because we had somen in one of these enclosed river things (picture on Amazon). Traditionally the noodles are sent down a long bamboo pipe and whoever wants some plucks it out. This thing uses a pump to send the noodles around in circles until someone wants some. Neat! You get a thousand points if you can manage to grab a cherry tomato from the stream using chopsticks.

We went to eat Indian food in Fukuyama, and on the way found a super nice library. They have this neat water-themed architecture:

The other side of the building has a waterfall staircase parallel with the regular staircase, but I couldn’t get a good picture.

Also, a random picture from Fukuyama for my fire-fighting uncle:

The decorations on the manholes/fire hydrants are different in every town and lots of them are painted like this one. Just one of the many ways Japanese people give their towns character.

Lastly, we got a new bookshelf for our apartment! We love it. Hopefully, carrying it home in the rain will be the most dangerous thing I ever do in Japan!

Knuth Classics Are Freely Available

| Comments

Donald Knuth wrote TeX in C/WEB. WEB is his system for writing literate programs which become both source code and typeset documents explaining the program’s operation. Some of his programs have been published: TeX: The Program and Metafont: The Program. Others have not: I don’t believe Bibtex was published in book form, for example.

All of these works are available online, though you have to generate the PDF yourself. The TeX live distribution (included in MikTeX, among others) comes with Knuth’s WEB system for doing this. If you want a copy of TeX: The Program and you have TeX live, you can download some WEB programs from and convert them yourselves. Let’s do TeX as an example. Download tex.web and Then do this:

weave tex.web tex.tex
pdftex tex.tex

Voila! One Knuth classic ready for reading. weave was available on my path because I have MikTeX installed on my computer. I did hit one snag- the first time I downloaded one of these files, I viewed it in the browser and then copied and pasted the entire thing into a text editor and saved it. This turned all of the newlines into Windows-style CRLF’s, and weave would die with the unhelpful message, read operation failed. The WEB system only works with Unix-style newlines, so make sure you download the file as-is if you are on Windows. The change file is also required for whatever reason, so if you don’t want it, just create a dummy change file containing % (a single empty comment).

Overall I’m pretty happy that it was so easy to generate these documents from such old sources. I wonder how difficult it will be to build the executables.

Available programs:

  • bibtex
  • dvicopy
  • dvitype
  • gftodvi
  • gftopk
  • gftype
  • mf (Metafont)
  • mft (older Metafont?)
  • patgen
  • pktogf
  • pktype
  • pltotf
  • pooltype
  • tangle
  • weave

Five Things We Need to Know About Technological Change

| Comments

Niel Postman: Five Things We Need to Know About Technological Change

To a man with a hammer, everything looks like a nail. We may extend that truism:… To a person with a computer, everything looks like data… every technology has a prejudice. Like language itself, it predisposes us to favor and value certain perspectives and accomplishments. In a culture without writing, human memory is of the greatest importance, as are the proverbs, sayings and songs which contain the accumulated oral wisdom of centuries. That is why Solomon was thought to be the wisest of men. In Kings I we are told he knew 3,000 proverbs. But in a culture with writing, such feats of memory are considered a waste of time, and proverbs are merely irrelevant fancies. The writing person favors logical organization and systematic analysis, not proverbs. The telegraphic person values speed, not introspection. The television person values immediacy, not history. And computer people, what shall we say of them? Perhaps we can say that the computer person values information, not knowledge, certainly not wisdom. Indeed, in the computer age, the concept of wisdom may vanish altogether.

I can’t help but feel he hit the nail on the head in helping me spot my own concerns about how I use computers or even books now. It reminds me of a quote from The High Beta Rich saying that rich people who spend lavishly end up not being able to get out of bed in the morning without $250,000. Because we are so rich in information, we end up craving it and becoming slave to it, instead of learning to accomplish more with less. We need to use information to better ourselves instead of just hoarding it or showering in it.

Another bias introduced by modern computers is multitasking. The machine multitasks, so we also multitask constantly. It’s not good for concentration or productivity (becomes self conscious and switches to editor’s distraction-free mode).

Schools Kill Creativity

| Comments

Ken Robinson Says Schools Kill Creativity

First post of my new linklog; I’ll be writing responses to articles from BYU’s CS 404.

There’s another reason schools kill creativity in my opinion: by killing intrinsic motivation. The worst culprit is literature class. I did honors/AP all through high school, and haven’t read a classic since (except Ender’s Game, which is a rather new classic). Who wants to read anything when it’s just required reading to make the grade? Kids should learn to enjoy good works of mankind because they are enriching, instead of just developing an aversion to requirements of “the system”. Sudbury Schools look nice. No classes!