I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Saturday, 20 July 2013

Apache Log Files Analysis

I might be doing this a lot of apache log file analysis in a few days so might as well take look at the the open source (and others) project there are t to perform this task.

I discovered the following projects:

  • logQL (GPL v3)
  • WebLog Expert ( with an Lite Freeware version)

The first one seems nice simple and the GUI is kept very simple. While the second one seems to have a lot of features. However, I have not tried to see exactly which one are available in the lite version.

I might also add a number of other libraires here.

Friday, 12 July 2013

Axiom - XML Processing for Axis and others

I have been taking a look at the Apache Axis2 Web Service framework. Reading the documentation, I was reminded of the Axiom framework used for the processing of XML. Therefore, I will gather here a few informations which I find useful. These info come partially from quickstart-samples. The example are changed a little to be adapted to my way of thinking. This is also a documentation for me.


In addition to be used to process XML efficiently, Axiom can be used to process MTOM messages which are used in SOAP to transport binary data.
Again on the quickstart-samples page, there are some examples. But I will use a separate POST for this.


How to retrieve child elements from root:

public void processXmlFile(File file, String namespace, String elementName) throws IOException, OMException {
// initialize the file input stream to be closed in this method
InputStream in = new FileInputStream(file);
// get the root element
OMElement root = OMXMLBuilderFactory.createOMBuilder(in).getDocumentElement();

// Process the content of the file
OMElement element = root.getFirstChildWithName(
new QName("-http://maven.apache.org/POM/4.0.0", "url"));
if (element == null) {
System.out.println("No <"+elementName+"> element found");
} else {
System.out.println(elementName" = " + element.getText());
}

// Because Axiom uses deferred parsing, the stream must be closed AFTER
// processing the document (unless OMElement#build() is called)
in.close();
}

Schema validation

How to perform partial schema validation (from quickstart-samples).

public void validate(InputStream in, URL schemaUrl) throws Exception {
  SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(in, "UTF-8");
  SOAPEnvelope envelope = builder.getSOAPEnvelope();
  OMElement bodyContent = envelope.getBody().getFirstElement();
  SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  Schema schema = schemaFactory.newSchema(schemaUrl);
  Validator validator = schema.newValidator();
  validator.validate(bodyContent.getSAXSource(true));
}

quickstart-samples presents also a way to do it with a DOMSource instead of the SAXSource.


Perform on chunks of an XML Document


Often it is useful to perform just on a particular chunk of the XML document.

public interface FragmentProcessor {

    public QName getTagName();

    public void processFragment(OEMElement);

}

  public void processFragments(InputStream in, FragmentProcessor fragmentProcessor) throws XMLStreamException {
    // Create an XMLStreamReader without building the object model
    XMLStreamReader reader =
       OMXMLBuilderFactory.createOMBuilder(in).getDocument().getXMLStreamReader(false);
    QName tagName = fragmentProcessor.getTagName();
    while (reader.hasNext()) {
       if (reader.getEventType() == XMLStreamReader.START_ELEMENT &&
          reader.getName().equals(tagName)) {
             OMElement element =
                OMXMLBuilderFactory.createStAXOMBuilder(reader).getDocumentElement();
             // Make sure that all events belonging to the element are consumed so that
             // that the XMLStreamReader points to a well defined location (namely the
             // event immediately following the END_ELEMENT event).
             element.build();
             // Now process the element.
             fragmentProcessor.processFragment(element);
          } else {
             reader.next();
          }
       }
   }

Wednesday, 10 July 2013

Maven Apt and Code Snippets

For a documentation and course I will give I am using the document creation properties from apt of maven. For a documentation of the format see:
the APT format. In order to give an example, you can use a very simple snippet:

    ------
    The APT format ( or the html title of the document)
    ------
    Me the author
    ------
    2013-7-9


The title at the top of the page (not indented)

  The first introduction paragraph.... which is indented so that it is clear that it is a paragraph.

* The first subsection

  Another paragraph also indented

** a subsection with two * in order to mark it as a sub subsection

  A third paragraph followed by an ordered list with numbers

    [[1]] first element

    [[1]] second element


This create the following snippet HTML fragment (in a given generated page).



<h2>The title at the top of the page (not indented)
<a name="The_title_at_the_top_of_the_page_not_indented"></a></h2>

<p>The first introduction paragraph.... which is indented so that it is clear that it is a paragraph.</p>

<div class="section"><h3>The first subsection

<a name="The_first_subsection"></a>

</h3><p>Another paragraph</p>

<div class="section"><h4>a subsection with two * in order to mark it as a sub subsection<a name="a_subsection_with_two__in_order_to_mark_it_as_a_sub_subsection"></a></h4>

<p>A third paragraph followed by an ordered list with numbers</p>

<ol style="list-style-type: decimal"><li>first element</li><li>second element</li></ol></div></div></div>

In order to get snippets, then I use snippet macros as described in: Guide to the Snippet Macro.

Thursday, 4 July 2013

Eclipse installation Problem onWindows7 with cygwin unzip

Once or twice I had problem using unzip to unpack the eclipse code under windows7. Thanks to this answer, it could start eclipse normally. After downloading eclipse:

$> cd dirtoput-eclipse
$> unzip pathwhere-eclipsezipis/eclipse...-version.zip
$> cd eclipse
$> find . -name "*.dll" -exec chmod +x {} \;

Saturday, 29 June 2013

GDM Configuration

Well I learned something about the GDM configuration by reading the well written gnome gdm manual. However, that did not solve my Gnome cofiguration problems.

But at least I know a little bit more how to configure the user screen and put useful on it through the use of an Xwilling script.

Friday, 28 June 2013

Systemd und service control under fedora

I must say I am currently a bit lost in the different mechanisms to start and stop services. I used to perform these tasks with the standard /etc/init.d/... scripts. But it seems that it does not work completely in this way. There seems to be now systemctl, service and chkconfig commands.

service sshd start

to start the ssh daemon.

service sshd stop

to stop the ssh daemon.

chkconfig sshd on

to enable the ssh daemon so as to start it after boot.


To use systemd, the following commands come handy:

systemctl start sshd.service

to start the ssh daemon.

systemctl stop sshd.service

to stop the ssh daemon.

systemctl enable sshd.service

to enable the ssh daemon so as to start it after boot.




Monday, 24 June 2013

python useful packages in combination with command line

I have been playing with python lately and discovered at least two small utility pacages providing useful features in combination with the commandline. For this reason I created two aliases:

alias openurl='python3 -m webbrowser -t'
alias webshare='python -m SimpleHTTPServer'

The first one opens a web page at the url given as a parameter, if the url does not have a protocol, e.g. http, then the command will interpret it as a local file. The second one starts a webserver for the directory where the command is called. Then you can provide in that way a simple mean of letting someone download local files.

Sunday, 23 June 2013

PAM authentication with multiple passwords

I just learned that it is possible to perform cascading failing authenthication. In that way it is possible to use different passwords, for example password with ldap or passwords with the shadow file. When a user logs in with his local password, the configured system would first try to log in with the ldap password for instance, which would fail, then the pam module for the local shadow file would be used.


I discovered this when reading about barada (see sourceforge page). This project offers the possibility of creating a nice remote password mechanism where a token can be obtained from a telephone app, for instance an android. It uses the HOTP protocol described in this RFC.

Friday, 21 June 2013

cmd Hell No! different colored text does not seem that easy

I have been looking for a cool way to change the color of a part of the text in the command prompt... But this proved to be a time stealer, because there does not seem to be any easy way to do it. There are some complex ways but I am not going to look into them.

Create simple GUIs to your scripts - HTA files

While looking for a way to help my grilfriend be more productive I found ut that one can create hta files. The following example is with VB. I have to see if it is possible to use other kind of scripts.


<head>
<title>HTA Test</title>
<HTA:APPLICATION
APPLICATIONNAME="HTA Test"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
</head>

<script language="VBScript">
Sub TestSub
Msgbox "Testing 1-2-3."
End Sub

Sub GetOSVersion
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" &strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
Msgbox objOperatingSystem.Caption &" " &_
objOperatingSystem.Version
Next
End Sub
</script>

<body>
<input type="button" value="Run Script" name="run_button" onClick="TestSub"><p>
<input type="button" value="Get OS Version" name="run_button" onClick="GetOSVersion"><p>

</body>

This may turn out to be useful once or twice. But I would hate to have to program in visual basic.
There was actually an example how to create a simple selection list in powershell. But I have not tried the described there, but the page might be useful to you