Monday, October 20, 2008

Finding all files containing a specific string in unix

find [directory_name] -exec grep -li "[search_string]" {} \;

e.g. find . -exec grep -li "xxxx" {} \;

which searches for files containing the string "xxxx" within the current directory.

Resizing animated gifs using Imagemagick

convert [filename] -coalesce temp
convert temp -resize %25 resized_image.gif

Sunday, September 28, 2008

Getting a single DB connection in Java

Connection conn = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@[ip_address]:[port]:[SID]", "[username]", "[password]");

Tuesday, September 23, 2008

Changing the Date/Time on Linux

Changing the timezone to Johannesburg:
$ ln -s /usr/shar/zoneinfo/Africa/Johannesburg /etc/localtime

Changing the date/time:
To change the date/time use the following syntax:
$ date MMDDhhmmYYYY
where MM is the month, DD is the day, hh is the hour, mm is the minute and YYYY is the year.

Updating the hw clock:
$ hwclock --systohc

Checking the hw clock:
$ hwclock --show

To maintain the timezone through a restart you may need to change the /etc/sysconfig/clock file.

Binary Tree Traversals

One of the important features of Genetic Programming is the tree structure which is the primary method of representing an individual. Understanding binary tree traversals is therefore required. The 3 methods of traversing a binary tree are Preorder, Postorder and Inorder traversal.

Preorder Traversal:
begin
   if tree=null return;
   print(tree.root)
   preorder(tree.leftsubtree)
   preorder(tree.rightsubtree)
end

Postorder Traversal
begin
   if tree=null return
   postorder(tree.leftsubtree)
   postorder(tree.rightsubtree)
   print tree.root
end

Inorder Traversal
begin
   if tree=null return
   inorder(tree.leftsubtree)
   print(tree.root)
   inorder(tree.rightsubtree)
end

JSESSIONID on URL causes an issue for the SE P1 handset

A JsessionID on the end of a download URL to a piece of content seems to cause a problem for the Sony Ericsson P1 handset e.g. file.3gp;jsessionid=xxxxx. The handset doesn't seem to recognise the format of the file and gives an error "There is a problem opening the file. Try Again?". The installation message sent back to the handset though is a 900 Successful Installation. Oddly if DRM is applied to the content (which will then be a .dm or .dcf file), the JsessionID is not really a problem. Removing the jsessionid from the URL to the content fixes the problem described above.

952 device aborted error

SE K750i gives a 952 device aborted error when downloading content if there is not enough space on the memory card. The handset shows the message "Operation Failed". This error is not very intuitave as, if it is a space issue the handset is supposed to send a 901 error. The handset had enough space on the handset itself so this is probably why a 901 error isn't the installation message. So identifying the actual problem was quite difficult. Deleting some of the items on the memory card solved the issue.