How to turn on the Java applet plug-in for browsers.

If you saw a message that said "Inactive Plug-in" when you wanted to play a Java applet game or something, turn on the Java applet plug-in for browsers. It's vary easy.

  1. Launch "Java Preferences". You can find it by using Spotlight.
  2. Check "Enable applet plug-in and Web Start applications".
  3. Re-start your browser. That's it!

The update to OSX Lion 10.7 would disable Java applet in browsers for some reason.

How to remove "event.layerX and event.layerY are broken and deprecated in WebKit..." warning message.

If you see the following warning message on your javaScript console of Google Chrome, you have to update jQuery to the latest version.

----------------------------------------------------------------------------------------------------------------------------------------------------------

event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.

----------------------------------------------------------------------------------------------------------------------------------------------------------

http://stackoverflow.com/questions/7825448/webkit-issues-with-event-layerx-and-event-layery

言語別の乱数生成方法

0からnまでの整数の乱数を生成する方法を、言語別にメモしておく。

C

#include <stdlib.h>
srand(time(NULL));
rand() % (n + 1);

C#

Random r = new Random();
r.Next(n + 1);

Java

Math.floor(Math.random() * (n + 1));

JavaScript

Math.floor(Math.random() * (n + 1));

Ruby

rand(n + 1)

Python

import random
random.randint(0, n + 1)

PHP

mt_rand(0, n);