DrJava Font Size Problem

I'm helping my son learning Java. One of the first things to do when learning Java is picking an IDE. I like DrJava for its simplicity and small size. However, when I first run DrJava, its font size is way too small on my 4K monitor.

There are 2 ways to fix this - the easy way and the hard way.

The easy way first.
Click Edit:Preferences, then click "Display Options", change "Look and Feel" to the one that ends with "Plastic3DLookandFeel".  Do this on Windows only, for Mac and Linux, default "Look and Feel" is fine.
Click "Font" under "Display Options", change all fonts to double the original size:
Press "OK", then close DrJava then open it again.  Now the fonts should be big enough to read.

(The changes you make are actually saved in a configuration file .drjava in your home directory,  you can edit the file directly for changes, but it's not recommended)

Now the hard way.
For the "easy way", we just changed DrJava's default configuration preferences.  The hard way is to compile a DrJava program with these changes already made in the source code so we don't have to change preferences.

Clone the DrJava repository on github: https://github.com/DrJavaAtRice/drjava

Try to compile it first:
cd drjava/drjava
ant jar

You must have ant already installed.  If it's compiled OK, try run it:
java -jar drjava.jar
(You can just double click drjava.jar file too)

Open src/edu/rice/cs/drjava/config/OptionConstants.java for editing:
Change "Monaco-12" to "Monaco-24"; change "Monospaced-12" to "Monospaced-24";
chanage "dialog-10" to "dialog-20"; change "dialog-12" to "dialog-24".

Save the file then recompile (ant jar).  Now DrJava is "pre-configured" with big fonts.

You might say this "hard way" is pointless.  Why on earth would anyone want to do this? I agree.  But just maybe one wants to provide a "pre-configured" copy of DrJava to his students.  I just show one way to do it.  Another way is to write a .drjava configuration file upon installation.  This is way more complex. Besides, I'm using a standalone jar file, there's no installation to speak of.


Bugzilla "Cannot determine local time zone" problem

I had this problem today and was pulling my hairs out trying to find a solution.
Below is the only fix that worked for me:
In 'lib/DateTime/TimeZone/Local.pm', find 'sub TimeZone {', right after it, put this next line:
return DateTime::TimeZone->new(name => 'Asia/Shanghai');
(Replace 'Asia/Shanghai' with your own timezone.)
Basically all the rest of this sub has no effect now.

Reload the error page, if it show another error says: "List::Util version 1.31 required...", open 'lib/List/AllUtils.pm', goto line 10, or find the line:
use List::Util 1.31 ();
Just delete '1.31'.

After that, it should work.  I'm using Bugzilla 4.4.9.


Cloning HDD to a smaller SSD for a Windows 8 Laptop

My win8 Dell Laptop has a 500GB HDD, I bought a 480GB SSD for hard disk replacement.  Unfortunately, the 500GB HDD's partitions span the whole disk, the exact layout copying wasn't possible.

I formatted the SSD to a GPT disk, then use various cloning softwares to do the cloning.  I tried Macrium Reflect Free, EaseUS Partition Master, Minitool Partition Wizard. None of them get me to Windows startup screen.

The last one I used is Minitool Partition Wizard. During boot, it said can't find OS.  So I tried changing different bios settings out of desperation and hoped one would work.  It did.

The setting is "disable virtualization".  I don't know why it worked, it doesn't make any sense, I'm just glad it did.

So if you have problem migrating HDD to SSD, this might be something you can try.


Re-sizing a Virtualbox disk image in Linux

One of my VirtualBox virtual machine had its disk full, I thought a simple resize should fix the problem. And I went:
vboxmanage modifyhd u140464-02-disk1.vmdk --resize 30000
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!
Turned out "modifyhd" only support .vdi, not .vmdk. OK I will just use .vdi then:
vboxmanage clonehd u140464-02-disk1.vmdk u140464-02-disk1.vdi --format vdi
vboxmanage modifyhd u140464-02-disk1.vdi --resize 30000
Then detach vmdk disk from the VM and attach the vdi.
But after I boot it up, the disk was still full. The disk size wasn't changed. After some googling I found I need to install gparted and use it to grow the partition, and gparted has to be run at boot. Too much hassle.  All I want was some additional disk space. So I did it my way.
(Inside the VM)
sudo fdisk /dev/sda
then enter p, it showed:
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758    33552383    16525313    5  Extended
/dev/sda5          501760    33552383    16525312   8e  Linux LVM
Enter n to create a new partition, press enter 2 times to accept default partition size. For some reason, there was a stray segment, so I have to enter n again to create a new partition. 2 partitions were created, after a p, my partition table looked like this:
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758    33552383    16525313    5  Extended
/dev/sda3          499712      501757        1023   83  Linux
/dev/sda4        33552384    61439999    13943808   83  Linux
/dev/sda5          501760    33552383    16525312   8e  Linux LVM
sda3 is useless, so I deleted it by a 'd' followed by a '3'. sda4 is the one I will use. Enter 'w' to write to disk. Then reboot the VM.

After reboot, do a:
sudo mkfs.ext4 /dev/sda4
My /opt was not used, so I just mount sda4 as /opt
sudo mount /dev/sda4 /opt
Add "/dev/sda4 /opt ext4 defaults 0 2" to the end of /etc/fstab so it was mounted automatically at boot.

In the end, I should have just add another virtual disk without bothering resizing the current one.


fixing VPN problem in Ubuntu

I set up VPN in Ubuntu 14.04, but when I tried to turn it on in NetworkManager, I kept getting errors like "No suitable device found", "Could not find source connection" in /var/log/syslog.

The problem turned out to be that my ethernet connection was not managed by NetworkManager. "nmcli c" didn't show my wired connection.

The solution:
Edit /etc/NetworkManager/NetworkManager.conf, in section [ifupdown], change "managed=false" to "managed=true", then do a:
"sudo service network-manager restart"
Now both vpn and ethernet connections are managed by NetworkManager, turning on VPN just works.


Programming Minecraft with Python: Introducing JuicyRaspberryPie

I developed a Bukkit plugin called JuicyRaspberryPie, that let you add commands to Minecraft with Python programming.

It's largely based on RaspberryJuice plugin, I added a Python command server and also changed the Java code a little bit to let the plugin talk to the command server.

The github page has more detail.

Here's a video demo of the plugin. (Fast forward to 15 minutes for python examples, before that is just about how to download and install the plugin, which is pretty boring)


Solving windows installer error 2503 2502 problem

I got a new laptop and tried to install python on it. But it gave me 2503 2502 error.  I had installed python on other windows 8 machines and never had this problem.

2503/2502 problem is caused by insufficient permission, which should be fixed easily, just right-click and then "run as Administrator", right?  Wrong! There's no "Run as Administrator" option available for MSI (windows installer) file.

Now the solution: open explorer, find your way to C:\Windows\System32, locate cmd.exe, right click it, then "Run as Administrator".  (If that's too complicated, try this: press "windows+Q", type "cmd", right click "Command Prompt", then "run as administrator").

Now cd to the directory where download the MSI file, then type the filename and enter. Install as usual.


EasyDedupe: delete your duplicate photos, movies, or any files

I have a lots of duplicate photos and movies that's taken up lots of hard-drive space.  I'm tired of finding them one by one manually.  So I spent this weekend  writing a program that can automatically detect and delete the duplicates.  I was able to reclaim half terabyte of space by using this program.

The program is called EasyDedupe.  You can download it here.  After you download it, just unzip it (twice, if I don't double compress, the zip file can't be saved in Chrome), and run EasyDedupe.exe inside the unzipped folder.  Yes, it only runs on Windows.  But the program is written in Python, if you use Mac or Linux, just grab the source code and run it from the command line: "python EasyDedupe.py". To run the source, you need to have wxPython installed. (On Mac, also do a "export VERSIONER_PYTHON_PREFER_32_BIT=yes" to set python run in 32bit before running Python)

There are 2 ways to run it: one is comparing 2 folders and delete any files in the second folders that's duplicate of the ones in the first folder. The other is simply select one folder, the program will find duplicates and delete them.   The first way is useful for deleting duplicates that are on the different folders or disks.  The second way is useful for deleting duplicates within a single folder (and it sub folders).

The program is very much alpha.  Let me know if it crashes on you.  It works for me.  It shouldn't delete non-duplicates.  Of course there's absolutely no guarantee nor warranty.  If you want to be extra cautious, use "Dry Run" option at the bottom of the UI.  "Dry Run" will not actually delete any files.  You can then look at "log.txt" file to see if the detected duplicates really are duplicates.


Fix windows 7 explorer displaying square boxes

I had to re-install Windows 7 recently.  After installation, my Chinese file names are all square boxes in the windows explorer.
I searched online, some suggested deleting the file "C:\Windows\System32\FNTCACHE.DAT". This did not work for me.
The solution is actually this:
Open control panel-> Apperance and Personalization, select under "Fonts", "Change Font Settings".
Uncheck "Hide fonts based on language settings".   Reboot.


CombiMath My first IOS game

My first IOS game CombiMath is released. (App Store Link)

(Accompanying web site - http://combimath.com/, visit it from cellphone to take full advantage of it.)

It's a "calculate 24" game.  I made the same game for web 3 years ago using Google AppEngine (link).  For IOS, I tried  to make it using HTML5 wrapped in UIWebview so that I don't have to use Objective-C.  But I wasn't satisfied with the end result of that effort.   So I bite the bullet and start learning Obj-C.  Turned out it wasn't so bad.  Objective-C is quite easy.  I also used Cocos2d, a popular 2D IOS game engine, which simplified a lot of things.

I'm glad it's out of the door.  I need to add game center with leader-board and battle mode in the next release.