Adding a ShutdownHook to a Java Program to Enable Clean Exit on CTRL-C

Often times I will be building a Java program that will either be run from a command-line or as a system service.  In most cases, during development, I’ll be running it directly from the command-line and will want to kill it by pressing control c on the keyboard.

When I do that I want to make sure that my program cleanly exits, closing any open files, socket connections, database connects, or what have you.

To do so, you must invoke → Continue reading “Adding a ShutdownHook to a Java Program to Enable Clean Exit on CTRL-C”

Replacing Smart Quotes (<91> and <92>) in vi

Smart quotes will be displayed as <91> and <92> in vi. A number of other special characters will also be displayed in similar fashion <96>, etc. . . .

To replaced them use do the following:

  1. Type:? ‘:’ 1,%s/
  2. Then, since it is a special character, you can’t simply type ‘<91>’ or that string will not be matched, so:
  1. Press: CTRL and V
  2. Then type: [space] x [space] 91
  3. [Enter]
Continue reading “Replacing Smart Quotes (<91> and <92>) in vi”

Configuring CentOS to run SELinux in Strict Mode

I am in the process of setting up some CentOS/RHEL 6 servers to run SELinux in strict mode. What follows are notes, links to online resources and things that I am discovering along the way. Once I am finished I will go back and re-write it to follow more of a how-to/guide type format. In the meantime, it might seem a bit disjointed.

Links/Resources:

  • http://wiki.centos.org/HowTos/SELinux
  • http://fedoraproject.org/wiki/SELinux
  • http://www.centos.org/docs/5/html/Deployment_Guide-en-US/rhlcommon-chapter-0001.html
  • http://www.nsa.gov/research/selinux/index.shtml

MaintLog Notes:

  • Make sure that the selinux-policy-strict package (and deps) are installed:
Continue reading “Configuring CentOS to run SELinux in Strict Mode”

Getting JavaScript CSS Dropdown Menu to Render Over a Flash Component

If you are having trouble getting a DHTML drop-down menu to display on top of a Flash movie try adding the following to the <object> tag that embeds the .swf file in your .html.

Add the following as a child to the <object> tag:

<param name=”wmode” value=”transparent” />

Add the following as an attribute to the <object> tag:

wmode=”transparent”

I was having trouble getting a JavaScript dropdown to render over a Flash movie under IE and after adding the aforementioned → Continue reading “Getting JavaScript CSS Dropdown Menu to Render Over a Flash Component”

Compiling .jsp Fragments in Eclipse

The ability to generate HTML or .JSP fragments that you can include on multiple pages of your site enables you to re-use code and increase maintainability.

However, if you need to include functions (or methods) and fields (or variables) in one fragment that is included on a page and then utilize them in another fragment included in the same page Eclipse will give you compile errors because it concludes that your references are out of scope.

The solution is quite → Continue reading “Compiling .jsp Fragments in Eclipse”

Accessing JSON Data Under IE7

Given the following JSON object:

var var_affectedAreas = {
? ? ‘areaCount’ : 6,
? ? ‘areasList’: [
? ? ? {‘enum’: ‘FILE’, ‘val’: ‘F’},
? ? ? {‘enum’: ‘REGISTRY’, ‘val’: ‘R’},
? ? ? {‘enum’: ‘PROCESS’, ‘val’: ‘P’},
? ? ? {‘enum’: ‘MEMORY’, ‘val’: ‘M’},
? ? ? {‘enum’: ‘NETWORK’, ‘val’: ‘N’},
? ? ? {‘enum’: ‘OTHER’, ‘val’: ‘O’}
? ? ]
};

You would think (and rightly so, at least under Firefox) that you would be able to → Continue reading “Accessing JSON Data Under IE7”

Setting up Cygwin, Linux Command Line, on a Windows Box

For all of you Linux (and Unix) users who are used to the Linux command line there is an application called Cygwin. Not only does it allow you to use the familiar command line commands but it also includes the ability to execute bash and csh shell scripts on a Windows machine.

When installing it, here are a few additional packages you’ll probably want to include:

vim, ncurses, tcsh

Simply type them into the search field and then check off → Continue reading “Setting up Cygwin, Linux Command Line, on a Windows Box”