VirtualBox using USB flash drive as a raw disk

  1. Run cmd as administrator
  2. cd %programfiles%\Oracle\VirtualBox
  3. VBoxManage internalcommands createrawvmdk -filename C:\usb.vmdk -rawdisk \\.\PhysicalDrive#
  4. Run virtualbox as administrator

elementary OS 0.4.0 Loki chinese input

Method 1. Set startup for ibus-daemon -drx

1. Open “System Settings” -> “Application” -> “Startup”
2. Click “+” on bottom left corner
3. Input “ibus-daemon -drx” ,and press enter
4. Re-logon

Method 2. Change the config file

1. Go to /usr/share/im-config/data/
2. Modify “21_ibus.rc” with “sudo”
3. Find “/usr/bin/ibus-daemon –daemonize –xim –panel=disable”
4. Remove parameter “–panel=disable” and save
5. Re-logon

For install 倉頡或速成

sudo apt install ibus-cangjie


Optimize Linux running on USB

1. Use memory instead of disk

This tip can also lead to data loss. If you do it, you will have to always shut down your computer properly from now on, because unexpected power failures will lead to data loss.

Linux usually ensures that all changes are written to disk every few seconds. Since disk writes are so slow, you can change your system to keep things in memory longer. All changes will be written to memory, and the excruciatingly slow writes to happen in the background while you continue working. This has an instant, noticeable effect, but it can lead to data loss.

Add these lines to /etc/sysctl.conf, and reboot.

vm.swappiness = 0
vm.dirty_background_ratio = 20
vm.dirty_expire_centisecs = 0
vm.dirty_ratio = 80
vm.dirty_writeback_centisecs = 0

The problem: using this tip means that your system stops writing changes to disk until you shut down or type “sync” at a command line. If your system loses power unexpectedly, you will get bad blocks. I did. You can limit the amount of data loss in the event of a power failure to one minute by setting vm.dirty_writeback_centisecs = 6000.

A side effect is that shutting down your computer will may take several minutes where it appears to be doing nothing. Don’t cut the power until it’s done, because it is busy writing all those changes to disk.



2. Using ramdisks (tmpfs) for temporary files

It is quite easy to move directories where temporary files are stored (primarily /tmp) to a ramdisk, and it can make a significant difference in performance. The following lines added to /etc/fstab cause /tmp and /var/tmp to be stored in ramdisks:

    tmpfs    /tmp       tmpfs    defaults    0 0
    tmpfs    /var/tmp   tmpfs    defaults    0 0


3. noatime

By default, the ext3/ext4 filesystem updates the access time attribute on a file system object whenever it’s read. This results in even the most trivial file reads result in a write operation. Keeping the access time updated is only important for some very specific tasks which we’re not likely to come across.

Open /etc/fstab and for each mount that is on your USB storage, add a noatime parameter. For example:

/dev/mapper/vg_root-lv_root /               ext4    errors=remount-ro 0       1


/dev/mapper/vg_root-lv_root /               ext4    noatime,errors=remount-ro 0       1



4. IO Scheduler



The default IO Scheduler used by Ubuntu is cfq. Changing this to deadline will see improved performance during times where multiple processes are trying to read/write to disk. You can change the default scheduler for all devices by adding a kernel parameter into grub.

Open /etc/default/grub and find the following line:


Add the elevator option:


Or, if you added the verbose option earlier:

GRUB_CMDLINE_LINUX="elevator=deadline verbose"

Now, use update-grub to apply your changed setting to grub.cfg and restart for the change to take effect.

sudo update-grub
sudo reboot

To see that your new scheduler has taken effect you can query which scheduler is currently in use for a specific device with this command:

cat /sys/block/<device>/queue/scheduler

delete all email in exim

To print a list of the messages in the queue, enter:

exim -bp

To remove a message from the queue, enter:

exim -Mrm {message-id}

To remove all messages from the queue, enter:

exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash

To remove all messages from the queue with specific word, enter:

exim -bp|grep “username”| awk {‘print $3’}| xargs exim -Mrm

ssh without password using certificate

Generate a pass-phraseless SSH key:

$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/

Copy your keys to the target server:

$ ssh-copy-id id@server
id@server's password: 

Now try logging into the machine, with ssh 'id@server', and check in:


to make sure we haven’t added extra keys that you weren’t expecting.

Finally check logging in…

$ ssh id@server


You may also want to look into using ssh-agent if you want to try keeping your keys protected with a pass-phrase.


Usage of RAMFS and TMPFS


# mkdir -p /mnt/tmp

# mount -t tmpfs -o size=20m tmpfs /mnt/tmp


# mkdir -p /mnt/ram

# mount -t ramfs -o size=20m ramfs /mnt/ram


Batch script sync two folder using xcopy on windows

@echo OFF
echo :
echo : XCOPY Batch Process Started
echo :
xcopy folder1 %USERPROFILE%\Desktop\folder2/E /D /C /Y
xcopy %USERPROFILE%\Desktop\folder2 folder1 /E /D /C /Y
echo :
echo : XCOPY Batch Process Complete
echo :

reCAPTCHA PHP example


Paste this snippet before the closing </head> tag on your HTML template:

<script src=''></script>

Paste this snippet at the end of the <form> where you want the reCAPTCHA widget to appear:

<div class="g-recaptcha" data-sitekey="{site key}"></div>


PHP Code

//form submitted

//check if other form details are correct

//verify captcha
$recaptcha_secret = “{secret key}”;
$response =file_get_contents(“”.$recaptcha_secret.“&response=”.$_POST[‘g-recaptcha-response’]);
$response = json_decode($response, true);
if($response[“success”] === true)
echo “Logged In Successfully”;
echo “You are a robot”;


Qadabra Payment Proof
paypal payment

Cacti – Fix the change page bug in Create New Graph Page

There is a bug of javascript in “Create New Graph Page”.

To fix this bug, you may modify the php file “html.php” and “html_utility.php” at <cacti directory>/lib/.

Change all the code from “function gotoPage” to “function goto$page_var”.