Wednesday, January 14, 2009

[Java] Install Java 6 doc on Ubuntu 8.10 aka Intrepid Ibex

Ubuntu 8.10 doesnt provide the java 6 doc but an installer that will take care of unzipping and copying the java doc in the right location.

If you want to install the java 6 doc on Ubuntu 8.10, you will have to:
  • download the doc package at http://java.sun.com/javase/downloads/index.jsp. There, click on the "Download" button in the "Java SE 6 Documentation" section. The name of the just-downloaded file will look like jdk-6u10-docs.zip
  • Copy this file under /tmp
  • Rename it to jdk-6-doc.zip
  • Change the ownership of the zip to root
    chown root:root jdk-6-doc.zip
  • Run sudo apt-get install sun-java6-doc
  • Et Voila!

Friday, January 9, 2009

[LDAP] Comments that are not comments

Today, we try to run one of the application we worked on in a new environment.
This application uses OpenLDAP and we had to reconfigure everything (create a new root dn, a binding user ...) but as Murpy's law says, "if anything can go wrong, it will". And I can confirm it happened.
We found out that when we set up the access to the ldap server in slapd.conf, comments (starting with #) does not necessarily comment the line out.
We had some lines as follow:

access to attrs=userPassword,shadowLastChange
   by dn="cn=admin,dc=myserver,dc=com" write
   #by dn="uid=cyril,ou=People,dc=myserver,dc=com" write
   #by anonymous auth
   by self write
   by * none

You would think that it would be like the below but it's not

access to attrs=userPassword,shadowLastChange
   by dn="cn=admin,dc=myserver,dc=com" write
   by self write
   by * none

According to the slapd config documentation
Blank lines and comment lines beginning with a '#' character are ignored. If a line begins with white space, it is considered a continuation of the previous line (even if the previous line is a comment).

Thursday, January 8, 2009

[vi] Basic vi command

See below the basic you should (me anyway) need to get started with vi.
I usually use vim(vi improved) but in some Sun servers, you may have only vi available.
  • h
Move the cursor to the left one character position
  • j
Move the cursor down one line.
  • k
Move the cursor up one line.
  • l
Move the cursor to the right one character position.
  • X
Delete the character before the cursor.
  • x
Delete character under the cursor. A count tells how many characters to delete. The characters will be deleted after the cursor.
  • a
Enter insert mode, the characters typed in will be inserted after the current cursor position. A count inserts all the text that had been inserted that many times.
  • i
Enter insert mode, the characters typed in will be inserted before the current cursor position. A count inserts all the text that had been inserted that many times.


You can find the above here

[perl] - Generate a random password

The following code will generate a random password composed of uppercase/lowercase/special characters and digits.

sub generate_password {
  my $length = shift || 10;
  my @chars = ( "A" .. "Z", "a" .. "z", 0 .. 9, qw(! @ $ % ^ & * ) );
  my $password = join("", @chars[ map { rand @chars } ( 1 .. $length ) ]);
  return $password;
}

You can pass a number as parameter to the generate_password function that will determine the length of the new password.
Default length here is 10