Sunday, June 03, 2012

Install Android in VirtualBox with Internet connection

  1. Download a "Buildroid for VirtualBox" OVA file at http://www.buildroid.org. There are 3 versions: for "phone", for "tablet" and for "tablet" with phone capabilities. [There is a Buildroid image with Market/Play app but "for testing purpose only".]
  2. Import the Buildroid image into Virtualbox: File --> Import Appliance...
  3. Install Google Play Store app (and other apps) (in Windows):
    • Get the adb (Android Debug Bridge) utility from Android SDK (http://developer.android.com/sdk/index.html) or download the adb at https://sites.google.com/site/keyablefile/adb-win.zip (including adb.exe and AdbWinApi.dll).
    • Download the app at http://buildroid.org/Download/buildroid-gapps-ics-20120317-signed.tgz
    • VirtualBox: Settings --> Network --> Adapter 1 --> Attached to: NAT; Advanced --> Port Forwarding --> Insert new rule: both Host Port and Guest Port = 5555. [Multiple virtual machines: increment the host port (5556,...) and keep the same guest port for each machine.] [Adapter 2 is used for emulating a Wifi connection.]
    • Start Buildroid virtual machine. Open Buildroid VM Configuration, there should be the IP address under IP Management.
    • In Windows Explorer, go to the folder containing adb.exe; Shift-right click --> Open command window here. [Check adb help for options and parameters.]
      • adb connect localhost (or adb connect the_above_IP_address)
      • adb push path\to/buildroid-gapps-ics-20120317-signed.tgz /sdcard/ (copy the .tgz apps file to Android)
      • adb shell
      • su
      • mount -o remount,rw /system
      • tar -xvzf /sdcard/buildroid-gapps-ics-20120317-signed.tgz
      • mount -o remount,ro /system
      • reboot
    • The Adroid machine will reboot and there should be Google apps including Market/Play.
Ref:
- http://keyable.blogspot.jp/2012/05/how-to-run-android-40-in-virtualbox.html
- http://www.buildroid.org/blog/?page_id=121

Install Android in VirtualBox

  • Dowwnload android-x86-4.0-RC1-eeepc.iso or android-x86-4.0-RC1-asus_laptop.iso from http://www.android-x86.org/download.
  • Create a new virtual machine on VirtualBox. OS type: Linux, version Linux 2.6. Memory: 512 MB or 1000 MB. Create a new boot harddisk. Adjust the settings: Sound: Sound Blaster 16; Network: NAT (or Bridged), adapter: PC-net-FAST III
  • Install Android. Choose Install Android-x86 to harddisk from the boot menu. Create one partition for the full harddisk, formatted as ext3. Install the boot loader GRUB. When the installation finishes, select "Run Android x86" to boot the Andoid. (Before the next booting, remove the CD image from Settings-Storage-IDE Controller.)
  • To make the mouse work in the virtual machine, go to “Machine” in the menu and select “Disable mouse integration” (right Ctrl, by default, to restore the mouse in host machine). Alt-1 and Alt-7 to enter command line or go back to graphical interface. Shutdown the machine by command-line (halt) or from menu of VirtualBox. Press Esc to exit standby mode.
  • To connect the Internet (from command line, tested with NAT):
    • netcfg to list the devices.
    • dhcpd eth0
    • setprop net.dns1 8.8.8.8
Ref:
- http://maketecheasier.com/install-android-4-0-ice-cream-sandwich-in-virtualbox/2012/03/02
- http://groups.google.com/group/android-x86/browse_thread/thread/eb88bb948176f6b8
- http://groups.google.com/group/android-x86/browse_thread/thread/ec0aee3a027775d7

Note:
  • By the above method, the Internet can be accessed using browser, but other apps cannot access the Internet (they need "wifi").
  • To access the Internet with other apps: see http://keyable.blogspot.jp/2012/05/how-to-run-android-40-in-virtualbox.html

Thursday, May 03, 2012

Read Vietnamese on Sony Reader PRS-T1

Fully embed fonts:
  1. Add the ePub book into Calibre. Right click on the book, choose Tweak Book. Choose Explode ePub.
  2. The file browser (Windows Explorer) will open at an temporary address like C:\Users\UserName\AppData\Local\Temp\calibre_0.8.44_tmp_2s_358\qsvcc__exploded. There should be files stylesheet.css and content.opf.
  3. In the directory containing the .css file, make a new directory named fonts. Copy 4 Gentium Book Basic fonts to that directory (the fonts can be download at scripts.sil.org/Gentium_basic).
  4. Open the .css file in a text editor and add 4 @font-face statements. (Notice the url at src:.) (There may be other .calibre, .calibre1,... in the file.)
    @font-face {
        font-family: serif;
        font-weight: normal;
        font-style: normal;
        src: url(fonts/GenBkBasR.ttf)
        }
    @font-face {
        font-family: serif;
        font-weight: normal;
        font-style: italic;
        src: url(fonts/GenBkBasI.ttf)
        }
    @font-face {
        font-family: serif;
        font-weight: bold;
        font-style: normal;
        src: url(fonts/GenBkBasB.ttf)
        }
    @font-face {
        font-family: serif;
        font-weight: bold;
        font-style: italic;
        src: url(fonts/GenBkBasBI.ttf)
        }
    
    Anywhere in the .css file where there is
    font-family: "Gentium Book", serif;
    can either be replaced with
    font-family: serif;
    or removed altogether because serif is the default font used by the reader.
  5. Edit the .opf file, manually add the 4 font files to the section. (In theory, this step is to make a compliant epub. In practice, it may make no difference to whether the epub will read correctly on PRS-T1.)
    <manifest>
        ... lots of file paths ...
        <item href="fonts/GenBkBasR.ttf" id="serifr" media-type="application/x-truetype-font"/>
        <item href="fonts/GenBkBasI.ttf" id="serifi" media-type="application/x-truetype-font"/>
        <item href="fonts/GenBkBasB.ttf" id="serifb" media-type="application/x-truetype-font"/>
        <item href="fonts/GenBkBasBI.ttf" id="serifbi" media-type="application/x-truetype-font"/>
    </manifest>
    
    The href attribute needs to be the path of the .ttf file relative to the .opf file inside the epub.
  6. Save and close all the edited files. Run Rebuild ePub in the window from Calibre.
Note:
  1. It is not a good idea to do a Calibre conversion on an epub after it has fonts fully embedded. Sometimes the fonts no longer work afterwards.
  2. The fonts may not work on the reader when fully embedded to an epub which has previously been added @font-face statements during a Calibre conversion using the ExtraCSS box. The conversion process will have placed all the @font-faces in each and every (x)html file inside the epub rather than in the .css file. These may well override the ones just manually added to the .css file. If this is the problem, manually removing the @font-faces from the html files should correct it.
More to read: 3 ways to achieve epubs with customized fonts
  1. Embedding. Font files are copied into the epub, @font-face css is added to the epub's existing css file.
    Often used by publishers for DRM'd retail epubs; but can be done for epubs not locked by DRM.
    Pros
    - epub should work on any reader which uses the Adobe renderer.
    Cons
    - non-DRM epubs only
    - The font files would be contained in every single epub. Some are quite large and add up to a lot of disk space if thousands of books are kept on the reader.
    - Have to manually edit each epub to embed font files, extra @font-face css and make some changes to the epub's .opf file.
  2. Font files are copied to the reader, @font-face css is placed in a specially-named .css file on the reader.
    This requires the firmware on the reader to be slightly modified to recognise the .css filename containing the @font-faces. This is because Adobe has seen fit to hide its default css file deep inside the firmware where users can't get at it.
    Pros
    - Can be used for all epubs whether they have DRM or not.
    - Only need to copy the font files and @font-face css to the reader once.
    - Don't need to do anything special in Calibre, nor to edit each epub.
    Cons
    - Have to 'hack' the reader firmware.
  3. A kind of hybrid. Font files are copied to the reader, @font-face css added to each epub's css file.
    The @font-face css can be added into each epub's css file manually using Calibre's Tweak-epub feature. Or this can also be done by a Calibre conversion to epub, by copying the @font-face css into Calibre's Convert - Look&Feel - ExtraCSS box.
    Pros
    - no hacking required
    - Only need to copy the font files to the reader once.
    - If the @font-face css is added to Calibre Preferences, this process is only needed to be done once. Cons
    - non-DRM epubs only
    - Because the @font-face css is slightly different for each brand of reader, the same epub cannot be used on different readers, e.g. an epub prepared for a Sony will not display correctly on a PocketBook, and vice versa.
Acknowledgments: jackie_w from mobileread.com
  • http://www.mobileread.com/forums/showpost.php?p=1818037&postcount=11
  • http://www.mobileread.com/forums/showpost.php?p=1726853&postcount=190

Monday, April 30, 2012

Using Epson Scanner 7600U (Windows 7)

On Epson's page (http://www.epson.jp/dl_soft/list/1221.htm), no driver for Windows 7. Thanks to http://d.hatena.ne.jp/miya_kaz/20120110/1326180360, it is found that the scanner can be used by the GT-9300's driver.

http://www.epson.jp/dl_soft/list/1502.htm#43

ここでWin7 64bit用のEPSON Scanをダウンロード,実行

使用する機器を聞かれるので,GT-9300を選択,インストール

スキャナをPCに接続する。最初のドライバ探しは失敗する。

デバイスマネージャでプロパティ→ハードウェア→プロパティ→設定の変更クリック。

ドライバータブ→ドライバの更新→コンピュータを参照→デバイスドライバの一覧から選択→イメージングデバイス→EPSON→GT-9300 を選択,インストール

ここまでやったらEPSON Scanを実行。Scanできました。

Saturday, November 05, 2011

Remove accent marks from filename in Vietnamese

(Gỡ bỏ dấu tiếng Việt trong tên tập tin)

This is a java code from http://khoinguonit.com/f80/[java]-doi-ten-file-tieng-viet-co-dau-thanh-khong-dau-1578/

  • It reads files from the input folder and then moves them to output. To make changes to files in the current directory, use . (dot) instead.
  • Online complier at http://www.innovation.ch/java/java_compile.html.
  • From console, run it by java Rename, or make a run.bat:
    @echo off
    java Rename

    pause
  • This code also changes upper cases into lower cases.

Saturday, October 22, 2011

Shrink VirtualBox disk images

In Linux (Debian) guest:
  • apt-get install zerofree
    zerofree is a small program which uses the ext2fs library to get a list of all the blocks, checks if the current block is free but non-zero (i.e. has been used at some point) and fills it with zeroes again. The utility also works on ext3 or ext4 filesystems. This allows the VBoxManage tool to compact the VDI.
  • init 1
    to go to single mode.
  • mount -n -o remount,ro -t ext2 /dev/XXX /MOUNTPOINT"
    to remount all partitions read only (chec the available filesystem with df).
    • -n : not try to update "/etc/mtab" (which might be on the now read only disk)
    • -t ext2 : not need journaling.
  • fsck.ext2 -f /dev/XXX
    to check the filesystem (if necessary).
  • zerofree /dev/XXX
  • fsck.ext2 -f /dev/XXX
    again to check the filesystem (if necessary).
  • mount -t ext4 -o remount,rw /dev/XXX /MOUNTPOINT
    to remount the partitions back to normal.
  • Shutdown the virtual machine.
In Windows guest:
  • Perform hard disk defragmentation.
  • Download sdelete from http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx
  • sdelete -c DRIVE:
  • Shutdown the virtual machine
In host:
  • VboxManage modifyhd /path/to/the/vmdiskimage.vdi --compact
Ref:
- http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi
- http://intgat.tigress.co.uk/rmy/uml/sparsify.html
- http://forums.virtualbox.org/viewtopic.php?t=1198
- http://maketecheasier.com/shrink-your-virtualbox-vm/2009/04/06

Thursday, October 13, 2011

Access linux filesystems in Windows

There are some drivers available to access a linux filesystem from Windows, such as Ext2Fsd (read and write, for ext2, partly ext3/ext4), explore2fs (read-only, for ext2/ext3), Ext2read (read only, for ext2/ext3/ext4), DiskInternals Linux Reader (freeware, read-only, for ext2/ext3/ext4, HFS and ReiserFS), Ext2 Installable File System for Windows (freeware, read and write, for ext2), RFSTOOL (read-only, for ReiserFS), ReiserDriver (read-only, for ReiserFS), LTOOLS (read and write, for ext2/ext3 and ReiserFS). Some of them have stopped development for quite a long time.

An more "native" approach is to make use of a virtual machine to read and write the linux filesystems on internal and external hard disk drives. It seems to be the only choice for btrfs until now.

  • Install VirtualBox (with USB support enabled).
  • Create a Debian virtual machine. Get a Debian netinst image and install a base system (without any suggested groups of packages). It takes around 900 MB plus swap space at the time of this writing. Network of the virtual machine is set to bridged.
  • To access a linux partition on intrenal hard disk drive: create an image representing it and add it to VirtualBox
    • Run cmd.exe as administrator.
    • Change into the VirtualBox directory:
      cd "c:\Program Files\Oracle\VirtualBox"
    • List the partitions of the hard disk:
      VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDriveX
      with X is the hard disk drive number (the first one in Windows is numbered 0). Linux filesystem is 0x83. Note the number(s) of the needed partition(s).
    • Create the image of the partition(s):
      VBoxManage.exe internalcommands createrawvmdk -filename "\path\to\file.vmdk -rawdisk \\.\PhysicalDriveX -partitions Y,Z
      The image file name has to be a .vmdk. Y, Z are the partitions numbers found by the previous command.
    • Run VirtualBox as administrator. Go to Storage tab of the Settings of the machine. Add the image in SATA Controller.
  • To access a linux partition on usb hard disk drive, select it from the menu Devices -> USB Devices from the machine window.
  • Install samba package. Its current version on Debian testing is 3.5.11.
    • Check available samba users with pdbedit -L -a. Create a new samba user (if necessary) with smbpasswd -a username (the username should be added in Linux system by useradd before that).
    • The default smb.conf should work out of the box, or can be edited to meet appropriate share needs. By default, the home directory of the user will be shared and read-only is set. To enable writing, set read only = no in [homes] definition. File and directory creation mask can also be re-set. Run /etc/init.d/samba reload to reload smb.conf.
  • Mount the partitions on internal and/or usb hard disks to directories which can be accessed by samba.
  • In Windows 7, type the IP address of the virtual machine in search/run box (menu Start), like \\192.168.56.38 (found by running ifconfig in the virtual machine). Windows 7 uses DOMAIN/username to login, which fails to log into samba server. This can be bypassed by adding a \ before the username.

Notes:

  • There are reports that with old versions of Samba and Windows 7, it is necessary to modify the Local Security Policy to set the LAN Manager Authentication Level to “Send LM & NTLM responses”. In Windows 7 Professional, this can be done in Control Panel -> Administrative Tools or secpol.msc from the command line. Windows 7 Home versions don’t have this tool but the same thing can be done by edit the registry by hand: open registry with regedit, go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa and add a DWORD value named "LMCompatibilityLevel" and set the value to "1".
  • To enable USB 2.0 (EHCI) controller, VirtualBox extension package must be installed separately.
  • Be careful with USB devices that are currently in use on the host! For example, if you allow your guest to connect to your USB hard disk that is currently mounted on the host, when the guest is activated, it will be disconnected from the host without a proper shutdown. This may cause data loss.
  • There are suggestions to use coLinux. But it does not support 64-bit system at the current time.

Links:

  • Ext2Fsd: http://www.ext2fsd.com
  • Explore2fs: http://www.chrysocome.net/explore2fs
  • ext2read: http://sourceforge.net/projects/ext2read/
  • DiskInternals Linux Reader: http://www.diskinternals.com/linux-reader
  • Ext2 Installable File System For Windows: http://www.fs-driver.org/index.html
  • RFSTOOL: http://freshmeat.net/projects/rfstool
  • ReiserDriver: http://rfsd.sourceforge.net
  • LTOOLS: http://www2.hs-esslingen.de/~zimmerma/software/ltools.html
  • VirtualBox: https://www.virtualbox.org
  • coLinux: http://www.colinux.org
Ref:
- http://www.virtualbox.org/manual/ch09.html#rawdisk
- http://www.ubuntugeek.com/howto-access-ext3-partition-from-windows.html

Saturday, April 16, 2011

Using tor button

1. # apt-get install iceweasel-torbutton
will install other related packages as well.

2. Configure polipo:
- backup /etc/tor/config
- use this file https://gitweb.torproject.org/torbrowser.git/blob_plain/HEAD:/build-scripts/config/polipo.conf as the above config file

3. Configure tor
- Uncomment these lines in /etc/tor/torrc
SocksPort 9050 # what port to open for local application connections
SocksListenAddress 127.0.0.1 # accept connections only from localhost
RunAsDaemon 1
ControlPort 9051

4. Restart polipo and tor
# /etc/init.d/polipo restart
# /etc/init.d/tor restart

Ref:
- https://www.torproject.org/docs/tor-doc-unix.html.en
- http://forums.opensuse.org/get-help-here/network-internet/429127-tor-not-starting.html#post2091241

Blank screen during boot

# lspci
1:00.0 VGA compatible controller: ATI Technologies Inc NI Seymour [AMD Radeon HD 6470M]

A blank screen appears after messages about udev. Cannot move to other consoles by Alt-Fx. However, can "blind" log-in, run startx and X works.

Solution: append radeon.modeset=0 (or nomodeset, if this does not work) to the kernel options line in the bootloader configuration file (/boot/grub/menu.lst or /boot/grub/grub.cfg [but this file is subject to change when upgrading GRUB] for GRUB users) to disable KMS.

Ref: https://wiki.archlinux.org/index.php/Ati

Tuesday, April 05, 2011

Installing Debian via the Internet from Windows (amd64)

1. Download linux (the kernel) and initrd.gz from
http://d-i.debian.org/daily-images/amd64/daily/netboot/debian-installer/amd64/

2. Install and boot GRUB4DOS.
kernel /linux
intrd /initrd.gz

3. The installation begins.

Using GRUB4DOS from Windows 7

A. GRUB4DOS
Copy grldr.mbr, grldr and menu.lst to C:\.

B. BCDEdit
1. Backup the current config:
bcdedit.exe /export c:\filename

2. Create new entry
bcdedit.exe /create /d "GRUB4DOS" /application bootsector

This returns a guid of 32-character string like
{5ed99144-5f57-11e0-818a-78843ccde686}
.
3. Set entry option value: device
bcdedit.exe /set {5ed99144-5f57-11e0-818a-78843ccde686} device boot

However, when booting, it may get the following error:
File: \grldr.mbr
Status: 0xc000000f
Info: The selected entry could not be loaded because the application is missing or corrupt.

This is because becouse Windows 7 creates a hidden extra partition for the BCD. Then, this command should be issued:
bcdedit /set {5ed99144-5f57-11e0-818a-78843ccde686} device partition=C:

4. Set entry option value: path
bcdedit.exe /set {5ed99144-5f57-11e0-818a-78843ccde686} path \grldr.mbr

5. Set entry display order
bcdedit.exe /displayorder {5ed99144-5f57-11e0-818a-78843ccde686} /addlast

6. Set timeout (for example, 2 sec)
bcdedit /timeout 2

Friday, December 14, 2007

Chơi CD nhạc với xmms

Chơi CD nhạc với xmms

* Tạo (điều chỉnh) một mục trong fstab cho tương tự /dev/cdrom /media/cdrom auto unhide,ro,noauto,user,exec 0 0
* Đặt đĩa CD vào ổ đĩa
* Nhấp chuột phải trên xmms, chọn Play Directory
* Chọn /media/cdrom (trong trường hợp này)
* Nếu
$ls /media/cdrom -al
lrwxrwxrwx 1 root root 13 2004-11-17 13:35 /media/cdrom -> /media/cdrom0

có thể cần tạo thư mục /media/cdrom0 nếu chưa có.

Monday, July 02, 2007

Installing usb wireless card on Debian Lenny

1/ CNet CWD-854 Dongle, P/N: 18-1HGWD85CH.
- Install the packages kernel-headers, wireless-tools.
- Go to http://rt2x00.serialmonkey.com/wiki/index.php/Downloads and download the file rt73-cvs-daily.tar.gz.
- May need to blacklist the RT73 driver available to the distro (?):
echo "blacklist rt73usb" >> /etc/modprobe.d/blacklist
- Extract rt73-cvs-daily.tar.gz, go to its Module/ directory, run make and make install.
- Run vi /etc/modules and at the end of the file, add rt73 in a new line.
- ls /etc/modprobe.d/ | grep rt73 to check if rt73 file exists, if not, touch rt73 and echo "alias rausb0 rt73" >> /etc/modprobe.d/rt73
- rm /etc/modprobe.conf as it is not necessary.
- run iwconfig to check the recognized name of the device.
- create a script called wlanz, for example:

#!/bin/sh
ifconfig wlan0 down
ifconfig wlan0 up
iwconfig wlan0 mode Managed
iwconfig wlan0 key XXXX-XXXX-XX
iwconfig wlan0 essid "My ESSID"
dhclient wlan0

chmod +x; then run it.
See Module/iwpriv_usage.txt in the driver package for information on other types of encryption and settings.
The above settings can be put in /etc/network/interfaces (restart the interfaces: /etc/init.d/networking restart):

auto wlan0
iface wlan0 inet dhcp
ifconfig wlan0 down
ifconfig wlan0 up
iwconfig wlan0 mode Managed
iwconfig wlan0 key XXXX-XXXX-XX
iwconfig wlan0 essid "My ESSID"

To list available networks: iwlist wlan0 scanning.

2/ Linksys WUSB54G:
- similar to the above
- using rt2570 chipset
- the interface named rausb0

Note: D-Link DWL-G122: rev B - chipset rt2570; rev C - chipset rt73.

Ref:
- http://ralink.rapla.net/ Ralink chipsets based wireless devices
- http://rt2x00.serialmonkey.com/wiki/index.php/Hardware
- http://ndiswrapper.sourceforge.net/joomla/index.php?/component/option,com_openwiki/Itemid,33/id,list_c-f/

Sunday, August 07, 2005

Directory index

Some (free) webservers do not allow to list files in directories. This script can help (thanks to http://www.plebian.com/news.php?artc=8):

<?php
unset($dir);
if(!empty($HTTP_GET_VARS['dir'])&&!strpos($HTTP_GET_VARS['dir'],'..')&&!strpos($HTTP_GET_VARS['dir'],'\.\.'))
{

$dir=$HTTP_SERVER_VARS['DOCUMENT_ROOT'].'/'.$HTTP_GET_VARS['dir'];
$d=&$HTTP_GET_VARS['dir'];
}
else
{
$dir='.';
$d='.';
}
clearstatcache();
if($a=@opendir($dir))
{
$dir=htmlspecialchars($dir);
$d=htmlspecialchars($d);
while(false!==($b=readdir($a)))
{
if(ereg("^\.",$b))
continue; // ignore hidden files
if ($b=='index.php') continue; //ignore index.php
echo (is_dir($b))?"
  • $b":"
  • $b";
    }
    closedir($a);
    }
    else
    {
    echo 'unable to open directory';
    }
    ?>
  • Sunday, July 31, 2005

    aMSN tip

    Since aMSN 0.95b (11/07/2005 in my case), it says that TkCximage is needed to run aMSN and it can be compiled with the makefile inside amsn folder. To compile it, tcl-dev and tk-dev are needed. Compiling is done as usual: ./configure and make.

    In this version, compilation happens in 3 places: utils/TkCximage/, utils/webcamsn/ and utils/linux/capture/ with creation of utils/TkCximage/TkCximage.so, utils/webcamsn/webcamsn.so, utils/linux/capture/capture.so, utils/linux/capture/libng/plugins/drv0-v4l2.so, and utils/linux/capture/libng/plugins/drv1-v4l.so. Then files .c, .h, .o can be deleted to save spaces in these directories.

    Disable logo: rename skins/default/pixmaps/logolinmsn.png (or comment the line ::skin::setPixmap logolinmsn logolinmsn.gif in gui.tcl, but there will be a blank line insteads).

    First post

    This post marks the registration date for this blog.