20 wonderful sights from Buzzfeed
- Amazon, South America
- Antelope Canyon, USA
- Uluru, Australia
- Bora Bora Island, Thaiti
- Victoria Falls, Zambia (or Zimbabwe)
- Fiord, Norway
- Santorini, Greece
- Iceland, North Atlantic Ocean
- Moraine Lake, Canada
- Petra, Jordan
- Machu Picchu, Peru
- Plitvice Lakes National Park, Croatia
- Great Barrier Reef, Australia
- Sistine Chapel, Rome
- Stone Henge, UK
- Taj Mahal, India
- Palace of Versailles, France
- Great Wall of China, China
- Angkor Wat, Cambodia
- Church of St. Mary of Zion, Ethiopia
HOWTO debug child process
On gdb prompt, type this.
(gdb) show follow-fork-mode
It may set parent mode. Then,
(gdb) set follow-fork-mode child
That’s it.
If you had a break point in the area of the child process, gdb automatically would switch to the child process.
For the further information, check THIS out.
Party Rock Anthem – [Walk off the Earth] + All About Maggie
It’s just awesome!! What a creative work!
walk off the earth
I really admire you guys. You are geniuses.
Get the absolute path of current shell script at runtime
I needed to know the absolute path of the shell script at runtime.
$PWD was not enough because the script could be executed from other directories
Thus, I googled and I got it.
# $SCRIPT_PATH is the absolute path of the directory in which the script is located.
SCRIPT_FILE_NAME=$(readlink -f "$0")
SCRIPT_PATH=`dirname "$SCRIPT_FILE_NAME"`
How simple it is!
How to replace words in multiple files automatically on linux
When you have bunch of files (may be over 100?), and want to replace words, you don’t want to handle them one by one. (If you have too much time, you can do one by one to spend time with some snacks and music.)
Here is the way automating the replace on command line.
find . -type f \( -iname "*" ! -iname ".svn" \) -exec egrep -l "$search_string" {} \; -print | sed -e ‘s/\ /\\ /’ | xargs -i perl -pi -e "s/$search_string/$replace_string/g" {}
$search_string is the words you want to change to $replace_string. If you have spaces in words, you shoud type space with backslash.
I had to replace “esp sha1 aes aes aes” to “esp null” in 255 configuration files whoes file names start with pol, so that I execute like below.
find . -type f \( -iname "pol*" \) -exec egrep -l "esp\ sha1\ aes\ aes\ aes" {} \; -print | sed -e ‘s/\ /\\ /’ | xargs -i perl -pi -e "s/esp\ sha1\ aes\ aes\ aes/esp\ null/g" {}
You’re welcome.
Seven social sins – Mahatma Gandhi
I suddenly felt I should remember this.
Mahatma Gandhi said,
- Politics without principles (신념없는 정치)
- Wealth without work (노동없는 부)
- Pleasure without conscience (양심없는 쾌락)
- Knowledge without character (인격없는 지식)
- Commerce without morality (윤리없는 비즈니스)
- Science without humanity (인성없는 과학)
- Worship without sacrifice (희생없는 종교)
A Brilliant Commercial
How brilliant!!
When you want Floating Point instruction in Kernel module.
CPU has FPU (Floating Point Unit), and some registers and instructions are related to FPU.
These don’t have any problem when operations are performed in user space.
BUT!!! How about in kernel module?
The registers related to FPU are not saved and restored when context switching occurs in kernel mode, so that many people suggest not to use FPU in kernel mode.
Unfortunately, there is inevitable situation.
I wanted to use AES-NI (AES New Instructions) which use xmm registers (related to FPU I guess) in kernel module.
Every time I called the function implemented with AES-NI, the kernel crashed with “device_not_available” exception and “math_state_restore” exception.
I did not know what happens with xmm registers in kernel module. After I googled, the solution poped up.
Here is the solution. (Extremely Simple!!)
Wrap the statements related to FPU with kernel_fpu_begin() and kernel_fpu_end().
// kernel_fpu_begin(); /* STATEMENTS (AES-NI related functions in my case); */ kernel_fpu_end(); //
How simple it is!!
When is __attribute__ ((regparm(0))) needed?
I wanted to use some assembly code into both a kernel module and a user space application.
A user space application worked find, but the kernel module was always crashed. (Oooops!!)
When I inspected the register, the argument value was wired.
The argument was the pointer value of a structure. It was obvious that the kernel crash because of the wrong argument value.
The reason was this.
1. The function implemented in assembly is implemented with getting argument within stack. (__cdecl calling convention)
2. The module passed the argument into the register directly. (__fastcall)
The solution is this.
1. When the caller declare the function (implemented in assembly), __attribute__ ((regparm(0))) is attached the very first of the declaration.
For example, __attribute__ ((regparm(0))) void a_functions(void* arg);
What does __attribute__ ((regparm(0))) mean?
1. This statement decides how many arguments pass in register directly, so that __attribute__ ((regparm(0))) means I do not want to the arguments passing with registers.
If you attach __attribute__ ((regparm(3))), the arguments passed with registers up to 3 of them. 4th argument is passed with the stack.
Until here, this is all I understood.