How to Type Simplified Chinese using Pinyin on Mac OS X

There is no special reason but I’ve just started learning Chinese. Well, I am a big fan of Chinese food and personally I’ve been to China a couple of times. There must have been a potential desire for learning it. Here is a kind of tips for a beginner like me – “How to Type Chinese”.

First of all, go to System Preferences, then lick on the Language & Text icon. Click on “Chinese – Simplified” flag, and select “Pinyin – Simplified”.


Typing Chinese Pinyin on Mac OS X

Then you can select “Pinyin – Simplified” as you input language by hitting “Command + Space”. Just hit “Command + Space” until “Pinyin – Simplified” is selected.


Typing Chinese Pinyin on Mac OS X

Now you can type pinyin and see the corresponding characters popup. You can choose one of the characters by either typing space or the corresponding number. For exsample, let’s type this following pinyin. You’ll see the corresponding Simplified Chinese characters. That’s it!


Typing Chinese Pinyin on Mac OS X

Posted in: Chinese

Tags: , ,

How To Button Single Breasted Suit Buttons

About leaving the bottom button open on single breasted suit, there is the following great lessons by The Art of ManlinessArt of Manliness Suit School-Part III: A Primer on Suit Buttons:

1) One Button Suits:
One button suits are the easiest to remember. The button should always be buttoned when standing and unfastened when one sits down.

2) Two Button Suits:
Two button suits are also simple. The top button should remain buttoned, while the bottom button is left undone.

3) Three Button Suits:
With three buttons, you have options. You can either button the top two and leave the bottom unfastened, or simply button the center button.

April. It is the season when new employees who wrap the body in a new suit overflow in the town. I often see that a young man buttons all buttons on single breasted suit without knowing the basic suit manners. Each time, I feel like teaching him how to button suit buttons. Yes I was like the young man when I was a new employee. On the other hand, it is every once in a while but there is a time when I see a man old enough to know the basic buttons all the buttons of single brested suits. I will not say anything about it.

Posted in: Random Topics

Tags: ,

BIOS Setup to Run Hyper-V on Dell T5400

If the following alert dialog message comes up while you’re running Hyper-V, you probably need to make some BIOS setting for virtualization.

The virtual machine could not be started because the hypervisor is not running. The following actions may help you resolve the problem:
1) Verify that the processor of the physical computer has a supported version of hardware-assisted virtualization.
2) Verify that hardware-assisted virtualization and hardware-assisted data execution protection are enabled in the BIOS of the physical computer. (If you edit the BIOS to enable either setting, you must turn off the power to the physical computer and then turn it back on. Restarting the physical computer is not sufficient.)
3) If you have made changes to the Boot Configuration Data store, review these changes to ensure that the hypervisor is configured to launch automatically.

In the case of Dell Precision T5400,  the following 3 BIOS settings change need to be done:

  • Security – Execute Disable: On
  • Performance – Virtualization: On
  • Performance – VT for Direct I/O Access: On

After the BIOS setup made, just choose “Save & Exit” in order to reflect the changes. Then try it again. you will be able to connect & start your Hyper-V Virtual Machine. Enjoy Hyper-V!

Environment Info:  Hyper-V/Windows 2008 Server RC2 Enterprise/Dell Precision T5400

Posted in: Environment Setup

Tags: , , ,

Compile Objective-C using GNUstep on Non-Mac OS

For those who want to play with Objective-C without having a mac (+ XCode IDE), GNUstep is the way to go. It enables you to develop programs in Objective-C on many platforms like *nix and even Windows. This time, I installed GNUstep on debian, and compiled and ran some Objective-C programs.

What’s GNUstep?

Probably you may know Apple’s Cocoa , Objective-C developmet frameworks(was known as NeXTSTEP many years ago). GNUstep is a GNU clone which not only is compatible with the Cocoa but also supports cross platform!

GNUstep provides a robust implementation of the AppKit and Foundation libraries as well as the development tools available on Cocoa, including Gorm (the InterfaceBuilder) and ProjectCenter (ProjectBuilder/Xcode). GNUstep currently supports Unix (GNU/Linux and GNU/HURD, Solaris, NetBSD, OpenBSD, FreeBSD, Darwin) and Windows.GNUstep Overview

Installing GNUstep on debian

First of all install the following 2 debian packages which are very fundamental for GNUstep development. The version of debian on which I tried it is 5.0.4.

- gnustep – The GNUstep Development Environment — user applications
- gnustep-devel – The GNUstep Development Environment — development tools

$ sudo apt-get install gnustep
$ sudo apt-get install gnustep-devel

If you are not debian user, find out GNUstep packages for the platforms you use from here.

Compiling Objective-C code with GNUstep

main.m

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSString *noncap = @"how do you like wednesday?";
    NSString *cap;
    cap = [noncap capitalizedString];
    NSLog(@"output = %@", cap);
    [pool release];
    return 0;
}

I coded a simple program above that captalize a string “how do you like wednesday?”. Now I want to compile it. But before that, make sure that gcc (>4.6) is installed on your platform. If not installed, just install it.

1. Compiling by executing gcc command line

gcc `gnustep-config --objc-flags` `gnustep-config --objc-libs` -lgnustep-base -o main main.m

gnustep-config is a usuful command that provides information on the current gnustep installation. gnustep-config’s –objc-flags option prints all the flags required to compile an ObjC file, and –objc-libs option prints all the flags required to link a GUI ObjC program.

$ gnustep-config --objc-flags

-MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1
-DGNUSTEP_BASE_LIBRARY=1 -D_REENTRANT -fPIC -g -Wall -DDEBUG -fno-omit-frame-pointer
-DGSWARN -DGSDIAGNOSE -Wno-import -g -fno-strict-aliasing -fexceptions
-fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -fgnu-runtime
-fconstant-string-class=NSConstantString -I. -I/home/kawasaki/GNUstep/Library/Headers
-I/usr/local/include/GNUstep -I/usr/include/GNUstep
$ gnustep-config --objc-libs

-rdynamic -shared-libgcc -fexceptions -fgnu-runtime
-L/home/kawasaki/GNUstep/Library/Libraries -L/usr/local/lib -L/usr/lib -lpthread -lobjc -lm

2. Compiling by Makefile, a little more sophisticated way

As a different way, you can create a Makefile for the program to compile. I created the following Makefile using examples from “A GNUstep Programming Tutorial

GNUmakefile

GNUSTEP_MAKEFILES=$(shell gnustep-config --variable=GNUSTEP_MAKEFILES)
include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME=SampleCode
SampleCode_HEADERS =
SampleCode_OBJC_FILES = main.m
SampleCode_RESOURCE_FILES =

include $(GNUSTEP_MAKEFILES)/tool.make

After you compile it with either way, finally you can execute the compiled program. Its output will be like this:

2012-03-16 01:48:18.355 SampleCode[17756] output = How Do You Like Wednesday?

Enjoy Objective-C programming with GNUStep!

REFERENCES

Posted in: Programming

Tags: , , , , ,

Transferring data with On-The-Fly Compression Using SSH and SCP

If you need to transfer large size files over very slow network, and if these files are not yet compressed, the following techniques effectively save your time and the bandwidth needed.

1. SCP Compress Option

SCP‘s -C option enables on-the-fly compression. Transfering an achive.log(/var/tmp/archive.log) using scp with compress option from a remote server to local:

scp -C -p <remote.server>:/var/tmp/archive.log /var/tmp

2. On-the-fly compression using SSH and TAR

Compressing ‘archive.log’ with tar, sending its output to STDOUT, and then piping it from remote server to STDIN of local:

ssh <remote.server> "tar zcpf - -C /var/tmp archive.log" | tar zxpf - -C /var/tmp

Speed Comparison

I tested them with and without on-the-fly compression and measured their real time. I transferred a large size file, archive.log which takes up about 1.1G disk usage from a remote server named “sakura” to local machine.

[case1]
transfer without on-the-fly compression
executed: scp -p sakura:/var/tmp/archive.log /var/tmp
elapsed time: 9min 23sec

[case2]
transfer with on-the-fly compression using SCP's -C option
executed: scp -C -p sakura:/var/tmp/archive.log /var/tmp
elapsed timed: 43 sec

[case3]
transfer with on-the-fly compression using SSH and TAR
executed: ssh sakura "tar zcpf - -C /var/tmp archive.log" | tar zxpf - -C /var/tmp
elapsed time: 36 sec

Do compress and make the most of your CPU power, then you can finish it In a shorter period of time!

Posted in: Random Topics

Tags: , ,