Thursday, December 3, 2009

twitter and google wave

After I use twitter and google wave, I am getting lazier on my blog. I may not post often enough, but somehow I should prepare something worth to read on my blog. I feel guilty.

Fedora Core 12 is good

I was late to post this, but I like Fedora Core. And not surprisingly, FC12 did not disappoint me. Again, well thought-through OS.

Monday, November 23, 2009


I am getting to love git.
I followed someone's post (using Subversion as a main repository in Dropbox). It was a wonderful idea. It was useful. But, svnroot on Dropbox makes nature a little awkward by svn design. And, peeking GIT rougly, it fits much better in Dropbox. So, I decided to learn, and it works out well.

The primary motivation is 'Lock vs. No Lock'. So, for VC using Dropbox, I recommend git.

Thursday, August 6, 2009

People who likes Twitter down.

Obviously, if twitter is down, This website will be very hot. I did the same thing :)

Bash, [C-xC-e] command editor

I found this accidentally and luckily. With predefined EDITOR env variable, C-xC-e will bring current command line into EDITOR. Regular expression based change can be applied.

I set up my EDITOR variable to 'emacs -q'.

Monday, July 20, 2009

Emacs, - for navigating buffers

One of emacs pain is 'too many key-strokes for a certain thing'. This xkcd partly shows this problem. But, true. Laughing at 'C-x r j "register"' is legitimate, especially from vim users. Vim way of 'doing a certain thing' is wicked fast. The key stroke that I describe is Emacs way of switching to a buffer. (OMG, 4 key strokes for just switching buffer??). Vim way is ':e "filename"' or ":bp", simpler than emacs way.

So, borrowing CTRL-TAB idea from windows, I installed buffer-stack.el, and bound keys for CTRL-TAB and CTRL-SHIFT-TAB. Easier to navigate. Hurray~

Monday, July 6, 2009

Swim, not that bad

This week, I reduced my swim by 5 seconds. I was only training 50 meters, and I could do 60 seconds for 50 meters. If I swim at 65 seconds for 50 meters, my breath was much smoother and I could go further. But, today's train was focused just for 50 meters.

I realized that I need more muscle. I definitely felt the resistance of my forearm pushing, but couldn't push hard enough. I feel so good!

Friday, June 26, 2009

Improving my swim

My shoulder muscle needs to improve. These days, my swim speed got better and my endurance level got better. It takes 70 seconds for 50 meter swim, 155 seconds for 100 meter swim. Better but, way worse than excellent swimmers. Olympic swimmers are less than 50 seconds for 100 meter.

I saw one of master swim person making 45 seconds for 50 meters consistently forever. At this time, my goal is 120 seconds for 100 meter. Long way to go.

Thursday, May 28, 2009

Oldies but Goodies

David Coverdale was one of the biggest influence of rock music history. His old songs are still touching. Here are two of my recent favorites. Sailing ships are originally played by Steve Vai. The guitarist on this video is Adrian Vandenberg.

Very famous "Soldier of Fortune". I don't need to comment/explanation, do I?
all the song that I have sung, echo in the distance,
like the sound of the windmill going round

Wednesday, May 27, 2009

keep watching this video.

Megadeth, Tornado of souls.
This song reminds my wild young life. I loved this song. I was just a stupid young rocker-wanna-be.
Anyway, very well performed live. Planning to buy this DVD.

Tuesday, May 12, 2009

Still using Emacs

I am still intimidated by Emacs internals. I can barely customise my emacs as I wish with lots of research. Sometimes, it looks counter-economic. To to a little thing, I have to pay the time price. I know modern technology of "Eclipse" or "Net Beans" to replace Emacs.
But, I still use Emacs because it is fun. No need to fall into debates of 'Eclipse is in the position where early Emacs was.' I just do this especially for fun of functional programming with Lisp.

Elisp isn't the same as Common Lisp. Functional programming sometimes was bothered by Object Oriented Programming knowledge. It is a different world. Just trust the 30 years of evolution of Emacs. It is Rock Solid.

I am taking an approach far from the perfect way. I just implement/tweak .emacs/.emacs.d as I need. I don't worry about Emacs API. Later when I find a piece that makes a better way to replace my stupid code, then I fix it. Sure I still need to design the code before a keystroke, but, I don't take serious design as I do in real life work.

Eclipse plugin can be also written using Java and Eclipse SDK. True... But not as enjoying and easy like Emacs. Eclipse SDK learning curve is far bigger than Elisp learning curve. No fun. And Eclipse plugin development seems more serious than Elisp customization.

"Hey, come back to modern world." I know, and I have to. If I work with Java, I will. But in Python perspective, I still love python-mode, rather than PyDev in Eclipse. Oh, yeah.. Way better. How does Eclipse handle Python natural "undeterministic code indentation"? Not better than Emacs "tab". How does Eclipse handle calendar library to ad-hoc insert "Today's date"? not better than Emacs "calendar" library. And in anything can happen on any place as Emacs does? Can Eclipse give a reference of individual open document (or buffer in emacs term)?

Most simply can Eclipse give a current position as a handle? Eclipse can be an IDE, but not an editor. It is not customizable.

Tuesday, April 28, 2009

CVS checking out behind webproxy

CVS is not a minor version control, yet. Especially for old projects like emacs still use CVS. One of my co-worker had hard time checking out emacs since our firewall blocks most of outgoing traffic. Luckily we have a web-proxy. Use this command.

cvs -z3 "-d:pserver;proxy=PROXY_SERVER;" co emacs

Thursday, March 12, 2009

Swimming, one recovery strategy

Today, I made another 12 lap swimming at one shot and didn't get tired. Total of around 40 some laps. At this point, doing many laps without improving swim skill is meaningless. So, I thought what will be the first one to fix?
I made several laps just checking as many I can see myself, and found I made inconsistent recovery especially on my left arm. Sometimes I make a splash during recovery. So, let's fix this during March.

Recovery is a procedure of an arm going back to front for the next swing. Each arm takes turn to propel. The best strategy to recover is to relax or spend the least energy to its original position. Splashing obviously isn't good. Splash by itself isn't bad. Drag after splash is bad. So, I took this approach. During recovery, focus on the elbow. Forearm just hang below elbow. While driving the elbow above the water, stay 'stream-lined'. That is important not to waste energy. At the final stage of recovery, Imagine that a hand opens a hole at the surface of the water, and put the entire arm through the hole. While doing this, the next swing starts and the body rotates. Obviously, this is the best time to initiate the propel.

So, again, at the final step of recovery,
1) push the arm through the imaginary hole,
2) kick the other foot to initiate hip rotation,
3) start the other arm swing. ( Remember the best efficient path of arm )
4) stretch for the stream line.

Swim is so much fun!

Monday, March 9, 2009

Swimming is just fun.

From beginning of this year, I began to swim. The whole first month was just struggling in the water, but after two months later, I can do 8 laps (200m) without taking a break. For me, the process to improve my swim was like tuning a sloppy software. But, in the end, nothing is more important than the fact that "Swimming is just so much fun."

Tuesday, February 24, 2009

Bash 4.0 released

I have not posted in Feb. But, I am not losing interest on my blog. Just my work was too busy and I was very tired at home.

Bash 4.0 is just released. Once again, I have to defer trying this out. I am still using fish. I like fish, but some features from bash are missed. In completion features, bash 4.0 didn't improve too much (as far as I read their change log.) So, I am not sure if I come back to bash.

Thursday, January 8, 2009

TCP segmentation example

Let's straight to the point.
Simply to make tcp segmented traffic, we need to turn off Nagle's algorithm. We can accomplish this with TCP_NODELAY option. I needed one for my test, but I couldn't find an example.
Since it is not that hard, I just wrote one. Don't expect too much in this example, however. I just needed this real quick, and wrote very sloppy. Here it comes:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#define handle_error(msg) \
    do { perror(msg); exit(EXIT_FAILURE); } while (0)

#define MAXDATASIZE 8192
#define SERVER_ADDR ""
#define SERVER_PORT 80
#define PAYLOAD "GET /index.html"
#define CHUNK 2 // chunk size. 2 byte segment for each.

int main()
    int sockfd, numbytes;
    char buf[MAXDATASIZE] = {0, };
    int optval;
    struct sockaddr_in srv;

    sockfd = socket(PF_INET, SOCK_STREAM, 0);
    if (sockfd == -1)
        handle_error("socket failed");

    optval = 1;
    if ( 0 > setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval))
        handle_error("sockopt, REUSEADDR");
    optval = 1;
    if ( 0 > setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *) &optval, sizeof optval))
        handle_error("sockopt, NO NAGLE");

    memset(&srv, '\0', sizeof srv);
    srv.sin_family = AF_INET;
    srv.sin_port = htons(SERVER_PORT);
    if ( 0 > inet_pton(AF_INET, SERVER_ADDR, &srv.sin_addr))
        handle_error("lookup fail");

    // CONNECT!
    if ( 0 > connect(sockfd, (struct sockaddr *)&srv, sizeof srv))
        handle_error("connect error");

    // Lazy: I'm not handling buffer overflow.
    strcpy(buf, PAYLOAD);
    int i;
    char sbuf[ CHUNK ];
    for (i=0; i<strlen(PAYLOAD); i += CHUNK) {
        strncpy(sbuf, buf+i, CHUNK);
        write(sockfd, sbuf, CHUNK);
        usleep(100000); // give time to clear the system call.
    write(sockfd, "\n\n", 2);

    if ((numbytes = recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1)
    buf[numbytes] = '\0';

    printf("client: received '%s'\n",buf);

    return 0;