Using your ISP’s built-in VPN in Japan

It’s a little known fact that the routers in Japanese ISPs are incredibly full featured when compared to the gateways you get abroad. One feature that is standard in most of them is VPN. In this post I’ll show you how I set-up my home network that allows me to access my GPU desktop from anywhere.

The first step is to look at the bottom of your router to find the default username and password. Then log in to the router which is typically the .1 address in your subnet. In my home it’s

NTT’s Hikari Router home screen

Expand the 詳細設定 (Advanced Options) menu on the left to show the VPN server settings link.

VPN Settings page

Check the 有効 checkbox to enable your VPN and take a note of the pre-shared key by clicking the 表示 button. Next make a VPN account by clicking one of the edit (編集) account slots and giving it a username and a (very strong) password.

To connect to the VPN on Mac open up the Network settings in the Setting app and click the add button to create a new network. Select VPN and choose the L2TP over IPSec type and give it a name.

Mac OS Network Settings

The Server Address is your public IP address which you can get by Googling for “Whats my IP address”

Authentication Settings

Click the Authentication Settings to enter your password and Shared Secret, click OK then Apply and you’ve finished the set-up. To test it you have to go outside your LAN but if everything is correct it’s as simple as clicking Connect.

Next would be to connect to your GPU machine. If you have a Linux machine you should be able to simply SSH into it using its local IP address. I use Windows for my desktop machine so I use Remote Desktop. You only have to enable it in the Remote Desktop Settings under System in the Settings Window like so:

If you use Jupiter (which I don’t) you can start it up and log into it via your browser as long as you’ve set the listen address to so that it accepts remote connections.

How Cappuccino handles pass-by-reference APIs in Cocoa.

I’ve been using Cappuccino at work recently and I came across a corner of Objective-J that I previously didn’t know about: how to use enumerateObjectsUsingBlock.

One of the nice things about Objective-C is that it has blocks.  Blocks allow you to make functions that take other functions as arguments, all while preserving scope. One of the most popular block-using APIs is the NSArray method enumerateObjectsUsingBlock. It takes a block that has three arguments: the current value of the iteration, the current index and a reference to a Boolean stop variable. If you set the variable to YES the loop will stop (much like the break keyword, which only works to break out of while and for loops.)

This is a problem for JavaScript because it always passes by value. Since it’s very cheap to create objects in JavaScript you could just pass an object with a property you can set, but that means that you have to remember the property name to set and the caller has to remember to copy that value back out. The Cappuccino developers thought of using a function that closes over an object in the parent scope via a macro called AT_REF.

To use a cappuccino AT_REF you simply call it and pass in the new value you want to set. Like so:

[array enumerateObjectsUsingBlock:function (item, i, stop) { 

In the implementation of enumerateObjectsUsingBlock you’ll see something like the following:

var stop = NO; 
for (var i = 0; i < length; i++) { 
    block(arr[i], i, BY_REF(stop)); 
    if (stop) 

The AT_REF macro expands to something like:

(function(val) { 
    if (arguments.length) 
        return (stop = val); 
    return val; 

That way you can both set the value by calling it with an argument and get the value by calling it with no arguments.

It’s brilliant if you ask me. But then again, pretty obvious when you think about it.

In the future the devs would like to integrate this into the language by using @ref() and @deref(), (hence the name of the macro).

To define methods that use AT_REF in your own code you can simply @import <Foundation/Ref.h>.  Clients of your API just need to know to call the argument to set and get it’s value.

Apple’s JIS Keyboard layout and the ADM3A

A few weeks ago a blog post on showed pictures of the old terminal that Bill Joy used when he created VI.  Terminals back then didn’t have arrow keys so if you wanted to move the cursor around you held down some kind of modifier and hit the H, J, K or L keys.  And they were labeled as such.  This news didn’t really interest me because I’ve read that somewhere before but when someone on my twitter stream posted a picture of the keyboard I noticed how much it resembles my Mac’s keyboard layout.

Since I live in Japan I use a Mac with a Japanese keyboard layout. The standard Japanese keyboard layout is a little hard to get used to at first because while it is a QWERTY keyboard some characters are in different places.  The placing of the double quote character and the left and right parenthesis eventually grew on me, but I always had a nagging feeling that the Japanese keyboard arbitrarily changed the locations of these very important for programming keys for no good reason.

When I saw the keyboard layout of the ADM3A I realized that it was in fact kind of the opposite.  The US keyboard layout has changed significantly since the 70s, but the Japanese keyboard didn’t.  Apple even keeps the position of the CTRL key where it should be (To the left of A).

The legendary ADM3A keyboard layout. (credit. Wikipedia)

The Apple Japanese keyboard. The Standard Japanese Keyboard layout has the exact same number row keys as the ADM3A.







I think this might be one of the reasons that I’ve grown to like the Japanese keyboard layout.