TinyMCE plugin: inserttab

I wrote a small plugin for TinyMCE, to solve the “tab” problem. This is because, in the TinyMCE editor, whenever I press “tab”, it will navigate, instead of insert “\t” in the editor.

After some understanding with TinyMCE API, then I wrote this plugin.


  1. Add the inserttab plugin button to the toolbar, in the HTML Javascript. This will show a button with “\t” image in the editor.
  2. Click the button to enable the feature.
  3. Then, whenever we press “tab”, if it is preformatted text, then it will become a real tab, “\t”, else will be filled with “    ”.
  4. To turn off, just click the button again.

The plugin is BSD license. It can be downloaded here.

Accidentally rename a currently downloading file

This was a small problem I faced, just to share how I solved it.

I was downloading a large file with JDownloader, around 700MB. But while downloading at around 600MB, I renamed the file (with extension “.part”) in the file browser. I didn’t notice it, until I finished downloading the file. Then I have 2 files something like this:

My_target_file_name.part      628647283
original_file_name.avi            734171136

From here, I knew that I renamed the file “original_file_name.part” to “My_target_file_name.part” during the file size was 628647283. But JDownloader continued to download the file until finish at 734171136 size.

Don’t worry, no need to re-download the file immediately. Try the following steps.

What I wanted to do was to combine the ending 105523853 from original_file_name.avi to the My_target_file_name.part, then the problem will be solved. So, split the file,

split -b 628647283 original_file_name.avi output

This will produce the files the outputaa with file size 628647283 and outputab with file size 105523853.

Now, combine the My_target_file_name.part with outputab, will solve the problem.

cat My_target_file_name.part outputtab > My_target_file_name.avi

Now, problem solved.

The way of data recovery


Recently, I accidentally dropped down my 320G USB external hard disk. This make me very sad. Because I got some precious data in the hard disk. The hard disk is unable to be detected on Windows 7. Then I tried to connect with two USB ports to provide more power to the hard disk, hopefully it was detectable. Yes, it was detected. Then I immediately used

CHKDSK /v /f /x f:

This was to hope to fix any file system problem. Then I went to sleep. Late in the night, I found that the CHKDSK was not responding, and the hard disk was stop operating. Unplugged the hard disk, and shut down computer. So, I knew that it was really a bad sign.


Next day, I boot into the Linux, and tried to use USB 3.0 port for the connection, thinking that it might provide more power for the hard disk. Right, it was detectable with the USB 3.0 port. Then, I mounted the hard disk and preparing to copy out the data. Now, copying the data did not work well, because the hard disk might stop operating and undetectable suddenly. So, I failed to copy out all the files. Then I looked for a better solution.

Unstoppable copier

I found a software, that is unstoppable copier. At first, I found that it was not bad. Because it will automatically skip the unreadable file and continue the copying. However, the problem of hard disk undetected was still existed. As a result, unstoppable copier did not work also.

(Note about unstoppable copier for Linux. The time stamp of the files are not copied with the original time stamp, but I am not sure about Windows version. This will cause the problem, if we want to do the synchronization in the future. Meaning that, if we copy out a corrupted file, since the time stamp is newer, this will overwrite the older file during the synchronization.)

safecopy: partition only

So, I tried for alternative, that was “safecopy“. This is a low level copying utility. By using this, I needed a hard disk greater than the 320G, so that it can copy the whole data to the location. At first, I entered

sudo safecopy /dev/sdb1 data.img --stage1

This was to copy the partition to a file called data.img.

However, at around 93%, then there is a message something like “cannot read from source”. Because, again, hard disk was not detected. Then, I tried to mount this partially recovered image, but failed.

safecopy: whole hard disk

Next, I tried to enter

sudo safecopy /dev/sdb data.img --stage1

This was to copy the whole hard disk to a file called data.img.

Yeah. With this command, I was able to copy the whole hard disk to the image file with 100% done. Then, the next problem was coming. I was not able to mount the image file. So, I posted the question to unix.stackexchange.com.


To mount the file, firstly, I used

fdisk -lu data.img

to see the hard disk image partition. Then, it produced,

Disk data.img: 310.8 GB, 310798626816 bytes
255 heads, 63 sectors/track, 37785 cylinders, total 607028568 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb1bec32c

   Device Boot      Start         End      Blocks   Id  System
data.img1              63   625137344   312568641    7  HPFS/NTFS/exFAT

From here, I thought that everything should be okay. But I failed to mount the partition. I mounted with this command,

sudo mount -o loop,offset=32256 -t ntfs data.img /mnt/temp

This mount the NTFS partition from the hard disk image with offset 32256. This 32256 comes from 512*63.

Then, the following output was produced,

Failed to read last sector (625137281): Invalid argument
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
   or it was not setup correctly (e.g. by not using mdadm --build ...),
   or a wrong device is tried to be mounted,
   or the partition table is corrupt (partition is smaller than NTFS),
   or the NTFS boot sector is corrupt (NTFS size is not valid).
Failed to mount '/dev/loop0': Invalid argument
The device '/dev/loop0' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

Then, I thought it was partition problem.

Partition problem

Continue to read from other resources for data recovery of NTFS, some mentioned about using parted command, I tried. But it could not print the partition of the hard disk image. That means, the hard disk image has some problem. I then tried the testdisk. It is a tool to solve the partition problem. But I tried, yet it did not work for my case.

Some of the resources mentioned about fsck.ntfs. For your information, there is no such thing yet. Do not waste your time to search for it. They also mentioned about ntfsfix. But it did not work for me, and it will asked for CHKDSK. I also tried ntfsresize, to resize the partition, but not worked also.

Since everything point to the CHKDSK again, I tried to boot into Windows to CHKDSK the disk image, but this command does not work to the image file!

Back to Linux, I tried to use VirtualBox and installed a virtual Windows XP. Hopefully to mount the data.img as a hard disk for the virtual Windows XP, and then can use CHKDSK. But failed again upon mounting the hard disk image.

I also tried gparted with gpart to fix the drive. But failed also.

I think most of the ways, I already tried. So, if you have the similar problem as mine, tried all the utilities I mentioned above.

safecopy again

Since there was no way to mount the hard drive image, I just try to use safecopy again for stage 2. I didn’t tried it, because safecopy with 320G needs too much time for me. And I thought that it was nothing more but just recover a little more. And also, my faulty hard disk might stop operating suddenly. So, I didn’t take this step at the beginning. But then, as a last choice, safecopy again,

sudo safecopy /dev/sdb data.img --stage2

I went to sleep. Then see the result. Right, the safecopy was not completed, and stop responding, and the hard disk was stop operating. So, the worst case was, I lost most of my data. But, before giving up, try again.

sudo mount -o loop,offset=32256 data.img /mnt/temp

It works! Yes, it really works.

So, I tried to mount again with my ownership to copy out the file.

sudo mount -o loop,ro,offset=32256,uid=myusername,gid=users,umask=002,noatime data.img /mnt/temp

Hooray, safecopy! Now I am copying out the files. But, still, some files are not able to be copied. But I solve the faulty hard disk problem.

Favourite web development frameworks

There are a lot of frameworks available for web development. For PHP, there are Zend Framework, CakePHP and CodeIgniter. I also tried Joomla! before, learn about the Joomla framework, but, it is really troublesome. In my opinion, Joomla! is user friendly, but not developer friendly.

I tried CakePHP. It is better than Joomla, for a developer. But the Acl control provided is really difficult to learn. The “Bake” seems useful, but editing the generated files is also a pain. The MySQL database is also not highly customizable. I totally agree to a post in Stack Overflow:

Less automagic is a plus! 😉

That is why, I am currently using CodeIgniter. Comparing to CakePHP, I can freely to use and do anything I like. There are less rules to follow, only a very simple naming convention. I can add my own class to the MVC easily. The URL controller and method pattern is simpler. The pagination is also more customizable. The MySQL database allows me to use my own query. The MVC architecture with the database has much more freedom. So, CodeIgniter is my first choice.

For the JavaScript, there is jQuery, dojo toolkit, MooTools, Prototype JavaScript Framework, etc. In my opinion, these frameworks are similar. I used MooTools once, not very suitable for me. I personally prefer jQuery. But at the same time, I don’t like the websites which use jQuery, because I can hardly use Greasemonkey modify the functionaliy.

There are also CSS frameworks: 960 Grid System and Blueprint. These CSS frameworks use grid system for the web layout. My favourite is Blueprint. It is too good to make a usable website, because grid system makes the website more organised.

So, my web development frameworks = CodeIgniter + jQuery + Blueprint.