Thứ Tư, 18 tháng 8, 2010

Cần phải tăng cân

Vì rất nhiều lý do khách quan (như chỗ ở không ổn định, không mang theo giày bata quần sóc, không có bếp nấu ăn) và 1 lý do chủ quan là em vừa mới ốm dậy vừa lười cho nên em không thể tập thể dục buổi sáng được.
Nhưng chiều nay nhìn bản mặt của em trong gương, em thấy mình cần phải thay đổi ... hình ảnh bản thân. Không thể má tóp mông teo, khuôn mặt lạt thếch như thế này mãi được.
Em quyết tâm lấy lại vóc dáng lắm, cơ mà vẫn chưa có điều kiện (lại bào chữa cho tính chần chừ lười nhác). Thôi thì chừ em sẽ lên dần kế hoạch ăn uống tập luyện. Khi nào ổn định chỗ ở xong, em sẽ
- Ăn 5 quả trứng gà / 1 tuần
- Uống 10 lít sữa / 1 tuần
- Ăn 200gr thịt bò / 1 tuần
- Ăn ít nhất 2 loại trái cây / 1 tuần
- Ngủ vào lúc 23h, thức dậy vào lúc 5rưỡi
- Hít đất và chạy bộ mỗi buổi sáng
- Nghỉ trưa 20'

Mục tiêu của em là được 50kg trước tết.

Trên đây là quyết tâm và kế hoạch của em. Chừng nào thực hiện, em sẽ cập nhật tình hình

Thứ Hai, 31 tháng 8, 2009

vim

A friend/colleague of mine is expert in emacs while I am just an amateur in vim :-( And he always says emacs is the best editor ever...
First comparison b/w emacs and vim: only emacs supports debug mode with gdb (that is we can debug and view current executed code concurrently). However I still decide to use vim in Unix as fluently as possible: first to work more efficiency, and second to prove that emacs is not the best (wasntme)
So, let's start with some useful links from gu-gle' ;)

... to be continued

Thứ Năm, 27 tháng 8, 2009

Shortcuts in Linux

Keyboard shortcuts (KS) free users from switching b/w keyboard and mouse (hence improve the manipulations). Below shows some frequency KS used in Linux environment also some common apps :


0. For general
- Alt Tab switch b/w app windows
- Alt Shift Tab switch backward b/w app windows
- Esc like Esc in Windows
- Ctrl End goto End
- Ctrl Home goto Home
- Ctrl L shortcut for "Open Locator" dialog. In desktop context => "Open Locator" will use file manager (ex: Nautilus) to open a folder. In editor apps context (ex: gedit) => "Open Locator" will open a file. In GNOME Terminal => like 'clear' command. In other apps context (ex: firefox, Nautilus) => will forcus on location/address bar
- Ctrl + zoom in (only for apps support zoom)
- Ctrl - zoom out (only for apps support zoom)
- F3 find next
- Ctrl F3 find previous
- F5 refresh
- Ctrl Alt Del log out
- Ctrl Z undo
- Ctrl Shift Z redo



1. For GNOME environment

1.0. General

- Alt F1 launch applications menu (like Win key in Windows)
-
Alt F2 launch "Run Application" dialog => Like Win R combined-keys in Windows, but more powerful (because Run Application can be used to start many applications located on $PATH)
-
Ctrl Alt L lock screen
-
Ctrl Alt D toggle show desktop (like Win D on Windows)
-
Print Screen take full screen shot
-
Alt Print Screen take screen shot of focused window
-
Alt Space open the window menu (like Right-Click on the top-left window)
-
F10 open first menu on leftside of menubar (usually open File menu)
-
Ctrl Alt Tab switch focus b/w the panel and the desktop, usually useful if switch to panel and select items located on panel
-
Ctrl Alt Left/Right move to previous/next virtual screen
-
Ctrl Alt Shift Left/Right take current window to next virtual desktop
- Alt F9 minimize current window
- Alt F10 maximize current window
- Alt F5 un-maximize current window
- How to change the default: by using Keyboard Shortcuts or Gconf editor
1.0.1. Keyboard Shortcuts
Launch Keyboard Shortcuts by: Alt F1 (launch Application Menu) -> type "Keyboard Shortcuts" on search menu. Then, change the global shortcuts for GNOME environment. Below are some useful modifications for me:
- F1 Launch help browser
- Windows W (Mod4 W) Launch web browser
- Windows E (Mod4 E) Launch Nautilus file explorer to Home folder
- Windows T (Mod4 T) Launch Terminal
- F11 Toggle fullscreen
1.0.2. Gconf editor (advanced GNOME settings)
On terminal, type gconf-editor to launch GNOME configuration. Besides
used to set the GNOME keyboard shortcuts (apps -> metacity -> global_keybindings), it also set application setting in GNOME, default web browser, etc.

1.1. GNOME Teminal
-
Ctrl L clear console (like 'clear' command)
- Shift Ctrl T (Ctrl Shift T) open new tab
- Shift Ctrl W
(Ctrl Shift W) close current tab
-
Ctrl PageUp/PageDown switch b/w tabs
- Shift Ctrl C (or Ctrl Insert) copy selected text
- Shift Ctrl V (or Shift Insert)pasted selected text
- Ctrl + increase size
- Ctrl - decrease size
- Ctrl 0 default size

1.2. Nautilus
-
Ctrl N open new Nautilus file explorer
-
Ctrl Shift N create new folder
-
Ctrl H toggle show/hide hidden files/folders
-
Ctrl L focus on location/address bar
-
Alt Home goto Home folder
-
Alt Enter open file/folder Properties dialog
-
F9 toggle left-side-panel
- Ctrl T open new tab
- Ctrl W close current tab
- Ctrl PageUp select previous tab
- Ctrl PageDown select next tab


2. For KDE environment


2.0. General

-
Alt F2 execute command
-
Ctrl B add bookmark
-
Ctrl Esc list of running apps
-
Ctrl W close
-
Alt F1 popup KDE launch menu
-
Alt F3 window open menu
-
Ctrl Insert insert text

- How to change the default


3. For specific applications


3.1. Firefox

-
Ctrl T new tab
-
Ctrl W close tab
- Ctrl Shift T undo close tab
- Ctrl PageUp/PageDown switch b/w tabs
- Ctrl N new window
- Alt F4 close window
-
Ctrl L focus on location/address bar
- Ctrl K focus on search bar
-
Ctrl B open bookmark
- Ctrl D bookmark (via Delicious)
- Backspace back navigation (like Back button)
- Shift backspace forward navigation (like Forward button)
- F5 refresh
- Ctrl F5 refresh override cache
- Esc stop loading page
- F6 switch b/w window frames. It is useful in switching back to main frame (which contains web page) from location/address/search bar
- F7 toggle from mouse browsing and
caret browsing. Caret browsing allow us to select text/link via keyboard
- Ctrl I show page infor
- Ctrl U show page source
- Ctrl + zoom in
- Ctrl - zoom out
- Ctrl 0 zoom to default
- Ctrl F find
- F3 find next
- Shift F3 find previous
- ' only find hyper-link in web page
- Alt Home (only used if search-bar focused) open current web page in another tab
- F11 toggle full screen mode
- Ctrl Shift Y open download dialog
- Ctrl Shift P toggle private browsing
- Ctrl Shift Delele open "Clear Recent History" dialog
- Ctrl Shift J open Error Console
- Ctrl Left (only used if a tab focused) move a tab left

- Ctrl Right (only used if a tab focused) move a tab right
- Ctrl Home (only used if a tab focused) move a tab to beginning
- Ctrl End (only used if a tab focused) move a tab to end

3.2. SCIM
-
Shift Space trigger SCMI mode (switch b/w US keyboard and Telex mode, etc ...) when we are in textbox, textfield.
-
Ctrl Space same as Shift Space, but should avoid in Eclipse (for auto completion)

3.3. Krusader
- Ctrl W close current tab
- Shift Left move to previous tab
- Shift Right move to next tab
- Ctrl PageUp goto parent folder
- Ctrl S search
- Ctrl . toggle display hidden folder
- F2 open terminal
- F3 view file
- F4 edit file
- F5 copy
- F6 move
- F7 make dir
- F9 rename
- And should change the default keyboard shortcuts (Settings -> Configure shortcuts) as below
+ Ctrl T duplicate current tab

3.4. Banshee


To be continued ...

Thứ Bảy, 1 tháng 8, 2009

UML: aggregation v.s composition

Assume we have above class diagram. The relationship b/w CardList and Card is aggregation, and the one b/w Deck and CardList is composition.

The main difference b/w aggregation and composition is:
- Aggregation: Card can independently exist with CardList. This means when CardList object is destroyed, Card object is still alive until we destroy it explicitly.
The generated code may looks like
class CardList
{
//some code
Card *_contents[];
//some code
}
'Coz _contents is an array of
pointer, it independently exist with CardList. Therefore, in aggregation relationship, we MUST call delete to avoid memory leak.

- Composition: CardList life depends on Deck. This means when a Deck object is destroyed, CardList object also destroyed.
The generated code may looks like
class Deck
{
//some code
CardList _cards;
//some code
}
'Coz _cards is an
object (NOT a pointer), it will be destroyed when a Deck object destroyed. Therefore, with composition relationship, we don't care about delete contained object.

C++: data member initialization

Assume we have this class:
class A
{
public:
A(int x, int y, char z);
void getValues(int &x, int &y);
private:
int a;
int b;
const char c;
};

void A::getValues(int &x, int &y)
{
x = a; y = b;
}

The questions are:
1. How to initial constant data member c ?
2. How to initial a and b ?

And here are the answers:
1. Since
c is a constant, the ONLY way to init c is:
A::A(int x, int y, char z) : c(z)
{
// do sth
}

2. There are 2 ways:
- The 1st one
A::A(int x, int y, char z) : a(x), b(y), c(z)
{
//do sth
}
- The 2nd one
A::A(int x, int y, char z) :c(z)
{
a = x;
b = y;
//do sth
}

Then, here are couple of questions
2.1. What is the different b/w 2 above methods?
---> The 1st one is faster, because there's no need to create default values for
a and b before assign real value to it like the 2nd one.

2.2. In the 1st method, can we reverse order like this
A::A(int x, int y, char z) : b(y), a(x), c(z)
{
//do sth
}
--> It depends on compiler.
* Using GNU C++ compiler, there is a warning:
..\FooBar.cc:35: warning: `A::b' will be initialized after
..\FooBar.cc:34: warning: `int A::a'
..\FooBar.cc:40: warning: when initialized here

This is because
a is declared before b (in class declaration), so compiler expects a stands before b in initialized-list.
The result of
getValues() is correct when executed in this case.
* Using C++ compiler for ALU (OneBTS) project, however,
getValues() returns strange values.

=> Keep in mind the precedence of data member in class declaration and initialized-list, because a mistake in this will lead to un-expected result.

Thứ Bảy, 25 tháng 7, 2009

Unix command: stty

stty is a command which changes the behavior of terminal line setting. The usage can be found in its manual page.
There are some useful options:
- List out current terminal line setting:
stty -a
- Prevent character printed out while input via keyboard (useful in enter passwd):
stty -echo
- Permit character printed out while input via keyboard:
stty echo
- Handle each input character per time instead of one line per time (useful in handle special character):
stty cbreak
- Handle each input line per time (the default behavior):
stty -cbreak

Thứ Năm, 23 tháng 7, 2009

Perl comments

Perl is simple and powerful in automation; but quite ambiguous and lack of user-defined data structure.