Thursday, May 14, 2009

perl caller

The way caller will show what is there in the array

File: temp.pm
#!/usr/bin/perl

package temp;

sub first_level {

@callerList = caller(0);
$size = scalar @callerList;
print "This is the size $size \n";
for ($index = 0; $index < $size; $index++) {
print "This is the index $index " . $callerList[$index] . "\n";
}

}

1;

File : test.pl
use temp;
print "Started the pgm \n";
temp::first_level();

@callerList = caller(0);
$size = scalar @callerList;
print "This is the size $size \n";
for ($index = 0; $index < $size; $index++) {
print "This is the index $index " . $callerList[$index] . "\n";
}


This is the output
Started the pgm
This is the size 10
This is the index 0 main
This is the index 1 test.pl
This is the index 2 3
This is the index 3 temp::first_level
This is the index 4 1
This is the index 5
This is the index 6
This is the index 7
This is the index 8 0
This is the index 9
This is the size 0

Tuesday, April 14, 2009

java plugin for 64 bit firefox

An issue that bothered many users of 64bit Linux is hopefully a history since JavaSE 6u12, which is now available in development version (therefore it is not a stable build and it is not recommended for "production use"). I have managed to install a Java plugin for Firefox on my 64bit Ubuntu - installation was pretty flawless...

Confirmed here: https://jdk6.dev.java.net/6uNea.html

So, what do you need to do in order to have a working Java in your Firefox on 64bit Linux?

  1. Update: Use Firefox from your distro repository.
  2. Rollback all your previous attempts to make Java work - if you don't perform this step, the result is uncertain... This includes especially following:
    • Make sure you have 64bit version of Firefox (previous workaround was to use 32bit version of browser). Note that there is also a 64bit Flash plugin for Linux available, so 32bit version of browser should not be needed anymore...
    • Remove IcedTea/gcj/... plugin if you were using it
  3. Download JRE 6u12 (an early access) from pages with JavaSE 6u12 dowloads (you can use this link pointing to the b03) and install Java to any desired folder (I would suggest /usr/lib/jvm folder for Ubuntu users, this is where Ubuntu places Java by default)...
  4. Create a link (ln) pointing to the Java plugin (file /lib/amd64/libnpjp2.so) in the ~/.mozilla/plugins folder (to let Firefox know where the new plugin is...) - maybe you will have to create this folder (I had to)
  5. Make sure the installation didn't interfere with the rest of your Java environment and that you are using stable Java system wide (call java -version). If not, reconfigure your Java environment, for example using update-java-alternatives command (thank's to Petr Chytil for the hint)
Note/Update: Are you getting "LoadPlugin: failed to initialize shared library /opt/java/jre1.6.0_12/lib/amd64/libnpjp2.so [/opt/java/jre1.6.0_12/lib/amd64/libnpjp2.so: wrong ELF class: ELFCLASS64]" message? Try to use the Firefox that is in your distro's repository. The problem Werner was facing (see the discussion below) was resolved by installing official openSUSE packages instead of the Firefox from mozilla site... Werner, thank you a lot for not giving up and elaborating on the issue!

Friday, March 13, 2009

24 bit color for rdesktop - windows2003 server

I am just pasting information from a list just in case they end up archiving it ;-)...
Hello list,

Surfing through the list archives for an answer to why can't i use more than 16 bit Color Depth when connecting to a WinXP TS, i found a lot of threads opened on this matter and a lot of people having this problem. I finally sort it out on my own, but i thought i'd post a relevant message to this list for all those people encountering the same issue, or for future searches.

Here are some notes to consider:

1. You can NOT get a higher color depth/resolution from a session than your video card on the client computer supports, even if the video card from the server computer supports it. (Obvious, but just to make sure it's understood)

2. The OS running Terminal Services DOES count.

3. Windows NT/2000's Terminal Services does NOT support a color depth higher than 16 bit. If you run these OSs and want better, don't bother, you won't get it.

4. Windows XP's DEFAULT Maximum Color Depth is ALSO 16 bit. This explains why when you try to use a 24 bit color depth option with rdesktop you will get WARNING: Color depth changed from 24 to 16 or something to that extent.

Here's the solution for Win XP (also 2003 server i guess):

Go START > Run and type in: gpedit.msc
The Group Policy Editor will open. In the GPE go
Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Terminal Services
Once you click on Terminal Services look in the right TAB and search for Limit Maximum Color Depth . It will probably have status Disabled by default. Right click on it and go Properties. The Properties window will open up. On the Setting TAB select Enable and at Color Depth select whatever you want. If you select Client Compatible you will allow terminal services to read the color depth setting from the client, so you can control it from the client. If not you can set whatever color depth you wish from that list. Yes 24 bit is maximum. As far as i know the RDP , even 5 has not enabled support for 32 bit color depth yet.

Good luck and hope it helps.

Best regards,
Lucian Constantin (Skello)

Saturday, March 7, 2009

xmkmf command not found

Intall imake that should solve the issue. I was working in RHEL5 (32 bit). I installed imake using this command as root
rpm -i imake-4.2.1-8.i386.rpm

Sunday, January 18, 2009

Is-a and is-like-a a difference

Is-a vs. is-like-a relationships

There’s a certain debate that can occur about inheritance: Should inheritance override only base-class methods (and not add new methods that aren’t in the base class)? This would mean that the derived type is exactly the same type as the base class since it has exactly the same interface. As a result, you can exactly substitute an object of the derived class for an object of the base class. This can be thought of as pure substitution, and it’s often referred to as the substitution principle. In a sense, this is the ideal way to treat inheritance. We often refer to the relationship between the base class and derived classes in this case as an is-a relationship, because you can say “a circle is a shape.” A test for inheritance is to determine whether you can state the is-a relationship about the classes and have it make sense.

There are times when you must add new interface elements to a derived type, thus extending the interface and creating a new type. The new type can still be substituted for the base type, but the substitution isn’t perfect because your new methods are not accessible from the base type. This can be described as an is-like-a relationship (my term). The new type has the interface of the old type but it also contains other methods, so you can’t really say it’s exactly the same. For example, consider an air conditioner. Suppose your house is wired with all the controls for cooling; that is, it has an interface that allows you to control cooling. Imagine that the air conditioner breaks down and you replace it with a heat pump, which can both heat and cool. The heat pump is-like-an air conditioner, but it can do more. Because the control system of your house is designed only to control cooling, it is restricted to communication with the cooling part of the new object. The interface of the new object has been extended, and the existing system doesn’t know about anything except the original interface.


Of course, once you see this design it becomes clear that the base class “cooling system” is not general enough, and should be renamed to “temperature control system” so that it can also include heating—at which point the substitution principle will work. However, this diagram is an example of what can happen with design in the real world.

When you see the substitution principle it’s easy to feel like this approach (pure substitution) is the only way to do things, and in fact it is nice if your design works out that way. But you’ll find that there are times when it’s equally clear that you must add new methods to the interface of a derived class. With inspection both cases should be reasonably obvious.

Sunday, December 28, 2008

./configure picks up wrong packages

To set the correct package set PKG_CONFIG_PATH so that it picks up right files
Example:
PKG_CONFIG_PATH=/usr/lib/pkgconfig ./configure