Wednesday, June 22, 2011

Google Sites

At work we switched to Google mail some time back. We use Google docs to share docs. I started using Google sites just out of curiosity. Anyone that has a GMail account has automatic access to Google Docs and Google Sites. Google Sites is a simple web site builder. Google Site started as JotBot, a wiki tool that Google bought in 2006 and later developed into what it is today. See wiki article at http://en.wikipedia.org/wiki/Google_Sites for more info.

Creating a Site
Building a site using Google Site is very easy. Simply click on "Create New Site" button and select any site template available in the template gallery. Then select the Theme and visibility settings, voila... you have the new site up and running. Though, it can be used to build any web site, because of it's original wiki flavor, it's a great tool to create wiki pages. Google site also offers several gadgets that can be embedded thus you can include other web pages, graphics etc. Google Docs can easily be embedded as well.

Creating Web Pages
Once a site is created, pages can be added to it at any time. Google Site by default offers the following page templates:

Web Page
Announcements
File Cabinets
etc

Any of these pages can have embedded content. "Web page" template A simple web page. Each new posting to the site will be an additional page. "Announcements" template offers a Blog/wiki style post where each page will have multiple posts. So a wiki site may contain one page of type "Announcements" and multiple posts in it. It's like a blog, except the pages can be added/updated by anyone (See security settings) and thus it's like a wiki page. File Cabinets shows list of files uploaded. One can create other complex templates based on these.

Each page can have comments and attachments. (These options can be turned off for specific pages as well).

Managing the Site
Site settings can be changed at any time, by clicking on More Actions->Mange Site (Only owners can manage sites). This screen can be reached by clicking on "Edit Sidebar" link. Here several options are shown. Here several options are available. In Site Layout option, you can change the size and layout of the site. This also has a Navigation section. By adding pages (links) here, they can be displayed on the side bar. The theme used for the site can be changed at any time as well.

Security Settings
Google Site access is controlled by "Site Permissions". This can changed at any time. Typically permissions are,

1. Public - Any one can see it
2. Anyone with the link - If someone got hold of the link, they can see it
3. Private - Access only by invite; sign-in required to see the pages.

Google Site vs Wordpress
In many ways, Google Sites can be compared to Wordpress.com blog pages. In both, you can create (web) pages quickly and use gadgets ( extensions) to add functionality. Both provide templates and themes to create web pages quickly. In general, Wordpress has a bigger developer community and is also a more matured product. It also has a lot more extensions available. Sites developed using Google Sites tend to be small personal sites. Since Google Sites had a wiki beginning it is stronger on collaboration of content. It allows each site to have multiple owners, contributors and viewers. This makes it more useful for development community to share information within a team.

My Google Sites
I created my first Google Site for our apartment community. It's a small community and I just created a page or 2 as a bulletin board. After that, I created and maintain a web page for our team to use at work. We create some developer documents which we used to dump on Network drive. The problem there was the files are not easily searchable and thus, after 100's files in the drive, we had to rely on individual's memory and notes. I tried to convert these to posts in the Google Site.

The current site I maintain at work has several pages, some with embedded Google Docs (converted Word, Powerpoint, Excel files). I also used a embedded widget to included an IFrame, so I can display an external web site. Since it's meant to be a collaborative site, I created several pages for various topics, each using "Announcement" template, so several posts can be made to the same page. For e.g., I have PB Wiki, for all posts related to our Powerbuilder development environment. Similarly a "Database Wiki" page for database related postings.

Now that we have site up and running, we need to back it up. I will discuss it in a separate post.

Monday, June 20, 2011

Pinging windows PC behind firewall

If your windows PC (XP, Vista) has firewall turned on, it may not respond to ping from other computers on the network. To allow pinging on this computer, try the following command:

netsh firewall set icmpsetting 8

To disable the same,

netsh firewall set icmpsetting 8 disable

Make sure you open command prompt as an Administrator.

Netsh is the command line utility available in windows command prompt (DOS box) to help with network configuration. See here for more on netsh.

The above settings can also be set in windows firewall settings GUI (screen) in control panel. Surprisingly it's a little more convoluted. See here

Dot... and Dotty

As a developer, one of the things I constantly do is documentation. This is not exactly a favorite task of mine, but I know it's a necessary evil. My programs are typically commented generously. Where necessary I create separate technical documents as well.

In order to make this mundane task a little more interesting, I always try to find tools to help with documentation. For e.g., I found Cppdoc, to document C++ programs, (similar to Javadoc), couple of years ago. While researching on this, I stumbled on Dotty. I found a great tool called GraphViz, but  I didn't do much with it at the time.

Recently when I had a need to create a flowchart for a work flow, again I looked for some tools. I could have used Visio and created some diagrams, but I wanted to automate the process of creating diagrams based on some (text) input. While researching, I re-discovered Dot and Dotty!

DOT and Dotty were originally developed by AT&T Bell Labs. DOT is a plain text graph description language. It's a definition language like CSS.  We can simply type up the information about a graph in human readable Text format, then feed it to a tool to generate a visual graph in various graphic formats. Dotty is a graph editor. AT&T actually bundled dotty and other tools as Graphviz. Graphviz is a collection of tools that interpret Dot structures and generate Graphs in various layouts.

In Dot language, Graphs can be defined as directed (DiGraph) or undirected (Graph). It also defines various elements in a graph such as nodes, arrows/lines or edges, labels etc. The syntax for the language includes various attributes of these elements as well. Thus by combining these elements and their attributes, one can build complex graphs/charts. Examples of such diagrams include, database schema diagrams, network nodes and connections, flow charts etc. The tools are capable of generating the diagrams in various graphic formats including JPG, PNG and SVG. A diagram is created in SVG format can be read by visio and other tools, thus sharing is easier.

The specification for DOT language is simple:

For e.g.,
graph {
a--b--c
}
Will generate



Each circle there is a node and the lines (with or without arrows) are called edges. Each of these have several attributes which can be used to control the presentation and to some extent actual layout.

Below is a simple directional graph (lines with arrows):

digraph{A->B->C->A}



Following line creates a yellow colored oval node:

n[style=filled color="red" fillcolor="yellow"]

The same node as a rectangle:
n[shape=rectangle style=filled color="red" fillcolor="yellow"]



There are several other attributes that can be used to build really complex diagrams. See here for syntax. References listed at the bottom have more details.

The strength of Dot is that the language is small and text-based. Thus, we can write scripts or programs to generate such a text description of a graph. One such application would be to generate graphical calling tree for programs.

Dotty and other tools in Graphviz bundle all have similar command line syntax. A typical usage would be,

 

dot -O -Tpng <example.dot>

I found a great use for this tool, recently. At work, we have sort of a workflow system. The system keeps track of various types of Cases generated by the system or created by the users. Each case type is defined by it's own workflow. To track various steps  in the workflow, we used a Treeview structure in Powerbuilder.While I was doing some research on these flows, I had a need to document the flows in a flowchart. As always, I didn't want to just open Visio and draw a few. I wanted to script it, so it can be generated by text and better yet, automatically from the database with the information we have about the flows!

Since it's so easy to create graphs from the text files, we may even be able to build graphs dynamically, thus could represent state diagrams of running processes.

There are various resources available for DOT and dotty. Dotty is originally written in C. There is a Java API (Grappa) available that wraps around Dotty functions. Apart from Dot, there are also other languages available for representing graphs in text format.

References:

http://www.graphviz.org/Documentation.php

http://wapedia.mobi/en/DOT_language

http://code.google.com/apis/chart/image/docs/gallery/graphviz.html

Friday, March 11, 2011

PVCS - Source repository File Server

In PVCS, when we try to open the project database, it typically lists File Servers to select. The file server name listed there is not the actual server's name. Recently, we had to find out what server it was connecting to. This can be done in Admin->File Servers menu option in PVCS. You can add/delete/update server names here.

[caption id="attachment_4952" align="alignnone" width="300"]pvcs_server_list Where to add PVCS server list[/caption]

So, if the PVCS server is changed in the future and you need to connect to the new server, change it as mentioned above. This needs to be done on each developer machine or the ini file could be distributed. (The name of the ini file is, C:\Program Files\Merant\vm\common\bin\win32\servers.ini)

[caption id="attachment_4951" align="alignnone" width="300"]PVCS Servers Fig 2. server list is stored in servers.ini[/caption]

If you connect to PVCS from Powerbuilder (or any other MSSCCI compliant IDEs), you do not have to change anything there. PB actually reads the PVCS servers.ini file to get the PVCS Server name(s). After making the changes to File Server name in PVCS, we just need to disconnect and reconnect to merant version manager in Powerbuilder.

SQLPLUS - Spooling in HTML format

I used this recently and I thought of sharing this. If you don't know this already, SQL*PLUS has built in support for HTML. All you have to do is add markup option either on command line or inside the script. By the nature of it, it is only useful when you are spooling the output. Useful when you are dumping from multiple tables or generating simple reports. Just be aware that the output file will be larger than the usual text file spool.

Just add below to the script before spooling and the

SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON -
HEAD "<TITLE>E-App Validation Report</TITLE> -
<STYLE type='text/css'> -
<!-- BODY {background: #FFFFFF} --> -
</STYLE>" -
BODY "TEXT='#000FF'" -
TABLE "WIDTH='90%' BORDER='5'"

spool cleanup_eapp_data.html

SQLPlus - spool name with embedded timestamp

To be able to create a spool file, with filename embedded with timestamp:

— spool filename with timestamp
col sysdt noprint new_value sysdt_var
SELECT TO_CHAR(SYSDATE, ‘yyyymmdd_hh24miss’) sysdt FROM DUAL;
spool run_filename_&sysdt_var.Log

Update 12/07/12

This was confusing, as I had the same name for column name and the SQL variable created by new_value. I've renamed the two accordingly. This works.

Also, I posted about spooling to HTML some time back. You can combine the two, of course:

col spoolname new_value spoolname_var

select 'tablist_'||to_char(sysdate, 'yymmdd_hh24miss') || '.html' spoolname from dual;
prompt &spoolname_var

SET MARKUP HTML ON -
HEAD "<TITLE>Session Stats</TITLE> -
<STYLE type='text/css'> -
<!-- BODY {background: #FFFFFF} --> -
</STYLE>" -
BODY "TEXT='#000FF'" -
TABLE "WIDTH='90%' BORDER='5'"

spool &spoolname_var

SELECT username, logon_time, status FROM v$session;
spool OFF;

creates a nice HTML file with a list of all users currently logged on to the database. This is saved in a HTML file with timestamp in it's name!

Thursday, March 10, 2011

TomCat + Sybase EA Server

Today another coworker of mine was trying to get XAMPP setup work with our EA Server. (We have PB application and Java objects deployed to this EA Server). He has a complete setup of XAMPP with Apache and Tomcat. He has a JSP page that uses the PB objects. This got to a point and crashed with "class not found" error. Clearly pointing to a classpath issue. But which one?

He mentioned that he had to set the EA Server first before he started XAMPP. Clearly there are some conflicts in the classes shared between the 2. EA Server is normally started using a batch file that reads the env classpath (windows settings in control panel) and adds its own classpaths locally. (SET LOCAL inside batch file). So whatever EA Server set is not visible to XAMPP but not the other way around. That's why he had to start EA Server first.

We then looked for the specific class that was "not found". This happened to a stub for the PB objects. In Jaguar manager (aka Sybase Central, EA Server admin) there is an option to generate stubs (and skeletons if needed). This typically points to SYBASEEASERVERHTMLCLASSES directory. We found out that he also similar classes in SYBASEEASERVERJAVACLASSES directory. We knew these were not used, as they were not in the class path. Then we searched for classes or jar files with similar names. We stumbled on a jar file that contains part of these stubs, inside XAMPP. (He uses OpenBD for coldfusion applications, which is why he has XAMPP in the first place). This jar was old and had part of the stubs classes and did not have the one we were having trouble with.

Apparently Tomcat was automatically loading this jar (Anything inside the lib directory gets loaded automatically). We found that when we tried to rename the file.

Now that we found out the classes in trouble, we thought we could just add the class paths needed to the environment classpath and hope Tomcat would pick it up. This did not happen. On the web, I saw a note about how Tomcat handles classpaths differently than regular Java. There was a suggestion to the classpath to the batch file that starts Tomcat. We didn't try that yet.

For now, we decided to copy the classes to the library folder, so Tomcat can automatically load the classes. So, we shut down XAMPP, regenerated the jar file (in EA Server stub generation, there is an option to generate a jar instead of class files) and copied to XAMPP lib folder and everything worked OK.