I recently upgraded my netbook’s OS to Ubuntu 11.10 and noticed that it’s taking longer than usual to launch programs that I use quite often. For example, it takes 7-8 seconds to launch Google Chrome, about 4 seconds to open terminal. Here’s what I did to make the os run faster without investing with a SSD disk (My root partition is using ext4 fs, skip step 1 through 3 if you are using file systems other than ext3 or ext4):
1. Add the following bold part to the root partition line in /etc/fstab
tune2fs -o journal_data_writeback /dev/sda5
/dev/sda5 is the root partition.
3. change the following line in /etc/default/grub
(bold part is added)
4. Run update-grub
5. Add the following line to /etc/sysctl.conf
NOTE: all the above changes require root privileges.
The difference? It now takes about 3-4 seconds to launch Google Chrome from cold start.
The currently stable version (3.1.7) of Tunnelblick would cause a kernel panic in Mac Lion while a connection is being made. Workaround is to use a beta version (3.2beta28) which is available at http://code.google.com/p/tunnelblick/downloads/detail?name=Tunnelblick_3.2beta28.dmg, released 7/31/2011.
[Edit 8/18/2011] Just updated Lion to 10.7.1 last night and version 3.2beta28 seems to be unstable as well. It has caused kernel panic two times in a row.
Need to keep looking for a version that works. Did a re-installation of the same version and it works afterwards.
Default is set to 604800 (7 days, bloodily stupid value chosen by M$?)
Change to a smaller amount, for example, 86400 (1day) or even 3600 (1 hour) if the OS is running some time-sensitive stuff.
A system restart is required for the new setting to be in effect.
After upgrading to Lion I noticed that the Homebrew theme that I’ve been using since Snow Leopard doesn’t display colors correctly(using different colors for directories, different types of files etc.) any more when working on remote hosts via ssh (local dir colors still work though) and switching to other themes doesn’t help. After messing around with the Terminal settings I finally found the cause and a solution. It seems Lion changed the terminal type to xterm-color256 during the upgrade (don’t remember what the setting was in SL though). The solution is simple enough, just change the emulation type for terminal from xterm-color256 to xterm-color (see screenshot below).
[ Update 1/2/2012 ]
Actually found a better solution here:
1. Keep the current xterm-256color in your Mac Terminal
2. Add the following lines to your ~/.profile on your remote host
[ "$TERM" = "xterm" ] && TERM="xterm-256color" alias ls='ls --color'
Found from http://httpd.apache.org/docs/1.3/configuring.html [ first section ]
Usually I use the following method to compare two mysql tables with identical structure (or one contains the subset of columns of the other):
select * from db_A.tbl_data
where (col1, col2, col3, ...) not in
(select col1, col2, col3, ... from db_B.tbl_data);
select * from db_B.tbl_data
where (col1, col2, col3, ...) not in
(select col1, col2, col3, ... from db_A.tbl_data)
[ change * to count(*) if only the number of differences is needed ]
This method works pretty well in terms of performance when
1) number of columns to be compared is not too big, usually around 10
2) there are indexes defined in each table, this is very important when number of rows to be compared in each table is huge, I’lve done comparisons between 2M rows agains 2M rows, it can take minutes to finish, even with indexes.
But I ran into performance problem the other day when I tried to compare two identical-structured tables (comparing all 15 columns) with almost 3M rows each, and each table has only 1 index defined. Queries using the first method ran very slowly and I quickly used up patience ( I waited for more than half an hour and even the first query couldn’t got finished). Without other choices, I came up with the following solution:
a) log in to mysql server
b) select * from db_A.tbl_data into outfile '/tmp/outfile_A';
c) select * from db_B.tbl_data into outfile '/tmp/outfile_B';
d) exit mysql console
e) cd /tmp; diff outfile_A outfile_B > diff
f) wc -l diff
if the result from f) is small, I can open up file diff with an editor to see what the differences are, otherwise I can use head diff and/or tail diff to take a glance at the differences. With this method, I got the results in less than 3 minutes, which is a huge improvement compared to the first method.
Here’s how I got stuck:
1) Remote access to a linux serverA
2) Launch tmux, Ctrl-b c to create a new window
3) From the new window, remote access to serverB, then run tmux att under shell to attach an existing tmux session (on serverB)
4) Now if I use the shortcut key Ctrl-b d, I can only detach from the session on serverA, because the tmux session on server B also uses Ctrl-b as the prefix
a) Press Ctrl-b n until the window containing the ssh session to server B becomes the current window
b) Press Ctrl-b :
c) Enter tmux command set -g prefix C-a
d) Press Ctrl-b d, tmux session on serverB is now detached, type exit to close the new window created in step 2, this step is optional though as the “nested” tmux session is detached from the ssh shell
e) Press Ctrl-a :
f) Enter tmux command set -g prefix C-b
Step c changes prefix to Ctrl-a so it won’t conflict with the tmux shortcut prefix from serverB. Step f changes the prefix back to Ctrl-b for serverA.