Tuesday, April 5, 2011

Custom Search in Chrome

At home, I have little use for domain-specific search engines---Google usually gives me the right answer. But, at work, Google doesn't have access to much of the information I need. Yes, we have an intranet search, but it is of little-to-no help when I'm looking for a particular bug, ticket or code revision. Firefox has "bookmarklets" which let you trigger a custom search based on a keyword. Though it's less obvious, Chrome lets you do the same thing via its "search engine" configuration. In the "Manage Search Engines" window, enter a keyword and a url and a "%s" for where the search string should be substituted. Then, finding a particular bug can be as easy as typing "b 12345" in the omnibox. I got this tip from Lifehacker.

Friday, April 1, 2011

Nohup or Disown?

In the past when I've started long-running jobs, I've used nohup. But, what if you forget to use nohup or find that a job is taking longer than expected? Today, I learned about disown which allows you to easily prevent a process from being killed when the parent is killed. Ksplice provides a detailed tutorial on using disown. The quick-and-dirty version is:

$ long-running-process.sh
^Z
[1]+  Stopped     sh long-running-process.sh
$ bg
$ disown %1

Friday, March 25, 2011

XChat Configuration

I'm an IRC newbie even though I've been using email for 15+ years. IRC seems great for those issues that benefit from the experience of many but aren't large or important enough to warrant hitting the mailboxes of 100 people. It also seems useful for determining the magnitude of an issue. Anyway, now that I'm using IRC, I wanted to make my client of choice, XChat, less annoying to use:

  • XChat highlights a channel when any new messages show up, including join/quit. So, as long as join/quit messages are displayed, the channel highlight wasn't very informative. I learned that it's easy to disable join/quit messages. Note that in in XChat 2.8.6, the "hide" option is under "Settings".
  • By default, XChat starts with no server connection and no channels. You can get it automatically connect and open channels via the "XChat"/"Network List..." menu. "Edit..." your server, check "Auto connect to this server at startup" and click the button next to "Favorite channels" to provide a list of auto-connect channels.

Tuesday, March 22, 2011

Deleting Old Files

Deleting old files should be an easy task, right? find can locate them and rm can delete them. But, what's the right combination? xargs must be useful as it converts newline-separated data into space separated data, but the first thing I tried didn't work because there were spaces in some of my file names:

$ find -mtime +90 | xargs ls
ls: cannot access ./download: No such file or directory
...
The xargs man page provides one solution:
...filenames containing blanks and/or new‐lines are incorrectly processed by xargs. In these situations it is better to use the -0 option, which prevents such problems. When using his option you will need to ensure that the program which produces the input for xargs also uses a null character as a separator. If that program is GNU find for example, the -print0 option does this for you.
Another option is to tell xargs to use newline as the delimiter. 'course, I'd recommend that you first try listing the files to see what you'll be deleting. Hence the ls in these examples. You should change to rm when you're ready to destroy.
$ find -mtime +90 -print0 | xargs -0 ls
$ find -mtime +90 | xargs -d "\n" ls

Thursday, March 10, 2011

Google Chrome 10: Flash Out of Date

If you're like me and just upgraded to Google Chrome 10 (10.0.648.127), you may find that you get Flash is "Out of Date" error messages. IIUC, Chrome 9 used it's own build-in flash player, but Chrome 10 has switched back to using the Adobe one. Also IIUC, Chrome 10 expects Flash 10 and will complain if the available flash is 9 or older. At first, I thought I was out-of-luck since this Adobe TechNote says that Chrome's flash is built-in, but I found that after uninstalling (Adobe) flash, not even the "Run this time" option would work. So, I tried reinstalling Adobe flash. It grabbed version 10 of Adobe flash, and, Poof! Flash was working again without the warning message. This even though I'm on Debian oldstable (5.0 aka lenny). So, if you run into this issue, I'd recommend installing Adobe flash 10. It appears that on Debian-like distributions (e.g. Ubuntu), this is as easy as:

$ sudo apt-get remove libflashplugin-nonfree
$ sudo apt-get install libflashplugin-nonfree

Update (3/24/11): Users on the Google Help Forum have suggested checking chrome://plugins to see if Chrome is using the Firefox's outdated plugin (/home/username/.mozilla/plugins/). If so, try deleting the outdated plugin and restarting Chrome.

Wednesday, February 23, 2011

Reloading the Mutt Configuration File

I find it a bit annoying that I have to re-enter my password twice every time I (re-)start mutt when I want to update my configuration file. Well, it appears I don't need to be doing restarting mutt. The MuttWiki describes a way to re-load the configuration after mutt is running. Type the following into mutt after you've changed your muttrc file:

:source /path/to/your/muttrc
Note that shell expansions may not work---you should spell out the full path.

Monday, February 7, 2011

Too many open files

Certain applications, such as a web server with lots of database connections, require a large number of open files. Most Linux systems are, by default, configured to allow relatively small number of open files, e.g. 1024. How to change this limit isn't as obvious as one might hope.

ulimit will show you current limits and let you change limits for the current session. But, one rarely cares about a temporary change. For a permanent change, one must realize that these limits are in place for security purposes---so that it is difficult for a single user to bring down the entire machine. So, the limits are configured in /etc/security/limits.conf. Adding the following lines to /etc/security/limits.conf should help if you are having "too many open files" troubles:

* soft nofile 16384
* hard nofile 65536
Note that this is also the place to "unlimit" the number of processes a user can run, e.g.:
* soft nproc 4096
* hard nproc 16384
Note that a "soft" limit is the limit a user will get when starting a shell. The "hard" limit is the highest limit they can set without "root" privileges.

Note that when checking limits using ulimit, soft limits are shown by default. Use the -H option to get hard limits. The -a option shows "all" limits. So, run the following two commands to see soft, then hard limits, respectively:

ulimit -a
ulimit -a -H