Pages

Thursday, July 24, 2014

Customizing the UNIX User Environment - Part 5 - Using the GNU info system - Part 2

Customizing the UNIX User Environment

**********************************************************************************

Using the GNU info system

********************************

Page layout and node navigation

---------------------------------------

The info program is a reader for documentation created using the texinfo system.

Info structures text into a hierarchical tree of nodes, with each node containing a description of a specific topic to a specific level of detail.

If you doct specify a node, the info page opens to the top menu of nides as shown here.

 

You can move around the info page using the SPacebar or Delete keys.

Depending on the type of terminal you're using, the Delete or Backspace keys allow you to move down the current page to view text that comes after the currently displayed screen.

 

The Spacebar key allows you to move up to viw text that comes before the currently displayed screen.

In this case, there's np text before the currently displayed screen, because this is the first and topmost screen.

 

The top line of a node acts as its header. The header consists of the following sections

-File

-Node

-Next

-Prev

-Up

 

The tile of the current topic is underlined and located below the header.

The title identifies the topic that's being descrbed in the node.

 

In addition to the title, a node contains a mode line, which identifies the node. The node line indicates how many lines the node contains and where you are within the node.

 

To move from one node to the next, you type n.

The header changes to reflect a differnt node.

In this case, the header has changed from the ar node to the nm node.

Of you are at the end of a node, you can also use the Spacebar key to move to the next node.

 

To return to a previous node, you type p.

The header changes to display the previos node. For example, whn you type p while in the nm node, the header changes from the nm node back to the ar node. You can also do this by using the Delete or Backspace key if you're at the beginning of a node.

If your keyboard has Page Up and Page Down keys, you can use them within a node instead of the Spacebar and Delete keys, but they won't open the next or previous node.

 

Let's say that you want to move up a level from the current node by pressing u.

You can also go back to the beginning of a code by pressing b.

 

The info page layout contains menus, which allow you to access other nodes. TO move to other nodes using a menu, you use the m option.

For example, to move to the objcopy node, you press M to invoke the minu prompt. Then you type objcopy and you press the Enter key.

Alternatively, you can place the cursor at the befinning of a menu item, in this case objcopy, and then press Enter.

 

The result shows the objcopy node open

 

The menu of a particular node is nirmally visible on the page.If there's no visible menu, that node does not have a menu and you may not issue the m option.

 

The info page may include cross nodes, which you reach through a cross-reference. A cross-reference is a footnote that points at nodes that belong to an isolated section within the structure.

As a result, these footnotes don't have leads to previous, next, or up topics. In this case, you need to use a specific command, such as f, to follow a specific reference, for example nodes associated with topics starting with the letter b.

 

The result in this case returns the BFD node.

 

The mode line - you can see how many lines a particular node contains and where you are within a node from the mode line.

The command line - is where you issue navigational commands to traverse the info system documentation. Note that not all commands may be available on all systems.

The Status line generally reflects the state of various keys - whether the numloclk, scroll lock, or insert mode is on or off, The status line is used for information only - you cannot write to it or update it.

 

You can invoke and use the info system from within an emacs text editor, which interprets the LISP programming language that supports text editing.

Emacs is a real-time display editor that allows you to edit file types, such as plain text, source code, and HTML files

 

Emacs includes complete online documentation. including a tutorial for new users. It can be customized and extended, and has self-documenting capabilities

 

Summary

---------------

The UNIX info reader program enables you to read help documentation formatted using the texinfo system. The info reader is designed to read texinfo fies, which contain documentation on most software developed as part of the GNU project.

When you invoke the Info system, it takes you to a pager environment where text is structured into a hierarhical tree of nodes. Each node contains a description of a specific topic to a specific level of detail. The info page opens to the top menu of nodes if you dont specify a node. You can use the Spacebar and Delete keys to navigare an info page.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Wednesday, July 23, 2014

Get all property names of javascript object

This is a tricky business and I believe I had tried this multiple times and ended using a work around. I had a javascript object in json notation and it had a lot of values encapsulated in it. To be specific it looked like the following

 

>> window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US")

{
       HSI B MAKATI PHILIPPINES : [object Object],
       HSI B HEREDIA COSTA RICA : [object Object],
       FSC-HEREDIA, COSTA RICA : [object Object],
       HSI QUEZON CITY PHILIPPINES : [object Object],
       CSSC-VENDOR-TELETECH, NOVA, PH : [object Object],
       HSI C HYDERABAD INDIA : [object Object],
       HSI C NOVALICHES PHILIPPINES : [object Object],
       EVRC . PASIG, PHILIPPINES : [object Object],
       HSI B TIJUANA MEXICO : [object Object],
       FSC-HYDERABAD,INDIA : [object Object]
}

All I wanted to do was get an array of the property names. Following attempts were futile. They either gave empty values or errors

>> x=window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US");x[0]

>> x=window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US");x(0)

>> x=window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US");x["0"]

>> window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US").properties

>> x=window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US");x[0]

>> x=window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US");x.length

>> x=window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US");x.size

>> x=window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US");x.size()

"Object doesn't support property or method 'size'"

 

Only Specific calls like the following with the property names worked. But this is no good to me as I cant always no all the properties present inside the object

>> x=window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US");x["FSC-HYDERABAD,INDIA"]

{
       Name : "FSC-Hyderabad,India",
       Description : "Refers to the Center corresponding to the code FSC-Hyderabad,India",
       Value : "AR",
       Type : "AGENT_CENTER_OUTSIDE_US"
}

 

At last the following attempts helped me

>> x=window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US"); for(y in x){y}

"FSC-HYDERABAD,INDIA"

>> x=window.top.getGlobalParamData("AGENT_CENTER_OUTSIDE_US"); for(y in x){console.log(y)}

LOG: HSI B MAKATI PHILIPPINES

LOG: HSI B HEREDIA COSTA RICA

LOG: FSC-HEREDIA, COSTA RICA

LOG: HSI QUEZON CITY PHILIPPINES

LOG: CSSC-VENDOR-TELETECH, NOVA, PH

LOG: HSI C HYDERABAD INDIA

LOG: HSI C NOVALICHES PHILIPPINES

LOG: EVRC . PASIG, PHILIPPINES

LOG: HSI B TIJUANA MEXICO

LOG: FSC-HYDERABAD,INDIA

 

Now I can construct my required array J

 

Hope this helps some one J

Monday, June 16, 2014

ORA-00904: "%text%": invalid identifier 00904. 00000 - "%s: invalid identifier"

A was trying a pretty basic command in SQL Developer and for some reason I got the following response that irritated me for almost an hour

 

ORA-00904: "%text%": invalid identifier

00904. 00000 -  "%s: invalid identifier"

*Cause:   

*Action:

Error at Line: 2 Column: 62

 

My query was pretty much similar to the following.

 

select * from <<table_name>> where <<column_name>> like “text”;

 

After a few trial and errors I identified the error. It was because of the double quotes around the text pattern that I was using. I replaced it with single quotes and things worked like charm. So as end result my query was like

 

select * from <<table_name>> where <<column_name>> like ‘text’;

 

Hope this helps some one J

 

Tuesday, June 10, 2014

Stuck with Unix Screen - A remedy

Stuck with Unix Screen - A remedy

 

I had been tinkering with the less and grep commands this morning and found that I got stuck with the PuTTY window. None of my commands seemed to work as they were getting in as some sort of text values. 0)0)

 

Exit, Clear nothing worked. Eventually received an expert advice that ctrl+c or ctrl+z would help you get back to your working directory and ctrl+c worked for me .

 

Happy to see the $ again EE-lol

 

Friday, June 6, 2014

Opening existing projects in eclipse - method 2

I knew a way to do it which I had posted in http://ozinisle.blogspot.com/2014/05/opening-existing-projects-in-eclipse.html. Unfortunately that did not help me this time. I had a complicated project with a complicated folder structure driven by many configuration/property files. And hence eclipse either gave me messages like it does not find the project or there is already a project by that name.

 

Thanks to an expert advice that I received. I think I am thankful enough that I am sharing it with you. I was asked to create  a new project in my workspace. A plain old “New Project” -> “Java Project”

 

That did the trick. Though it created a new project, it started displaying the underlying folder structure in the operating system.

 

Hurray that worked for me. So in simple words,

 

1.       Let me assume that we have a project named “MyComplexProjectWithNastyFolderStructure” in “D:\workspace”

2.       I have a workspace set in eclipse pointing to “D:\workspace”

3.       Now if the project “MyComplexProjectWithNastyFolderStructure” is visible in the workspace – hell why are you reading this post

4.       Still “MyComplexProjectWithNastyFolderStructure” is visible but you have a problem like, you have to remove it and get updated code from say “CVS”, then close it

5.       Go to the file system (OS) and do what you have to do, like backing up the existing project, deleting it or scolding it or whatever nice stuff you plan to do

6.       Come back to eclipse. Click “File->New->Java Project”

7.       Give the name to your Java Project as “MyComplexProjectWithNastyFolderStructure”

8.       Tada… the project gets created again and this time you can look at the changes that you have made in the file system

9.       If not, try refreshing it

10.   Hope you got what you wanted. If not, “Lord Vinayaka Bless You” – go bless others for me J :P

 

Hope this helps J

 


Thursday, June 5, 2014

getXMLString from an XML Node Object

Following is a simple function that would let you obtain the XML contents of a XML node in a string format. The packages that had been imported into the class are listed as follows. I hope these are available as a free download

 

import org.w3c.dom.NamedNodeMap;

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

 

public static String getXMLString(Node xmlNode){

              String xmlString = null;

              xmlString="<";

              xmlString+=xmlNode.getNodeName();

             

              NamedNodeMap attributes=xmlNode.getAttributes();

              int noOfAttributes=attributes.getLength();

              int itr=0;

             

              for (itr=0;itr<noOfAttributes;itr++)     {

                     Node attributeNode=attributes.item(itr);

                     xmlString+=" "+ attributeNode.getNodeName() + "=" + attributeNode.getNodeValue();

              }

              xmlString+=">";

             

              NodeList childNodes=xmlNode.getChildNodes();

              int noOfChildNodes=childNodes.getLength();

             

              if (noOfChildNodes==0)     {

                     xmlString+=xmlNode.getNodeValue();

              }      else   {

                     int childNodeItr=0;

                     for (childNodeItr=0;childNodeItr<noOfChildNodes;childNodeItr++)      {

                           xmlString += getXMLString(childNodes.item(childNodeItr));

                     }

              }

             

              xmlString+="</"+xmlNode.getNodeName()+">";

             

              return xmlString;

       }

 

 

Creating an XML Document node from XML string

Following method helps you convert XML String into a XML Document Object

 

import java.io.ByteArrayInputStream;

import java.io.InputStream;

 

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

 

import org.w3c.dom.Document;

      

public Document getXMLDoc(String xmlString) {

       InputStream is = new ByteArrayInputStream(xmlString.getBytes());

       DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();

       DocumentBuilder dBuilder = null;

       Document doc = null;

       try {

              dBuilder = dbFactory.newDocumentBuilder();

              doc = dBuilder.parse(is);

       } catch (Exception e) {

              // TODO Auto-generated catch block

              // logger.error("Parsing exception iha xml traversal");

       }

      

       return doc;

}

      

You can use the doc object as follows

 

doc.getElementsByTagName(tagName)

 

 

Monday, June 2, 2014

Creating a jar file through eclipse

Its rather simple and straight forward to create a jar file using eclipse. I am employing an ant build file to do this stuff.

 

Create a project and add a class to it as follows

package com.self.jarTest;

 

public class HelloWorld {

    public static void main(String[] args) {

        System.out.println("Hello World");

    }

}

 

Now create a build.xml file in the root of your project folder with the following content

<project>

 

    <target name="clean">

        <delete dir="build"/>

    </target>

 

    <target name="compile">

        <mkdir dir="build/classes"/>

        <javac srcdir="src" destdir="build/classes"/>

    </target>

 

    <target name="jar">

        <mkdir dir="build/jar"/>

        <jar destfile="build/jar/HelloWorld.jar" basedir="build/classes">

            <manifest>

                <attribute name="Main-Class" value="com.self.jarTest.HelloWorld"/>

            </manifest>

        </jar>

    </target>

 

    <target name="run">

        <java jar="build/jar/HelloWorld.jar" fork="true"/>

    </target>

 

</project>

 

Now right click on the build.xml and click on “Run As -> 3.Ant Build -> Clean, Compile, run, jar -> Run“

 

That’s it you got your jar file J

 

Creating a jar file through command prompt

It gives me a feeling like I am interacting more with my computer than usual. I feel like those so called geek hackers in Action movies as I don’t see anything visually until I clean, compile and run my jar files lol. I know I am exaggerating stuffs here, but, its’ sometimes good to enjoy the little things in life you know J

 

Coming to the point, In order to create a file entirely through command prompt, one can possibly follow the forth coming steps to do it.

 

1.       Get to your project folder. In my case it was through

>>cd “projectFolderPath”

 

2.       Create your class file. I created one to print a statement as follows

 

package com.self.jarTest;

 

public class HelloWorld {

    public static void main(String[] args) {

        System.out.println("Hello World");

    }

}

 

3.       Create a build directory

>>md build\classes

 

4.       Psst. I don’t have admin rights on this stupid machine and so I can’t change my environment variables. So I did the following

>>"C:\program files\Java\jdk1.7.0_55\bin\javac.exe” –sourcepath src –d build\classes src\com\self\jarTest\HelloWorld.java

 

In your case, if your environment variables are set properly I assume it must be something similar to

>>javac –sourcepath src –d build\classes (path to your HelloWorld.java file)

 

5.       Now create a folder to put your jar file

>>md build\jar

 

6.       And finally create your jar file (* following line does include a ‘dot’ – ‘.’ – don’t omit it)

>>jar cfm build\jar\HelloWorld.jar mf –C build\classes .

 

@*%%*, My class path is not set properly and I can do nothing about it L So I did the following

>>"C:\program files\Java\jdk1.7.0_55\bin\jar.exe" cfm build\jar\HelloWorld.jar mf –C build\classes .

 

Vola, my jar file is created. Now to do the most meaning full stuff, I am speaking about the “Check if its working or not” theorem. I used the following line of command

>>java -jar "build\jar\HelloWorld.jar"

 

Wohooo…. It worked like charm. I got the following

>>Hello World

 

I know it seems like, I am getting exited for nothing. Who gives a damn J

Trouble shooting java.lang.UnsupportedClassVersionError

I encountered an error which stated ‘Exception in thread "main" java.lang.UnsupportedClassVersionError: …. Blah blah blah’ when I tried to run an class as a normal java application in eclipse. The code was fairly simple and hence I definitely had nothing to debug for errors. A little search revealed about the nature of the error and its fix which was again fairly simple and straight forward.

 

I used a default JRE which was included from JDK160_29 corresponding to a weblogic 12c server. But my compiler was set to Java 1.7

 

So all I had to do was change it to 1.6 and my code worked like charm J

 

So in summary the fix to my issue was File->Preferences->Java Compiler->’Compiler Compliance Level’ -> choose between 1.3 to 1.7 to suit your JRE version. In my case it was 1.6