This is also very good shell feature, but many times I failed to use. I will encourage myself by posting this. Here we go.
Suppose I created a temp dir, and move to it.
$ pushd .
$ mkdir /tmp/lalala
$ cd /tmp/lalala
The last command can be easily made by, recall by arrow-up, ctrl-A, remove 'mkdir', and type cd. Not bad, but bash has better option.
$ pushd .
$ mkdir /tmp/lalala
$ cd !$
Confused or frowned for another cryptic symbol memorization? That was my first impression. But, actually not. It is very elegant usage.
! is history recall. As we usually do "$ !510" - recall command number 510 in history.
$ is regex. End of line. Then, we can think usage of '!^'.
$ cat a b c d e
$ cat !^
cat a
So, each run will remember previous argv vector, and we can call by placer(^,$).
Another nice feature. I am interested in middle one, like c in previous example.
$ cat a b c d e
$ cat !:3
cat c
Not bad. Here is another interesting one.
$ cat a b c d e
$ cat !:1-
cat a b c d
$ cat !:1-
cat a b c
Popping every argument..
In my opinion, this is a gift from bash for who think before hand. Someone who lavishes meaningless 'ls', like me, wouldn't get benefit. :)
Thursday, July 31, 2008
Tuesday, July 15, 2008
Transaction in MySQL
Personally, I use PostgreSQL. PostgreSQL is the most advanced open-source database. I am bravely saying that it is more advanced than MySQL is at the time of this writing. However, my department is running MySQL 5.0. I feel lucky that it is not MySQL 4.1. I have to migrate my current works stored in my desktop in postgresql to mysql. It is anticipated from the beginning, but I just didn't prepare.
The migration will not be hard, though. It is easy to convert postgres dump to mysql dump for import. I searched my favorite function, Transaction. To make transaction work, InnoDB must be used, which implies mysql should be compiled with support of InnoDB. Mostly it is true.
Here is one additional change to apply for postgres dump. Any create table statement should have something like this.
create table table_name ( ...description... ) TYPE=InnoDB;
Simple, but just wonder why InnoDB is not a default type, and who wants some table type without transaction support. Transaction on mysql is relatively new feature, on the other hand, PostgreSQL already supported long time ago. Oh well.. It is what it is. We use mysql, so be it.
The migration will not be hard, though. It is easy to convert postgres dump to mysql dump for import. I searched my favorite function, Transaction. To make transaction work, InnoDB must be used, which implies mysql should be compiled with support of InnoDB. Mostly it is true.
Here is one additional change to apply for postgres dump. Any create table statement should have something like this.
create table table_name ( ...description... ) TYPE=InnoDB;
Simple, but just wonder why InnoDB is not a default type, and who wants some table type without transaction support. Transaction on mysql is relatively new feature, on the other hand, PostgreSQL already supported long time ago. Oh well.. It is what it is. We use mysql, so be it.
Tuesday, June 24, 2008
Going back to Fedora Core
My recent Fedora Core 9 can be said successful. I still like Gentoo so much. But, in the work place, running gentoo may risk me to stay longer in the office. My choice of alternative is "Fedora Core 9".
I began this with Ubuntu 7.04 which was the left over from the previous. And switched to Kubuntu 8.04 with KDE4 three or four months later. Disappointed so much and tried Fedora Core 9. Thought about Open Suse, but FC was the next.
I tried Fedora Core just once about two years ago for a couple months. I guess it was FC6 or FC7. I switched to Gentoo when RedHat 9 became Fedora Core. So basically, I left RedHat world long time. I don't even remember how it was.
In short, Fedora Core changed a lot from where I stopped using. The biggest advantage of FC9 is very considerate default. Different from Ubuntu policy (literally enabling everything regardless of system resource for ease of use), FC focused more on lower level stability such as kernel API compatibility across the versions. Hibernate works very nice. Good for laptop. So, in kernel level, Fedora Core opens flexibility more, and it is stable more.
But don't get wrong with X11 crashes. That's not due to unstable kernel. That's because the gap between distro's open end and user failure to provide suitable driver. I believe this has been and will be the endless fight for Linux kernel and X11 driver.
I began this with Ubuntu 7.04 which was the left over from the previous. And switched to Kubuntu 8.04 with KDE4 three or four months later. Disappointed so much and tried Fedora Core 9. Thought about Open Suse, but FC was the next.
I tried Fedora Core just once about two years ago for a couple months. I guess it was FC6 or FC7. I switched to Gentoo when RedHat 9 became Fedora Core. So basically, I left RedHat world long time. I don't even remember how it was.
In short, Fedora Core changed a lot from where I stopped using. The biggest advantage of FC9 is very considerate default. Different from Ubuntu policy (literally enabling everything regardless of system resource for ease of use), FC focused more on lower level stability such as kernel API compatibility across the versions. Hibernate works very nice. Good for laptop. So, in kernel level, Fedora Core opens flexibility more, and it is stable more.
But don't get wrong with X11 crashes. That's not due to unstable kernel. That's because the gap between distro's open end and user failure to provide suitable driver. I believe this has been and will be the endless fight for Linux kernel and X11 driver.
Friday, June 13, 2008
KDE4: Gentoo, Kubuntu, and Fedora Core 9
I am okay with KDE4. There are still some quarks in KDE4, but generally I like how it is now. I can't explain detail of KDE4 in each distribution. In short, I dropped Kubuntu for KDE4. I agree that Ubuntu linux is doing a great work, but with KDE4, they need to catch up.
With Gentoo, things are smooth. Sure!! I pay huge compile time for this. In my work place, things are moving in fast phase. So, having gentoo isn't quite suitable. I chose Kubuntu when I had a chance to refresh my work desktop. Kubuntu KDE4 was pretty disappointing. One of most annoying example is that I couldn't move widgets in panel. Right click did not even offer "Move" option which I remembered it was there on Gentoo. So, I had to find another time to refresh my desktop. My desktop didn't find time to kick out Kubuntu, yet. I could flush and rebuild my laptop during the last weekend with Fedora Core 9. Still some issues, but much better than Kubuntu.
When I get a chance, I will compare rpm vs. deb. In short, deb is more convinent, but rpm is more flexible. dpkg(deb package) mainly uses package based dependancy and extends out to file based integrity check if it needs to. RPM, on the other hand, takes file based, but yum wraps these into package level and group level ( collection of packages ).
With Gentoo, things are smooth. Sure!! I pay huge compile time for this. In my work place, things are moving in fast phase. So, having gentoo isn't quite suitable. I chose Kubuntu when I had a chance to refresh my work desktop. Kubuntu KDE4 was pretty disappointing. One of most annoying example is that I couldn't move widgets in panel. Right click did not even offer "Move" option which I remembered it was there on Gentoo. So, I had to find another time to refresh my desktop. My desktop didn't find time to kick out Kubuntu, yet. I could flush and rebuild my laptop during the last weekend with Fedora Core 9. Still some issues, but much better than Kubuntu.
When I get a chance, I will compare rpm vs. deb. In short, deb is more convinent, but rpm is more flexible. dpkg(deb package) mainly uses package based dependancy and extends out to file based integrity check if it needs to. RPM, on the other hand, takes file based, but yum wraps these into package level and group level ( collection of packages ).
Thursday, May 29, 2008
to filter .svn view
find is a great tool. But, find treats all files and all directories equally including .svn dirs. Suppose we need to see the directory structure of a certain directory and issue this command:
$ find . -type d
If the current directory is under svn version control, find will show many .svn directories, too. Well, since find is a great tool, it will have some filtering functions, too. 'man find' and we can come up with this to filter out .svn.
$ find . -name .svn -prune -o -print
Hmmm.. We select non-.svn by inverting the result. But, we don't know it is a file or directory. Unix has another great tool called egrep.
$ find . -type d | egrep -iv ".svn"
We used invert matching not in find, but in egrep. Inspecting a directory will be much easier with these two tools. For svn specific, we can use 'ls' command on svn.
$ svn ls -R
But, ls isn't good for distinguish file or diectory.
$ find . -type d
If the current directory is under svn version control, find will show many .svn directories, too. Well, since find is a great tool, it will have some filtering functions, too. 'man find' and we can come up with this to filter out .svn.
$ find . -name .svn -prune -o -print
Hmmm.. We select non-.svn by inverting the result. But, we don't know it is a file or directory. Unix has another great tool called egrep.
$ find . -type d | egrep -iv ".svn"
We used invert matching not in find, but in egrep. Inspecting a directory will be much easier with these two tools. For svn specific, we can use 'ls' command on svn.
$ svn ls -R
But, ls isn't good for distinguish file or diectory.
Thursday, May 8, 2008
Python and DB2
We have a DB2 backend and I started to test it with PyDB2. Here is a tutorial link. In short, nothing is surprising. It uses standard python DBAPI interface with some good utility in DB2.db2util package.
Initially, I thought this client package would give different usage because DB2 client is different than postgres, mysql, or Oracle. However, PyDB2 is written well by supporting standard API.
Initially, I thought this client package would give different usage because DB2 client is different than postgres, mysql, or Oracle. However, PyDB2 is written well by supporting standard API.
Monday, May 5, 2008
Shell, Brace expansion
I found that I research this whenever I think of this function.
If I have to select file a,b,c only in /tmp, brace expansion is the answer. /tmp may have bunch of other files. Also repeating /tmp/a, /tmp/b, /tmp/c is annoying.
$ ls /tmp/{a,b,c}
Brace expansion is not used often, but when it is needed, it is super useful. I have to leave this note hoping that I have a place to lookup at least.
If I have to select file a,b,c only in /tmp, brace expansion is the answer. /tmp may have bunch of other files. Also repeating /tmp/a, /tmp/b, /tmp/c is annoying.
$ ls /tmp/{a,b,c}
Brace expansion is not used often, but when it is needed, it is super useful. I have to leave this note hoping that I have a place to lookup at least.
Subscribe to:
Posts (Atom)
