Banpei.net

Remembering Japanese cars from the past

Page 291 of 317

Osu! The Guitar Hero for the PC?

I came across this last weekend:

Basically Osu! is a Drumming game for the PC for which many popular (JPop) tunes are available. The principle is basically the same as for Guitar Hero, however with Osu! you can create your own fields and challenges!

For me it is a bit too much since I already suffer from mild RSI from now and then, but for all other out there: Try it! It is fun to do!

You can find Osu! here:
Osu!

Touge drifting video from 1995

This amateur drift video (3 parts), made in 1995 on the Hakone Pass, also shows that AE86s back in those days were very popular as well. I counted at least 8 or 9 different hachi-rokus, however it is a bit difficult with so many stock hachis:

I did spot a Z10 Soarer, KE70 corolla and a KP61 starlet as well. Other popular cars are the RPS13 180sx and the S13 Silvia. Must say all these cars resemble the stock look of the early Initial D chapters, which of course is the same period. ;)

Useless Japanese car innovations: spoken reverse warning signal

I managed to find another useless innovation: we all know the reverse warning signal, short beeps indicating a big truck is reversing (with no rear vision at all). That’s very useful and people are used to it and act upon it.

In the early 80s Toyota innovated the reverse warning signal and equipped their MarkII with a spoken reverse warning signal:

Of course this innovation is only useful for people understanding Japanese, if they are used to it at all… If someone would reverse with their Jaguar and that car would tell me in English “Watch out, big lump of iron is reversing! Keep away! Do not stand in the turning circle! Etc. etc.” I would not really act upon that: I’d probably first start laughing my ass off and then probably congratulate the driver with such cynical car!

You see, that’s why this can only fall into the category of useless Japanese car innovations!

Programming: ON DUPLICATE KEY MySQL weirdness

I had some weirdness with MySQL today… Updating on a duplicate key error works like a charm: it updates the row which violates with the key and everybody is happy!

Well, actually I’m not… I encountered this problem today. I had a table with a number and an average and the table named averages looked like this:

|-----------------------------|
|      id |  number | average |
|-----------------------------|
|       1 |       1 |       0 |
|       2 |       4 |    0.25 |
|       3 |       2 |     0.5 |
|-----------------------------|

Now let’s say I wanted to increment id 1 with number=2 and an average=1, normally I would use the following query:

UPDATE `averages` SET `number`=`number`+2, `average`=(((`average`*`number`)+(1*2))/(`number`+2)) 
WHERE `id`='1';

This would update the table and set the number to 3 and average to 0.6666667. This worked fine till I added this to a cronjob which calculates averages from large quantities of rows. Since I would not know the identifiers upfront I changed the query to an INSERT query with a ON DUPLICATE KEY UPDATE part which updates when we already have a row for the identifier, so I came up with this:

INSERT INTO `averages` VALUES (1, 2, 1) ON DUPLICATE KEY UPDATE `number`=`number`+2, 
`average`=(((`average`*`number`)+(1*2))/(`number`+2))

But, as I found out later, this doesn’t work the same way as the UPDATE query: the ON DUPLICATE KEY UPDATE does not write itself to a single UPDATE query, but rather to two seperate UPDATE queries. This means that the query will be written to this:

UPDATE `averages` SET `number`=`number`+2 WHERE `id`='1';
UPDATE SET `average`=(((`average`*`number`)+(1*2))/(`number`+2)) WHERE `id`='1';

Can you identify the problem I encountered here? And perhaps guess what the average column was set to?? ;)

« Older posts Newer posts »

© 2024 Banpei.net

Theme by Anders NorenUp ↑