Friday, April 16, 2010

Missed PUG monthly meeting, exploring Java byte code and BCEL

I missed yesterday's Python User Group Singapore monthly meeting. I had to finish certain document before leaving office yesterday, I couldn't make it.

Last night I was exploring this Byte Code Engineering Library (BCEL) from Apache. This library gives us a way to analyse, create and manipulate binary Java class file. This library has been used by a lot of Java frameworks and containers, as those frameworks need to add some instrumentation when deploying those components in those frameworks and/or containers.

Well, this is considered an advanced thing in Java. Java classes are stored as Java byte codes. When you compile a Java source code, you will have .class file which is a Java byte code file. Java byte code is a form of machine instruction (in this case Java Virtual Machine or JVM). So it's executable binaries for JVM. Java byte code also have opcode like assembly language.

There are 2 type of instruction sets:

  1. stack machine
  2. register machine

Stack machine operates on stack. Operands are the stack only. The first programmable scientific calculators released by Hewlett-Packard are stack machines (http://www.hpmuseum.org/). They operate in a Reverse Polish Notation. I remembered that my first one of my first Java programming assignment was to implement GUI application for a Reverse Polish Notation calculator. My Dad has his own story of owning one of these calculators and he used to be very proud of the magnetic stripe stored Moon Lander game. It's just a number only Moon Lander, but it's a game running on programmable HP calculator!

Other sample of stack machines that most of us still use is the Intel x86 math coprocessor instructions set. It uses registers that are organised as stack, which will rotate back when overflowing the boundary (of 8 registers).

Stack machines, because it's only operate on stack and usually only the last few data in stack, may have shorter instruction bits. Unlike register machines which usually take some of the bits to specify from which and which register the data is from, and to which register the result goes, stack machines enjoy the benefit of default operands, that is top 1 or top 2 of the stack. The result is always in the stack.

I think one of the main considerations why JVM uses stack machine is to pack as few numbers of bits in the opcode. As most JVM runs as virtual machine, there will be no performance advantages of having a lot of register which anyway stored in RAM by the virtual machines.

Ok, enough for the stack machine, now back to the BCEL it's exciting to touch back the assembly language, byte code, opcode, operand, and stuffs if you are really into  it. I try to code a bit and will share the code later.

Sunday, April 4, 2010

What to do when you don't have locate tool

What to do when you want to find certain file(s) and you don't have the locate tool? Probably you are in Solaris, AIX, or other variants of UNIX that doesn't have the locate tool. Probably your Linux sysadmin just don't like the locate tool to be there?
May be you are in the support team and now that there is no fancy locate tool you still need to find where the file is located.

Someone at the mailing list asked about the question, so I will write it here so that everybody can benefit from it.

What we can do depends on the frequency of locating such files. If we are to mimic the slocate / mlocate (ubuntu) background process, this what I would suggest (assuming you have /root folder and have root equivalent access):

[sourcecode lang="shell"]<br /># find / -print &gt; /root/locations.txt &amp;<br />[1] 30851<br />[/sourcecode]



The number "30851" is the process number for the background process. You need to wait for a while until the background process completed. When it completes, it should display something like:

[sourcecode lang="shell"]<br />[1] Done        find / - print &gt; /root/locations.txt<br />[/sourcecode]


Whenever you want to search file name containing "tomcat-6.0", just run this command:

[sourcecode lang="shell"]<br /># grep "tomcat-6.0" /root/locations.txt<br />/home/dbaktiar/Downloads/apache-tomcat-6.0.24.zip<br />/home/dbaktiar/Downloads/apache-tomcat-6.0.26.tar.gz<br />[/sourcecode]


If you are using Ubuntu or sudo based tools, we can modify:

[sourcecode lang="shell"]<br /># sudo find / -print &gt; /root/locations.txt &amp;<br />[1] 30851<br />[/sourcecode]



Wait until the background process complete (you can do something else if the task take quite long).
Then to find files with "tomcat-6.0" string in its filename:

 

[sourcecode lang="shell"]<br /># sudo grep "tomcat" /root/locations.txt<br />[/sourcecode]


If you want to locate certain file(s) once you can run this (as suggested by Mr Budi Rahardjo):

[sourcecode lang="shell"]<br /># find . -name &lt;pattern&gt; -print<br />[/sourcecode]


Replace <pattern> with the full name or partial name of the file. When wespecify the name of the file, we can use wildcards, but don't forget to quote the name when needed.

Friday, April 2, 2010

COTD: a Chinatown's Starbucks?!?

In UNIX systems, we have motd tool, which is "message of the day", usually a short announcement or greetings from the system administrator. Sometimes it's also "match of the day" when we are talking about sports. I'll have my version called cotd "cup of the day", probably writing these messages while taking a sip of coffee.

On my way to gym at OneGeorge Street from Chinatown MRT, I usually take this route: Chinatown Point - Hong Lim Complex - Fook Hai Building - Hong Lim Park - OneGeorge Street.

Somewhere at the Hong Lim Complex, something always catch my attention.

I decided to take a picture of it.

 

Wednesday, March 31, 2010

My blog on domain danielbaktiar.com launches today

Today I have finally made a successful copy of my dbaktiar.wordpress.com. Now that I run wordpress blog on my own domain danielbaktiar.com.

There is some minor glitches, such as the exported than imported Wordpress now produces "&gt"s where it should display ">". Right now I just simply edit them one by one as there's not so much such occurrence. Overall I am highly satisfied with the smooth migration. The Wordpress team had done a great job to make it very easy to migrate and move Wordpress blogs around!

I decided to setup my own domain and hosted site because I need some degree of freedom in customizing my website, CSS, javascript, and also to put AdSense as well, too name a few.

Wednesday, March 17, 2010

Installation of Hudson in Karmic Koala (Ubuntu 9.10)

We are implementing Hudson continuous integration server heavily. Initially we are running all our Hudson jobs on a Windows box.

Hudson is an open source continuous integration tool. It gains popularity very fast and based on my experience in production, it is one of the most active open source project component I have been using. It is pretty common to get Hudson updates more than once a week.

With support from Debian community which setup the Hudson installer which updates easily through the apt tools, I became enticed to move to Ubuntu. I was following the instructions from the Hudson CI site.

These steps show how easy it is to deploy Hudson in an Ubuntu box.

[sourcecode lang="shell"]<br />$ wget -O - http://hudson-ci.org/debian/hudson-ci.org.key | sudo apt-key add -<br />[/sourcecode]


Add this entry to your /etc/apt/sources.list using your favorite editor.

[sourcecode lang="shell"]<br />$ sudo vi /etc/apt/sources.list<br />[/sourcecode]



Add this line at the end:

[sourcecode lang="shell"]<br />deb http://hudson-ci.org/debian binary/<br />[/sourcecode]


Then run the apt tool to update your Debian packages.

[sourcecode lang="shell"]<br />$ sudo apt-get update<br />$ sudo apt-get install hudson<br />[/sourcecode]


Upon finishing the whole thing, I popped out a browser and hit the URL: http://localhost:8080/, and YES! it works!

Friday, January 29, 2010

Oracle Announced the Outline Strategy on Integration of Sun

Oracle has announced  the outline strategy and its commitment  on Sun Microsystems integration into Oracle. It was in a Webcast and for those who missed it, could get it from the website.

This is the link from Oracle website.

We already noticed some additions on links in the Oracle Technology Website (http://otn.oracle.com) which includes newly added Sun's technology portfolios.

Friday, January 22, 2010

EU Commission Approval of Sun Microsystems Acquisition by Oracle: Lesson Learned

Yesterday James A. Goosling, the founder of Java platform, put a picture in his blog: "So long, old friend...".
After the EU Commission approved Sun Microsystems (NASDAQ: JAVA) acquisition by Oracle Corp (NASDAQ: ORCL), Oracle expects that Russia and China will also accept it. The main foreseen obstacle to the agreement was the EU Commission approval. Now that it has been approved, the acquisition is expected to go smoothly.

Some people began speculating on the fate of open source projects, which nurtured by Sun, yet they don't believe that Oracle will give enough support for those open source projects. One high profile fear was from Monty Widenius, the founder of MySQL, which after selling the company to Sun left MySQL (the company), and forked a new database project: MariaDB. He campaigned to prevent the acquisition of MySQL by Oracle. Now we see the result, it seems that he lose the campaign. Some voices also speculate about the fate of OpenOffice, Glassfish, etc after the acquisition.

This matter once again prove: "a technology is good, but we also need to make money". Of course Sun Microsystems is not the first to go down, there were a lot of dead carcasses of open source companies ended up acquired by profitable commercial companies that sell their proprietary products.

Sun is highly respectable company, which produced a lot of very good products. All hail respect to the company that bred the Java technology and platform, which took over the world. Yet, after this high profile achievement, the company still need to make money to bring value to the shareholders.

Lesson Learned: Companies Need To Make Money In Order To Sustain the Business

I guess this serves as reminder for those people (including me) who wants to make a company based on sophisticated technology, either open source or closed source; take note, when we start a company, we also need to make money.

Now that Wikipedia site had grown that big, the non-profit model required it to campaign for more money to sustain its operation.