Saturday, January 06, 2018

Introducing the Yollar

Seems like new currencies are everywhere these days. This one isn't new, it's a just a new name for something that already exists. Recently I've been using 1 Yollar to mean 100 Japanese Yen. If you moved to Japan from the US or the EU, you probably still think about money in terms of something around the value of a USD or EUR and are a bit confused by dealing with so many zeros when talking about Yen (quick now, is 500,000 Yen for a car cheap or expensive?). Do you sometimes say "60 dollars" when something costs 6000 Yen? Does the person listening know whether you actually meant exactly 6000 Yen or whether it was actually 60 USD and so need to multiply by 110 to get Yen. The Yollar removes any confusion, 60 Yollars is 6000 Yen.

This unit was already floating around in your head, you just didn't have a name for it. Now you do.

Saturday, November 11, 2017

Adding remote-control keys to a Keygal door

My house has remote control keys (as well as regular keys). It's very convenient, I have no idea how secure it is. Anyway, I lost one of the keys and bought a new one and had some trouble following the Japanese instructions. I got it eventually, so here's the procedure.

First note, you can't just add a key, you have to wipe the system and add all of your keys back in one go.

The original Japanese docs are here and here. That'll make it clear how to get access to the register/clear button for you lock.

So, here's the procedure, I'm not exactly sure that all parts are necessary but this worked (you might want someone else around to do the press-and-hold part. Apparently you have 20s to do it all. I don't know how strict that is.

  1. Put one of the metal keys in your pocket - you wouldn't want to lock yourself out!
  2. Open the door.
  3. Twist both the top and bottom cyclinder closed and then open again. I suspect this isn't necessary but it's no harm.
  4. Remove the cover at the top of the top cylinder.
  5. Press the register/clear button for 5 seconds, until it makes a long beep sound. You have cleared all the keys off the lock, none of your remove control keys work now.
  6. Press and hold the register/clear button, keep holding it while you do the next steps.
  7. Take your first key and press lock then unlock then lock and unlock again. You should hear short beeps for these presses (I'm not 100% sure that I heard a beep for each one but definitely for the first lock press).
  8. Now take each of your next keys and press lock then unlock. Unlike the first key, you only need to do it once per key.
  9. Let go of your register/clear button.
  10. Put the cover back on the top of the top lock.

You can watch this video too. It's for a different model but gives a clear idea of the registration method.

Friday, August 25, 2017

Women in tech and James Damore's diversity memo

I work for Google, the following is purely my personal opinion.

I wanted to say something about James Damore’s now-famous diversity memo. I didn’t post sooner as I haven’t had much free time and it requires care. It requires care because it's very easy to read his doc as an innocent attempt to have a discussion and to see him as the victim of a liberal conspiracy. I don't believe either of those to be true. Luckily many people have already written a great deal that I agree with and I will be mostly just refer to them.

There are a bunch of issues.

Is his science correct?

I’d guess some of it is but he has been so selective that it doesn’t really matter. See [Sadedin], [Giglio] (very detailed) and [Economist] who talk about specific studies and also the cherry picking.

Is his argument valid?

I can't find an actual argument in his doc, he just lists off some alleged differences and states that they may be factors in the gender gap. He makes no effort to show that biology is more important than society or that it's significant at all. His doc doesn't prove that the current 80-20 split in tech is natural any more than the 100-0 split in science in 1800. We have had 1000s of years of institutionalized sexism and while he suggests other causes, he provides no reason to think that they matter in comparison to the well-known social problems.

Wasn’t he talking about preference, not ability?

He writes, “I’m simply stating that the distribution of preferences and abilities of men and women differ in part due to biological causes and that these differences may explain why we don’t see equal representation of women in tech”. So he was definitely talking about ability, although he did a good job making it seem like he wasn’t.

In my mind, preference and ability are highly related. Much of my ability comes from my preference and vice-versa. It's easier to study something you like, you'll like things you're good at. Given two candidates of equal ability, I would choose the one who likes doing the job. Talking about preference just seems like a coded way of talking about ability while maintaining plausible deniability.

Wasn’t he talking about populations, not attacking the women who were already hired by Google?

Negatively stereotyping a group is an attack on every individual in that group, including those who don't fit the stereotype. If the stereotype is accepted then every woman has to prove that they are not stereotypical to every new employer, manager, colleague etc, meanwhile men get a free pass. Allowing these ideas to stand unchallenged makes life harder for every woman interested in tech, propagating these ideas is an attack on every woman interested in tech.

Was he starting a discussion in good-faith?

I don’t think so. The doc does a great job of sounding reasonable but implies things (e.g. that biology is a significant factor) that it really does not justify (see above). Also you would have to be fool to think that a doc like that would lead to a productive discussion. It is chock-full of direct and indirect attacks on women’s ability and right to work in tech. There’s no need to do any of that if you just want to raise issues with diversity programs. Interestingly, according to [Gable Brown] he comes from a highschool where this kind of trolling-disguised-as-reasonable-argument was widely understood. It was practiced as a sport by some. In their forums, she says that they are discussing his use of well known techniques. It seems unlikely that he would then accidentally deploy those techniques.

Even if the memo raised some legitimate points, it is fundamentally tainted. If you drop a turd into a swimming pool, don't be surprised when nobody wants to race you and you're kicked out of the pool. It doesn't mean you're an awesome swimmer and everyone is afraid to race you. In this case, the pool was about 90% turd.

Can’t we just have this honest conversation?

I think you should be tied up in a sack and thrown in the river. I’m sure neither of us are 100% right but I had a sack tailored to fit you. Maybe you should at least be tied up in it, we can see what happens after that. Anyway, can't we just have this honest conversation? Just have it again and again until hopefully some day you get into the sack? Is this some kind of ideological echo chamber where we can’t have an open, honest discussion about whether I should tie you up in a sack and throw you in the river? Free speech! I’m being oppressed!

As [Danger] points out, some ideas (like “this group of employees is inherently less fit for their role”) cause happen just by being debated openly. Just having the conversation is an existential threat to that group. That doesn't mean they can never be debated but you have to take responsibility for the harm if you do.

Is Google a place where people can express unpopular or conservative opinions safely?

I think so, but I guess I’m part of the dominant ideology. Expressing any view carelessly in Google is a bad idea. There are experts in all sorts of fields who will pop up and correct you. There is definitely a liberal bias but as Stephen Colbert said, reality has a well-known liberal bias. Specifically, reality is constantly changing, it doesn’t care how things used to be, and it doesn’t care what some book or some old white guy says. This makes conservative opinions particularly tricky. They are, by definition, about keeping things how they used to be. They are often justified by appeals to how things used to be, a book or some old white guy. That's really not going to help you at Google.

If you want to express the view that some group of people should continue to have a shitty time just like they had in the good old days or that some other group of people should continue to enjoy privilege they haven’t earned, then you’re going to have a bad time. You are not simply offending people, you are attacking them. The spread of your opinion causes direct harm to them in their work and/or personal lives.

If you don't understand the very real impact of your words, the reaction may feel like an attack. You're not being attacked (hopefully), you're just being asked to try to see things from a perspective you would not normally. This can be very uncomfortable. Accepting this perspective may require admitting you've been a jerk for years (hopefully without knowing it) or becoming conscious of an unearned privilege (and not taking advantage of it going forward). If you already feel like you're just barely scraping by (it turns out that many people, even in good jobs, feel this way, it's called “imposter syndrome”) then giving up some of your advantages will feel quite threatening.

If you expressed a poorly thought out liberal/left-wing view at Google you would also have a bunch of people tell you why you're wrong. What you probably won't have is a bunch of people taking it as an attack against them. This is because the conservative view is (almost by definition) the establishment view and attacks against the establishment are usually easy to shrug off. If someone published a doc on why men make inferior engineers, I doubt anyone would feel the need to take it apart line by line. This opinion is not a incessant, real threat to men. Diversity programs and un-biasing training on the other hand are an emerging threat and as we see, result in strong reactions.

Other responses

I also recommend reading [Lee] and [Wojcicki] for examples of what women deal with every day.


Sunday, February 26, 2017

Getting a steam game to work on ubuntu 16.10

I bought the Humble Bundle Freedom Bundle (supporting the EFF). Before now, I had never used Steam. The install was pretty painless and some games worked just fine but some didn't (e.g. Ninja Pizza Girl). Not only did they not work but they just failed silently which is pretty crappy.
After some poking around, I found this guide, most of which did nothing but the last few commands

triggered installing some missing items

and now the game runs. I don't know which of these actually fixed it.
This is a pretty awful user experience. There was no indication what was failing or what was needed. Steam's site has no documentation that I can find on getting things working well on Linux and most of the guides I found were telling me to install packages that I already had.

Sunday, November 13, 2016

Trump's America

Shaun King's twitter compilation of nationalistic, racist assaults, abuse and general bad behaviour is horrific. The volume of incidents is remarkable. It seems pretty hard to make the case that Trump is to blame. He's a terrible person but he didn't create this, he just revealed it and in the long-run he may have done the US a favour. His election forces prosperous liberals to realize that previous victories in the "culture wars" were won and maintained by force (force of wealth, control of key assets like media and major pieces of internet infrastructure). The enemy was beaten and silenced but they were not persuaded, assimilated or brought inside the tent.

Just like you can't bomb away terrorism, you can't legislate, berate and shame away racism and bigotry. They both have deeper underlying causes that have to be tackled. I imagine they have also common underlying causes - hopelessness, alienation, seeing others prosper unjustly (in reality or just in your perception), seeing no path to prosperity inside the rules, for you or your family. Even when the rewards are trivial and the teams picked randomly, people display irrational biases for their team vs others. Humans are instinctive racists and bigots, suppressing that takes energy, motivation, thoughtfulness, generosity and other things that are in short supply for many people having a hard time.

Solving the problem requires addressing the underlying causes. Anything else is just suppressing the problem. It will still be there, seething under the surface, waiting for a chance to come out again, possibly in an even worse form.

Of course Trump and the republican party's policies over the next 4 years are probably just going to make life worse for both his supporters and his opponents, so there's the very real possibility that things will get a lot worse before they get better but a Hillary victory that allowed the left to continue ignoring Trump's supporters for 4 more years wouldn't necessarily be a better long-term result.

Saturday, April 16, 2016

Cause and effect

We went to Batman Vs Superman, we also watched Mystery Men a few weeks ago. Awesome conversation with my son Sean:

S: Why is he wearing glasses? Superman doesn't need glasses.
Me: When he's Clark Kent, he wears glasses so people don't think he's Superman.
S: ... Like Captain Amazing.
Me: Yes, just like Captain Amazing :)

Friday, January 08, 2016

(Another) Solution: Writting year as sums of runs of numbers

The solution of just grinding out of the algebra is fine but it's a bit dull and unintuitive. We can use the discussion at the end of the last post to produce a simple proof with almost no algebra.

What we're going to prove is that the number of sequences of consecutive integers that sum to \(Y\) is equal to twice the number of odd divisors of \(Y\).

First off note that if the sum is positive, then there must be more positive numbers in the sequence than negatives. I'm going to assume it's positive, if it's negative then the procedure works, just with the signs changed.

Next, note that the solutions to the problem always come in pairs. Every sequence of even length has a corresponding sequence of odd length. You can construct one from the other as follows.

If 0 appears in the sequence then you cancel every negative number with it's opposite positive number and remove the zero. Every time you cancel a \(-\) with a \(+\) you remove 2 elements from the sequence, so it stays odd or even. Finally removing the 0 flips from odd to even or vice versa. E.g. $$ -3 + -2 + -1 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 $$ becomes $$ 4 + 5 + 6 + 7 $$ 2 slightly non-obvious cases of this are sequences beginning with 0 or 1. They have no negative elements, so you just either add or remove 0 at the start.

Conversely if the sequence does not contain 0, prepend all the numbers from 0 up to the start of the sequence and also prepend their negatives. This does not change the sum but it flips the length from even to odd or vice versa. E.g. $$ 4 + 5 + 6 + 7 $$ becomes $$ -3 + -2 + -1 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 $$

So now we just consider the solutions of odd length. If we can show that there is exactly one of those for every odd divisor of \(Y\), we're done. That turns out to be fairly easy.

First, lets say you have an odd length sequence that sums to \(Y\). Since it's odd-length, it must have a middle number, let's say \(n\) and then there are \(k\) numbers before and \(k\) numbers after. The befores and afters go together in pairs. \(n-1\) with \(n+1\), \(n-2\) with \(n+2\) etc. Each of these pairs sums to \(2n\) and there are \(k\) pairs plus a lone \(n\) from the middle giving a total of \((2k+1)n\). So we have that \(Y=(2k+1)d\) and so \(2k+1\) (the length of the sequence) must be an odd divisor of \(Y\). So this shows that any sequence that sums to Y leads to a specific odd divisor of Y.

Conversely given an odd divisor of \(Y\), \(2k+1\) and we set \(n = Y/(2k+1)\) then the sequence of length \(2k+1\) centred on on \(n\) sums to \(Y\). So every odd divisor leads to a sequence of odd-length and we're done.

Sunday, January 03, 2016

Solution: Writting year as sums of runs of numbers

It turns out the answer is fairly well known and involves what are known as polite numbers but I hadn't heard of them before.

So in order to solve this, we consider sequences of positive consecutive integers. I've added "positive" in there because sequences that are all negative are just positive sequences with the sign flipped and so are not interesting. Sequences that start negative and go positive are also not interesting as you can a bunch of the numbers will cancel out and you'll be left with a sequence that's purely negative or a purely positive.

There's a well-known formula for the sequences starting at \(1\) and that the formula for triangular numbers: \(1 + 2 + ... + n = n(n+1)/2\). We can use this to get a formula for sequences that don't start at \(1\). The sum \((k+1) + (k+2) + ... + (k+n)\) is just the sum from 1 to n minus the sum from 1 to k. More formally that's \begin{equation}\label{2.1} \begin{split} &{} n(n+1)/2 - k(k+1)/2\\ =& 1/2(n^2+n -k^2 -k)\\ =& 1/2(n^2-k^2 + n -k)\\ =& 1/2((n+k)(n-k) +(n -k))\\ =& 1/2((n+k + 1)(n-k))\\ \end{split} \end{equation}

So now if we want to get a specific number \(Y\) out of that then $$ Y = 1/2((n+k + 1)(n-k)) $$ so $$ 2Y = (n+k + 1)(n-k) $$

Notice that the factors on the right hand side differ by \(2k + 1\) this means that one is always even and one odd and the odd one must be a divisor of \(Y\) (any odd divisor of \(2Y\) must divide \(Y\) also). So every odd divisor, \(d\) of \(Y\) gives us 2 possibilities. Either $$ \begin{split} &n+k+1& = d\\ &n-k& = 2Y/d\\ \end{split} $$ or $$ \begin{split} &{}n+k+1& = 2Y/d\\ &{}n-k& = d\\ \end{split} $$

Solving these for n and k we get either $$ \begin{split} n &= (d-1)/2 + Y/d\\ k &= Y/d - (d + 1)/2\\ \end{split} $$ or $$ \begin{split} n &= (d-1)/2 + Y/d\\ k &= (d - 1)/2 - Y/d\\ \end{split} $$

In both cases \(n\) is the same. The \(k\)s are different and in fact they are almost negatives of each other (add them together and you get \(-1\)). This means that for any odd divisor \(d\) you get exactly two solutions but exactly one of them will have a positive \(k\). \(n\) is positive if and only f \(d\) is positive.

So in fact for any \(Y\) there are exactly as many solutions as there are positive odd divisors of \(Y\). In the case of 2016 we have factors \(2016 =\) $$ \begin{split} d=1 &: 2016 = 2016\\ d=3 &: 2016 = 671+672+673\\ d=7 &: 2016 = 285+286+...+291\\ d=9 &: 2016 = 220+221+...+228\\ d=21 &: 2016 = 86+87+...+106\\ d=63 &: 2016 = 1+2+3+...+63\\ \end{split} $$ and for \(2015 =5*13*31\) we have $$ \begin{split} d=1 &: 2015 = 2015\\ d=5 &: 2015 = 401 + 402 + ... + 405\\ d=13 &: 2015 = 149 + 150 + ... + 161\\ d=31 &: 2015 = 50 + 51 + 80\\ d=65 &: 2015 = 2 + 3 + ... + 63\\ d=155 &: 2015 = 65 + 66 + ... + 90\\ d=403 &: 2015 = 197 + 198 + ... + 206\\ d=2015 &: 2015 = 1007 + 1008\\ \end{split} $$

In the 2015 example, the divisors 65, 155, 403 and 2015 are big enough that k becomes negative and we need to switch to the second solution. This doesn't happen at all for 2016 - the odd divisors never get very big because a lot of 2016 is kind of locked up inside the 32.

When the sequence comes from the first solution, it has exactly \(d\) elements and is centered around \(Y/d\). This makes sense intuitively, you can sum the sequence by adding the first and last, the second and second last, etc each contributes \(2Y/d\) and finally the middle one gives you one more for a total of \(dY/ = Y\).

When the sequence comes from the second solution, that doesn't work but instead of switching to solution 2, we can stick with solution 1 and accept a negative \(k\). Then we get a \(d\)-element sequence that sums to \(Y\) $$ \begin{split} d=65 &: 2015 = -1 + 0 + 1 + 2 + 3 + ... + 63\\ d=155 &: 2015 = -64 + -63 + ... + 90\\ d=403 &: 2015 = -196 + -195 + ... + 206\\ d=2015 &: 2015 = -1006 + -1005 + ... + 1008\\ \end{split} $$ each of these is actually the same as the solutions above (just cancel all the negatives with their positive counterpart)

Puzzle: Writting year as sums of runs of numbers

This year is 2016 and \[ 2016 = 1 + 2 + 3 + ... + 63 \] I didn't notice this myself, I saw it written somewhere but then I wondered if there were any other ways of writing 2016 as a sum of consecutive numbers and it turn out there are.

So, the puzzle is, how many ways are there of writing 2016 as a sum of consecutive numbers and what's the answer for the general case where you're trying to write any number \(Y\) as such a sum. The answer is quite simple but non-obvious.

I'll post the solution shortly My solution is here, please leave comments or solutions below.

Monday, August 31, 2015

Anti-war protest in Tokyo

This lady was at the anti-war protest in Tokyo this weekend. Police estimates are 30k people, organizer estimate were 120k people. I've no idea what the truth is but the pavement everywhere was jammed full of people with signs, chanting anti-war and anti-Abe slogans.

The protest is because the prime minister (Abe Shinzo) is trying to get a few bills through parliament that would allow Japan to participate in collective self-defense. In particular, this would mean that they could have a pact with the US. The US is currently at war with several abstract concepts and some entities that are not nation states, so what does collective self-defense mean in this case? It also seems to be contrary to article 9 of the Japanese constitution. Even if the bills pass, they will be quickly challenged in the Supreme court, where hopefully they'll be trashed. Of course Abe's party has a proposal to fix the constitution too.

For extra fun, she was being interviewed by CCTV, the Chinese state TV station.

Thursday, February 26, 2015


For almost 2 years I've been having back pain. It took me about 9 months to figure out that it was from cycling (I blamed various things at first, like my mattress).

I went to a physio who gave me some exercises. I hated them because doing them correctly was really tricky. I noticed that one of them was like lying on the floor and pretending to swim, so I just started swimming for real instead. Swimming and better posture at work mostly fixed the upper back pain but I continued to have lower back pain. As a result, I could only cycle 2 or 3 days per week.

A few months ago, I went back to the physio to do a bike-fit, thinking that if I sat differently on the bike, it would fix my back. He said that the bike wasn't the problem. He told me that my lower back was lacking flexibility, that the vertebrae were locked and that I needed to stretch. He gave me different exercises for my lower back. These were not as hateful as the previous set but they were still annoying.

Then a friend told me about Sworkit, an app that makes it easy to do exercises casually, whenever you have some time. It comes with a bunch of set routines, with videos of how to do each exercise and you can do 5 minutes at a time, with 30 seconds for each exercise. Inside the Stretching secton I found "Back Stengthening". For the first while there was a bit of clicking and popping in the lower back as things freed up. After about a week of doing these 2-3 times per day, I was back cycling every day without pain!

That's a fantastic result for me. I had been worried that I would have to give up cycling. Taking the train is a little slower but reasonably comfortable but I fear what would happen to me with free lunches and no exercise. So splashed out the $1 for the Sworkit Pro to say thanks.

I learned two things from this.

  1. Stretching matters. I've cycled everywhere for almost 30 years but I'm still a fairly casual cyclist. I try not to break a sweat (not possible in Japanese summertime!) and I just go at a comfortable speed. I have never warmed up before getting on the bike and I still don't but at some point during the day it's good to stretch properly. Perhaps that's just getting old.
  2. The mediocre thing you do regularly is way more effective than the perfect thing you never do. The stretches in Sworkit were not tailored to my problem but the app makes it fun and easy enough that I do them 2-3 times per day. The tailored exercises were annoying enough that I was only doing them once every 2-3 days. I've had the same experience with Japanese. The manga that I enjoy reading is clearly inferior to the textbook that I never open from some abstract language learning point of view but in practice, you can only learn from the things you do, not the things you don't.

Wednesday, October 08, 2014

AsRock Q1900DC and laptop power adapters

I couldn't find any concrete recommendations but I now know that the DC in fits the adapter of a Toshiba Dynabook Satellite T210 but since that adapter is needed for the laptop, I had to buy another. In my local shop the Toshiba replacements were expensive so I bought an adapter for a Panasonic Toughbook (it came with 2 different size jacks). So they also work.

Sunday, July 06, 2014

Hotpot without the hot or the pot.

Back to the same place again (麻辣湯 - malatang). This time I remembered to take a photo before eating it all (harder than it looks).

It's awesome. It's basically Sichuan hotpot but without having to deal with a fire and a huge bowl of soup on your table. And ordering for one is easy. You choose your ingredients and 3 minutes later they bring you the cooked results. Unlimited rice included, all for 680JPY (4.90EUR)!

This time I went for 激辛, the highest on their spicy scale and it still wasn't that spicy. I might be getting the "foreigners don't like spicy" treatment, I don't know. I'll ask to go off the scale next time.

They also have awesome fried shaolongbao. These things are dangerous. They're dumplings, full of soup. Even when you think you've slurped it all out, there are still pockets remaining, hidden away, waiting to shoot a jet of boiling hot liquid up your nose when you bite down!

Sunday, February 16, 2014

Delivering mail from my home server to gmail

Mostly a note to myself

My ISP in Japan (OCN) blocks port 25 outgoing. It provides a relay host but it drops things if they have a dodgy looking from address. So I set up a postfix rewrite rule to make all of my mail from this server look like it was coming from my gmail account. This seems to make OCNs SMTP relay happy.

In /etc/postfix/, I added

smtp_generic_maps = regexp:/etc/postfix/generic
and that file looks like
/(.*?)@.*/ myaddress+antispamtoken+hostname-$

Gmail thinks this is spam, so I had to set up a filter to automatically catch emails from myaddress+antispamtoken and mark them as not spam.

There are probably several better ways of achieving the same goal but the less I know about SMTP and MTAs the happier I am.

Sunday, January 12, 2014

Fixing a Nexus 7

A couple of weeks ago, my Nexus 7 went into the sink while I was washing up. Despite my best efforts, I couldn't save it. About a year ago, a colleague dropped his Nexus 7 and smashed the screen. He was kind enough to give me that old tablet this week.

Thanks to, swapping the screens was fairly straightforward. I actually made it harder for myself because I read their full teardown and peeled back a lot of sticky copper shielding that I could have just left alone if I'd noticed they had an article for just replacing the display. Anyway, those guys are awesome. I was able to fix the speaker in another phone last year because of them, go buy some of their repair kits.

Here's what the insides of 2 Nexus 7s looks like :)

Also, well done Asus for making it fairly easy for me and my fat fingers to do this.

If anyone needs any help attempting the same thing, let me know.