Dec 31, 2011

Dynamimcally setting the title of an xterm (and compatible) window

Keywords: xterm, konsole, title, dynamic, .tcshrc
Depends on: tcsh
Download:  .tcshrc -fragment

I was looking to customize my Konsole's title.  I wasn't entirely happy with the default.  I wanted `~' to be displayed when I was in my home directory and I didn't want to display my fully qualified host name.

What I wanted was the following when in my Home directory on my machine named `zoom':  pablo@zoom:~

A quick Web search (keywords:  xterm title escape sequence) provided the necessary escape sequence -

Reading tcsh's man page, I found the precmd variable.  The commands specified in precmd are executed before each prompt is printed.  Perfect.

The .tcshrc fragment, I placed at the top of my .tcshrc file to ensure it gets executed first when a terminal is started.

The final piece is to ensure Konsole is configured to display titles:
  1. Start a Konsole terminal
  2. Left-click inside the terminal to bring up a menu of options, select Configure Current Profile ...
  3. Select the Tabs tab and
  4. Set both Tab title format: and Remote tab title format: to Window Title Set by Shell

`sleep' until a certain time

Keywords:  bash
Depends on:  Nothing
Download:  sleep_until

A few months ago I had the need to mimic an interactive at.  Basically, I needed a sleep until a certain time.  I rummaged around the Web and found the solution.  This script implements the solution with a wee bit of error handling.

Attribution to the solution is in the script's tombstone.

Dec 30, 2011

Removing raspberry bush thorns from your hand

My boys love to pick fresh raspberries.  Inevitably they get tiny thorns on their fingers.  The thorns are too small to remove with tweezers so I stumbled on using duct tape to remove them:
  1. Cut a piece of duct tape, 
  2. Rub it over the affected area and 
  3. Quickly pull the tape off.  
You may need to do the above two or three times.

Multi-processor Work Queue script

Keywords:  bash
Depends on:  Nothing
Download:  thread_task

Certain processes are not multi-threaded.  For example, bzip2.  If we have a set of files which needs to be compressed, bzip2 can be handed the list of files and it'll compress the files one after another.  On a single processor machine, this works well.  On a multi-processor machine though, all but one processor are idle.

What's required is for the files to be placed in a queue and each bzip2 process is handed one file to compress.  When it's finished, the next file in the work queue is processed until all the files are processed.

The thread_task shell script is a generic work queue script.  It will run any command against a set of files.  By default, it will determine how many processors are on your machine and run at most that many simultaneous processes.  The script has a nice switch as well.

  • Enable the list of files to come from stdin so we can pipe the output of, say, find.

Oracle Get DDL script

Keywords:  Oracle, DDL, stdout
Depends on:  sqlplus (and its dependencies)
Download:  get_ddl

On many occasions I need to fetch DDL/source for Oracle objects (e.g. tables, views, packages, etc.) from the Database.

The get_ddl shell script is a wrapper around Oracle's DBMS_METADATA package.  It's an on-demand script:  as the demand requires, I add another object.

  • 1.1 - -i option to pull a specific index DDL.

Convert .mkv (and more) to `Apple TV 2' script

Keywords:  handbrake, cli, script, bash, Bourne
Depends on RPM(s) - openSUSE:  handbrake-unstable-cli
Download:  2_apple_tv

If you'd like to convert many files to Apple TV 2 format via the command line, the script will do it for you.  It's simply a wrapper around HandBrakeCLI.  I've tested .mkv (what started the script) and .avi.  .ISO's should also work.  It's whatever HandBrakeCLI supports.

  • Added -d target_dir option
  • Error handling on arguments - if not a file, skip it. 
  • Handbrake insists on the input file residing in the current working directory.  The shell script makes it so.
  • Added 64-bit formatting - support for files greater than 4 GiB