Transparent Outter Border Effect

I attempted to make a transparent outter border effect for a design as displayed in this post.

To make this effect in HTML/CSS, I tried to make a outter wrapper that wrapped all the contents of the website with a thick border and opacity set to 8%. Unfortunately, opacities set in parent objects will pass to its children as well; meaning all contents under this wrapper also will have an opacity of 8%. There is no way of getting around this.

The solution to this problem is to make the outter wrapper have an image background consisting of the 8% transparency as needed. Thus, there is no need to adjust the opacity in CSS directly.

Java exec() results in no output in linux

For some reason, executing something like ping in java generates no output, but something like uptime does.

I’m guessing the reason for this is because ping has the sticky bit set. It seems like any programs that has the sticky bit will fail to run and generate any output in java.
Edit: Actually, this doesn’t seem to be true. mount has the sticky bit set but it runs fine.
Edit: Running the java program from a shell script causes java to generate output as it normally should….
Edit: The problem solved itself… Try to remove all environment variables by running unset `env | awk -F= '/^\w/ {print $1}' | xargs` and see what happens by running

Executing Programs in Java

The program arguments will be executed through this ‘shell’. You can make a loop that will make the following snippet a real shell.

import java.io.*;

public class SimpleShell {
	public static void main(String[] argv) {
	String line;
	StringBuilder output = new StringBuilder();

	try {
		Process p = Runtime.getRuntime().exec(argv);
		BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
		while ((line = input.readLine()) != null) {
			output.append(line).append("\n");
		}

		System.out.println(output);
	} catch (Exception e) {
		e.printStackTrace();
	}

	}
}

SVN: “Attempted to lock an already locked dir”

If you work with Eclipse and SVN, you’ll probably come across an error similar to: Attempted to lock an already locked dir

You can sometimes resolve this by cleaning up the workplace directly in eclipse by right clicking on your project -> team -> cleanup.

However, if that fails, you will need to delete all the lock files in your workplace.

If you’re under linux, run find ./ -name lock -exec rm {} \; in the workplace directory. If you’re on windows, I’m guessing you can do a search for all lock files and deleting it from the search results. Once that’s done, try to commit again, and hopefully it will work.

If eclipse still refuses to stop spewing error messages after all that, it’s best you start over your workplace. That is, back up your workplace, delete it, re-checkout the code, copy the backed up code into the workplace again, refresh the workplace in eclipse, and attempt to recommit again.

If even that fails, then it’s time to gg.

Installing and Creating a new SVN Repository

Note: This is the second time I’m writing this entry since RZ somehow managed to lose my first post. So these steps are from memory and might not be 100% correct.

If you want to install subversion, you will need to have apache. Easiest way to install this is via yum (or whatever package manager you need to use).
yum install subversion mod_dav_svn httpd

Once complete, you should have a directory in /etc/httpd/conf.d/subversion.conf.

We will create the repos in /home/subversion. I’ll also make a user ‘subversion’ who can manage these files without root. As root, run the following commands:

  1. useradd subversion
  2. cd /home/subversion

To create a new repo:

  1. Create the directory for the new repo. eg: 'repo'
  2. run 'svnadmin create repo'

To create the initial import of the trunk:

  1. mkdir /tmp/trunk
  2. svn import /tmp/trunk file:///home/subversion/repo/trunk -m "Initial Import"

You may want to add users to access this repo. Suppose you want to add user:

  1. cd /home/subversion/repo/conf
  2. htpasswd -cm svn-auth first_user
  3. htpasswd -m svn-auth second_user


Note: do not use the -c argument after adding the first user, otherwise it will overwrite the existing password file.

You will then need to add an entry to /etc/httpd/conf.d/subversion.conf with the following:


        DAV svn
        SVNPath /home/subversion/repo

        AuthType Basic
        AuthName "Subversion Repo for MyRepoName"
        AuthUserFile /home/subversion/repo/conf/svn-auth
        Require valid-user

Ensure the files in /home/subversion/ are owned by apache, but still is group owned by subversion.

You should now be able to access your new repo by going to /svn/repo after using the username/password combination given to htpasswd above.

Generating Self-Signed SSL Certs

If you want to have SSL enabled on your webserver, you may want to generate self signed certificates.

  1. cd ~
  2. mkdir ssl
  3. openssl genrsa -des3 -out server.key 4096
  4. openssl req -new -key server.key -out server.csr
  5. openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
  6. openssl rsa -in server.key -out server.key.insecure
  7. mv server.key server.key.secure
  8. mv server.key.insecure server.key

Step 3: Generating the key, use any pass phrase.
Step 4: Creating the certificate signing request
Step 5: Signing the certificate signing request
Step 6: Making a key that has no pass phrase

Note: Ensure that all keys are not readable to others. chmod 700 the ssl directory and chmod 600 all the keys.


To install the key on a litespeed web server

  1. create a new listener, call it for example, ‘secure’
  2. go to the ssl tab and specify the following values:
    1. Private Key File: $SERVER_ROOT/ssl/server.key
    2. Certificate File: $SERVER_ROOT/ssl/server.crt
    3. Chained Certificate: no
    4. CA Certificate Path: $SERVER_ROOT/ssl
    5. CA Certificate File: Not Set
  3. Copy the entire ssl directory generated above to the litespeed server root
  4. Chmod the entire ssl directory to 700, and chmod the keys to 600
  5. Chown/Chgroup the entire ssl directory to the lsadm user

Java Quick RegEx Matching

Suppose you want to match something in Java such as the average time from a ping output:

Pinging steamr.com [64.22.123.253] with 32 bytes of data:
Reply from 64.22.123.253: bytes=32 time=100ms TTL=53
Reply from 64.22.123.253: bytes=32 time=100ms TTL=53
Reply from 64.22.123.253: bytes=32 time=101ms TTL=53
Reply from 64.22.123.253: bytes=32 time=100ms TTL=53

Ping statistics for 64.22.123.253:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 100ms, Maximum = 101ms, Average = 100ms

You would want to do something like:

Pattern pingPattern = Pattern.compile(".*Minimum = [0-9]+ms, Maximum = [0-9]+ms, Average = ([0-9]+)ms.*", Pattern.DOTALL);
Matcher pingMatch   = pingPattern.matcher(pingOutput);

if (pingMatch.matches()) {
	averagePing = Integer.parseInt(pingMatch.group(1));
}

Note that the ‘.’ in the pattern does not by default match new lines or return carriages. The Pattern.DOTALL is needed so that ‘.’ accepts everything. RTFM for more info.