Friday, November 30, 2012

Windows 7: Japanese not displaying in Windows

SkyHi @ Friday, November 30, 2012
Your problem probably stems from the fact that you're font chache probably is corrupted; delete the fileC:\Windows\system32\FNTCACHE.DAT and restart, your problem should be solved.


Windows XP had a “supplemental language support” section under Regional and Language options. You had to select them and perform the installation (which required the CD and was annoying) if you wanted to work with Asian languages. This was removed with Vista and support for these languages came by default. Windows 7 turns out to be a little different, however.
I usually do not find what Microsoft chooses to hide from the UI very useful. Why do I need to hit the alt key to see the file menu for example? This started with Internet Explorer and seems to be applied to other apps as well, including Windows Explorer. All of a sudden, the menu disappeared… Yes, it provides a little more space on the screen, but that space is not very useful as menu bar is not located at direct eye sight anyway. Does anybody browse the Internet full screen? No.
Lets get back to the Font issue. I launched an html document with Japanese strings in Notepad and was presented with a bunch of boxes! Boxes are how Windows expresses “I don’t know how to display this character”. I went to Format > Font to pick a font which supports Japanese script but none existed! Ah, must be the newest victim of Microsoft hiding team…
Windows 7 hides fonts depending on your language settings. Go to Control panel > Fonts > Font settings and uncheck “Hide fonts based on language settings”
Hiding the fonts is supposed to simplify the font selection in applications. I am not sure which applications are targeted for this but Notepad is definitely not one of them. The font selection dialog has always been and is still far from being user friendly and having 80 fonts instead of 200 doesn’t really provide any improvement.
I picked MS Minco for the font and Japanese for the script and there we go. No more boxes!


REFERENCES
http://superuser.com/questions/372928/windows-7-japanese-not-displaying-in-windows
http://www.emreakkas.com/windows-tips/how-to-enable-hidden-fonts-in-windows-7
http://mangahelpers.com/forum/showthread.php/3709-How-To-Enable-Japanese-Language-Windows

Thursday, November 29, 2012

Find command: Exclude / Ignore Files ( Ignore Hidden .dot Files )

SkyHi @ Thursday, November 29, 2012


Q. How do I ignore hidden .dot files while searching for files? How do I ignore or exclude certain files while running Linux / UNIX find command?

A. Find command support standard UNIX regex to match or exclude files. You can write complex queries easily with regex.

Find command and logical operators

Find any file whose name ends with either 'c' or 'asm', enter:
$ find . -type f \( -iname "*.c" -or -iname "*.asm" \)
The parentheses must be escaped with a backslash, "\(" and "\)", to prevent them from being interpreted as special shell characters. The -type f option force to only search files and not directories. The or operator either find .c or .asm file.

Understanding find command operators

Operators build a complex expression from tests and actions. The operators are, in order of decreasing precedence:
( expr )Force precedence. True if expr is true
expr
-not expr
True if expr is false. In some shells, it is necessary to protect the ‘!’ from shell interpretation by quoting it.
expr1 -and expr2And; expr2 is not evaluated if expr1 is false.
expr1 -or expr2Or; expr2 is not evaluated if expr1 is true.
WARNING! The '-or', '-and', and '-not' operator are not available on all versions of find. Usually GNU find supports all options. Refer your local find command man page for more information.

How do I ignore hidden .dot files while searching for files?

Find *.txt file but ignore hidden .txt file such as .vimrc or .data.txt file:
$ find . -type f \( -iname "*.txt" ! -iname ".*" \)
Find all .dot files but ignore .htaccess file:

REFERENCES
http://www.cyberciti.biz/faq/find-command-exclude-ignore-files/

Find Command Exclude Directories From Search Pattern

SkyHi @ Thursday, November 29, 2012


How do I exclude certain directories while using the find command under UNIX or Linux operating systems?

You can use the find command as follows to find all directories except tmp directory:
find /path/to/dest -type d \( ! -name tmp \) -print
Find all directories except tmp and cache:
find /path/to/dest -type d \( ! -name tmp \) -o \( ! -name cache \) -print
The -prune option make sure that you do not descend into directory:
find /path/to/dest -type d \( ! -name tmp \) -o \( ! -name cache -prune \) -print
You can find all *.pl find except in tmp and root directory, enter:
find /  \( ! -name tmp \) -o \( ! -name root -prune \)  -name "*.pl" -print


References
http://www.cyberciti.biz/faq/linux-unix-osx-bsd-find-command-exclude-directories/

Saturday, November 24, 2012

A Tmux Crash Course

SkyHi @ Saturday, November 24, 2012

I’ve been using Tmux for about six months now and it has become just as essential to my workflow as vim. Pane and window management, copy-mode for navigating output, and session management make it a no-brainer for those who live in the terminal (and especially vim). I’ve compiled a list of tmux commands I use daily to help me work more efficiently.
Tmux Panes
If a tmux command I mention is bound to a keyboard shortcut by default, I’ll note that in parenthesis.

SESSION MANAGEMENT

Sessions are useful for completely separating work environments. I have a ‘Work’ session and a ‘Play’ session; in ‘Work’, I keep everything open that I need during my day-to-day development, while in ‘Play’, I keep open current open-source gems or other work I hack on at home.
tmux new -s session_name
creates a new tmux session named session_name
tmux attach -t session_name
attaches to an existing tmux session named session_name
tmux switch -t session_name
switches to an existing session named session_name
tmux list-sessions
lists existing tmux sessions
tmux detach (prefix + d)
detach the currently attached session

WINDOWS

Tmux has a tabbed interface, but it calls its tabs “Windows”. To stay organized, I rename all the windows I use; if I’m hacking on a gem, I’ll name the window that gem’s name. The same thing goes for client applications. That way, I can recognize windows by context and not what application it’s running.
tmux new-window (prefix + c)
create a new window
tmux select-window -t :0-9 (prefix + 0-9)
move to the window based on index
tmux rename-window (prefix + ,)
rename the current window

PANES

Panes take my development time from bland to awesome. They’re the reason I was able to uninstall MacVim and develop solely in iTerm2. I don’t have to switch applications to switch contexts (editing, reading logs, IRB, etc.) - everything I do, I do in a terminal now. People argue that OS X’s Cmd+Tab is just as fast, but I don’t think so.
tmux split-window (prefix + ")
splits the window into two vertical panes
tmux split-window -h (prefix + %)
splits the window into two horizontal panes
tmux swap-pane -[UDLR] (prefix + { or })
swaps pane with another in the specified direction
tmux select-pane -[UDLR]
selects the next pane in the specified direction
tmux select-pane -t :.+
selects the next pane in numerical order

HELPFUL TMUX COMMANDS

tmux list-keys
lists out every bound key and the tmux command it runs
tmux list-commands
lists out every tmux command and its arguments
tmux info
lists out every session, window, pane, its pid, etc.
tmux source-file ~/.tmux.conf
reloads the current tmux configuration (based on a default tmux config)

MUST-HAVES

These are some of my must-haves in my tmux config:
# remap prefix to Control + a
set -g prefix C-a
unbind C-b
bind C-a send-prefix

# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf

# quick pane cycling
unbind ^A
bind ^A select-pane -t :.+

WORKFLOW

During the day, I’ll work on one or two Rails apps, work on my dotfiles, run irssi, and maybe run vim in another window to take notes for myself. As I mentioned, I run all of this inside one tmux session (named work) and switch between the different windows throughout the day.
When I’m working on any Ruby work specifically, I’ll have a 75%/25% vertical split for vim and a terminal so I can run tests, interact with git, and code. If I run tests or ‘git diff’ and want to see more output than the 25% allots me, I’ll use tmux to swap the panes and then move into copy mode to see whatever I need to see.
Finally, I run iTerm2 in full-screen mode. Switching between OS X apps for an editor and a terminal is for chumps!



REFERENCES
http://robots.thoughtbot.com/post/2641409235/a-tmux-crash-course

Friday, November 23, 2012

How to Locate Windows Live Mail Store Folder

SkyHi @ Friday, November 23, 2012

All emails of Windows Live Mail are saved in Windows Live Mail Store Folder location. Windows Live Mail uses thestandard EML format and creates folders for each user where all EML files are stored.
This Guide will help you know answers to your question like – “Where does Windows Live Mail store messages?”, “Where does Windows Live Mail store contacts?”, “Where does Windows Live Mail store its files?” & “Where does Windows Live Mail Store my emails?”.

Identify & Locate Your Windows Live Mail Store Folder

To identify the folder where Windows Live Mail stores all EML files follow the below steps:
  1. Open Windows Live Mail, Select Tools | Options from Windows Live Mail toolbar. This will display following Options box:

    Locate Windows Live Mail Store Folder
  2. From the Options box go to the Advanced Tab then click the Maintenance button as shown below:

    How to Locate Windows Live Mail Store Folder?

  3. From the Maintenance box, Click the Store Folder button as shown below:

    Identify Windows Live Mail Store Folder
  4. Now this will display the following box having store folder location as shown below:

    Windows Live Mail Store Folder Location
In Windows Live Mail Store location, you can find respective folders for all the users configured in Windows Live Mail. In each users folder all EML Files are stored.
Knowing the location of where does windows live mail store messages & contacts, you can easily review & archive Windows Live Mail emails (.EML files) & you can easily import EML filesconvert Windows Live Mail to Outlookconvert EML to PST .

REFERENCE

Wednesday, October 24, 2012

Partitioning and Formatting Second Hard Drive in Linux - (ext3 and ext4)

SkyHi @ Wednesday, October 24, 2012

Recently, I bought an external hard disk formatted with NTFS. Not that there is something really wrong with NTFS but I prefer using ext4.
First, I deleted the existing partition and created a new Linux partition using fdisk:
?
1
# fdisk /dev/sdb
Assuming /dev/sdb is the external hard disk. Use d to delete the partition and use n to create a new partition. 83 is the ID of the native Linux partition.
Them, I use mkfs.ext4 to format the partition with ext4:
?
1
# mkfs.ext4 /dev/sdb1
Note that mkfs.ext4 expects a partition as its argument.
Finally, I use tune2fs to adjust some parameters: // don't need this
?
1
2
# tune2fs -m 0 /dev/sdb1
# tune2fs -L bakap01 /dev/sdb1
The -m option is for adjusting the percentage of reserved blocks. The reserved blocks are used by privileged processes which is by default 5% of the hard disk size. Since I’m using the external hard disk solely as a storage, I set this to 0 so I can also use those 5% for storage. The -L option is for labeling the filesystem.



Introduction

This article presents the commands used to partition and format a second hard drive in Linux using the ext3 file system. For the purpose of this example, I installed a second hard drive in a Red Had Linux system where the drive is recognized as /dev/hdb. I want to make only one partition on this hard drive which will be /dev/hdb1.

fdisk

First, you will need to run the fdisk command in order to partition the disk. For this example, I only want to create one ext3 partition. Here is an example session:
[root@racnode1 ~]# fdisk /dev/hdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 4865.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-4865, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-4865, default 4865): 4865

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 83

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Create ext3 File System

The next step is to create an ext3 file system on the new partition. Provided with the distribution is a script named /sbin/mkfs.ext3. Here is an example session of using themkfs.ext3 script:
[root@racnode1 ~]# mkfs.ext3 -b 4096 /dev/hdb1
mke2fs 1.27 (8-Mar-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
4889248 inodes, 9769520 blocks
488476 blocks (5.00%) reserved for the super user
First data block=0
299 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Mounting the File System

Now that the new hard drive is partition and formated, the last step is to mount the new drive. For this example, I will be mounting the new hard drive on the directory /db.
 
You will first need to create the /db directory before mouting the disk! (e.g. mkdir /db)
Edit the /etc/fstab file and add an entry for the new drive. For my example, I will create the /dev/hdb1 entry as follows:
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/shm                tmpfs   defaults        0 0
/dev/hdb1               /db                     ext3    defaults        1 1
/dev/hda2               swap                    swap    defaults        0 0
/dev/cdrom              /mnt/cdrom              iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0
After making the entry in the /etc/fstab file, it is now just a matter of mounting the disk:
[root@racnode1 ~]# mount /db

[root@racnode1 ~]# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda3             37191660  11016692  24285724  32% /
/dev/hda1               101089     12130     83740  13% /boot
none                    515524         0    515524   0% /dev/shm
/dev/hdb1             38464340     32828  36477608   1% /db



  237  dmesg
  238  df -h
  239  fdisk -l
  240  fdisk /dev/sdb (n -> p-> default to rest)
  247  mkfs.ext4 /dev/sdb1
  261  mount -t ext4 /dev/sdb1 /opt


REFERENCES
http://blag.borap.net/2011/08/10/formatting-an-external-hard-disk-with-ext4/
http://ashok-linux-tips.blogspot.ca/2011/05/createconvert-ext2-or-ext3-or-ext4.html
http://www.idevelopment.info/data/Unix/Linux/LINUX_PartitioningandFormattingSecondHardDrive_ext3.shtml

Monday, October 22, 2012

Hard Disk: BadCRC errors from dma_intr on bootup

SkyHi @ Monday, October 22, 2012

If dma is enabled on a controller that is not well supported, these errors can appear. ( I had it on a VIA KT266a with kernel 2.2. Upgrading to kernel 2.4 fixed it beautifully.
If you are sure that the IDE controller is supported, the drive is on its way out. You can run fsck with the badblock option turned on to mark these blocks as bad... As a rule, once these errors start, we throw the disk away(This is a high availability production environment).
If you dont mind that the disk can crash in the near future, make a backup and continue using it, it might work for a long time to come.
If the disk is under guarantee... take it back, it is not worth risking data loss if the drive can be replaced for free.
This is how you hunt for and fix badblocks.
# e2fsck -c /dev/hda1
Make sure that you have a backup, badblock scans can destroy data running with certain switches.
# man badblocks && man e2fsck (And read them carefully)
To turn of dma per drive
# hdparm -d0 /dev/hd[a-d]
To list dma settings
# hdparm -d /dev/hd[a-d]
To turn dma on
# hdparm -d1 /dev/hd[a-d]
Where hd[a-d] is hda, hdb, hdc, hdd.

REFERENCES
http://linuxgazette.net/issue76/tag/10.html