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.


Video formatting for PowerPoint embedding

If you have problem embedding videos into your PowerPoint presentation, here's some help.
You need to convert your video to a format PowerPoint accepts. However even if you are able to embed your video and play it on your computer, it doesn't mean it will be playable on other computers. I tried quite a few combinations of video/audio format (h264, mp3, aac etc.) and found the least common denominator of video/audio format that can be embedded in PowerPoint and played on almost all windows computers is wmv2/wmav2. So here’s command for video conversion with ffmpeg:
ffmpeg -i video1.mov -vcodec wmv2 -acodec wmav2 -f asf video1.wmv
The resulting video quality is usually not very good, the images are often pixelated. To get better video quality, you need to specify bitrate:
ffmpeg -i video1.mov -b 1500k -vcodec wmv2 -acodec wmav2 -f asf video1.wmv
Here I specified 1500kbps bitrate. You can set higher bitrate. Of course it doesn’t make sense to go above the video’s original bitrate. You can find the a video’s original bitrate from ffmpeg output or on Windows, right click the video file and select “Properties” then “Details” tab. Try different bitrates and select a lower one while still maintaining an image quality. Often times, I want to keep my video (and therefore the size of PowerPoint) small by shrinking the video (e.g. 320x240) like this:
ffmpeg -i video2.mp4 -vcodec wmv2 -acodec wmav2 -f asf -s 320x240 video2.wmv
Small video has an marginal benefit besides small file size: because the image size is small, the effect of pixilation is markedly reduced. Even with smaller size, with several videos in the Powerpoint, the file can still be too large to be sent with email(gmail and yahoo mail have 25Meg limit). To solve this problem, I usually just embed small, low quality, incomplete “teaser” videos with notes and links to complete 1080p videos I (pre)uploaded on youtube. To cut a 30 second video, starts from 5 seconds at original video:
ffmpeg -i 027.MOV -ss 00:05 -t 30 -vcodec wmv2 -acodec wmav2 -f asf -s 480x270 027s.wmv
My original 1 minute 1920x1080 video is 180MB, the half-minute “teaser” video is only 1.1MB.