Friday, May 20, 2011

PingGuin, Net Notifier Software


Software is about making life easier. It's right that to check whether internet is available we make command line ping requests. To know whether the connection is really active we can just ping to www.anydomain.com i.e; www.saosx.com. Whenever this ping fails we ping to our default gateway to check whether gateway is reachable. A gap between the host and gateway will result unreachability to web servers. When gateway is reachable we further need to check whether DNS servers are reachable. So we need more two pings. I always thought about automating these tasks. I have once indeed written a script that does all these works. Well, that's another story.

I wanted to create a software for general people who can use this tool to automate the ping process to all three servers (gateway, pri dns, sec dns) . Moreover, I implemented feature to show balloon tips on the taskbar notification area whenever internet is available.

I have made attempts to make the software as user friendly as possible. When start the software the initial dialog box is shown which has a static box that updates whether internet is available or not. In that window I have enabled automatic retrieval of network interface settings so that user don't have to go through tedious typing everytime he/she starts the software.


It is really amazing that the entire internet is running on kindness and openness of people. Why not I contribute some from my side! That's the reason behind my delivering of this software as open-source. Together we make a better world. I don't want others to go through same tedious procedure during building components for my software. You can straight visit my project source code here:
http://code.google.com/p/pingguin/source/browse/#svn%2Ftrunk

 It's an opensource project. You have freedom to use my code. But please acknowledge me and my project in comment. I will also welcome anyone to contribute in this project. Contribution can be of many forms. May be pointing out a bug, suggesting features that should be included in the future release or working with the code directly and improving the quality of work.

I would like to acknowledge my endless debts to msdn, microsoft forums, codeproject and all the forgotten resources of internet that helped me to get new ideas and develop and nourish them. msdn is Microsoft Developer Network and forum for VC++ is available here: http://social.msdn.microsoft.com/Forums/en/category/visualc while codeproject is an awesome website for helping developers across many programming languages and frameworks.

Native Software developers can take help on following topics from my this project:
  1. Standard mechanism of accessing Windows Management Instrumentation information
  2. DNS Lookup and PING API (alway check msdn for reference)
  3. Showing Balloon Tips and adding icon in the taskbar
  4. Displaying menu from resource using tray icon
  5. Creating Windows Threads using structure
  6. Unicode string manipulation (using tchar library)
  7. Creating Installer for Native Software (see PingGuin_Installer in the svn trunk)
I'm building an API for network tools and parsing other types of information some of which release under project sasubsync, Wireshark Parser, Stutdown Timer, Blogger Code editor etc. A compendium will be provided in my site in future. So in related topics you are welcome to take help. If some code isn't available you can ask me.

By this time when I'm writing this post this software is available for Windows only. I'm checking user responses. According to that I'll decide whether to release for other platforms. You can download installer of pingguin for windows from here:
http://code.google.com/p/pingguin/downloads/list


This software is built in my off-time (killing my traveling time, yeah I call this little exploring in this universe as traveling, you can't sue me until you're oracle! :P). Hence, this software has still no relation with my software company, Reve Systems. It's all about pingguin, a net notifier software. You are welcome to visit: http://code.google.com/p/pingguin/

Sunday, January 2, 2011

Installing Latex on Windows and Linux and Latex Document Compilation Instructions

In this article, I’ll present some tips and tricks on how to do certain things on latex such as adding sections, subsections, inserting images and writing equations etc. Then I’ll provide a sample tex file and instructions for compiling the file using latex along with installation instructions of latex software on various operating systems.

Adding sections and subsections in latex documents

To add a section, use section tag. Here’s an example,

\section{Overview}
If this section is in a chapter it is preceded by a numbering. For example, if it is chapter 1 numbering is 1.1, 1.2 etc.

If you want to add a subsection under a section use use subsection tag. Here's an example,


\subsection{Formulation}

It will have numbering like 1.1.1, 1.1.2 etc. If you need subsections under subsection, use subsubsection tag.

No more nesting (after 3 levels) is supported.


How to insert images on latex documents

The first thing you need to do is to convert your image (jpg, png, gif etc) to eps (a postscript format) which is easy to convert to pdf. To convert an image to eps format you need ImageMagick. In fedora installation command of ImageMagick is

# yum install ImageMagick

In Windows you can install ImageMagick after downloading from http://www.imagemagick.org/download/binaries/

Current latest release direct link for Windows:
http://www.imagemagick.org/download/binaries/ImageMagick-6.6.6-7-Q16-windows-dll.exe

Now use the convert command to convert the image.


$ convert filename.jpg filename.eps

In widows you have to put the installation path as well with the command. For example, if it installed in C:\Program Files\ImageMagick directory.

C:> “C:\Program Files\ImageMagick\convert.exe” filename.jpg filename.eps

To view eps files you need ghostscript. In Windows, you can install ghostscript from here:
http://ghostscript.com/releases/gs900w32.exe

In Fedora, you have to apply following command as root to install ghostscript,


# yum install ghostscipt

Now it’s time to include the eps file on tex. Use figure tag to make caption, includegraphics command to include the image. You need to specify the correct path of your image in \includegraphics command. Here’s an example,

 1 \begin{figure}[htbp]
 2   \centering
 3 \includegraphics{./Figures/SA_Spheric.eps}
 4   \caption{Latitude and Longitude \label{ Latitude and Longitude }}
 5 \end{figure}

Set the caption text and label text same. Label text is used on List of figures. In a template they are automatically numbered according to chapter. If you need to scale up image to half of its size use scalebox tag along with includegraphics.

\scalebox{0.5}{ \includegraphics{./Figures/SA_Spheric.eps}}


Writing scientific/math equations in latex

If your equations require numbering on right side use this tag,

\begin{equation}  Your math exp \end{equation}

For example,

\begin{equation}\int r = \sqrt[2]{x^2 + y^2 + z^2}\end{equation}

But if your equation doesn’t require numbering use tag like this,

\begin{math}  Your math exp \end{math}

For example,


Our equation is, \begin{math}\int r = \sqrt[2]{x^2 + y^2 + z^2}\end{math}. Proof ...

Integration symbol: \int

To show only root sign not n-th root use tag: \sqrt{x}, replace x with your expression or symbol

To show nth root use tag: \sqrt[n]{x}

To show fractions like ½ use \frac tag. Example,


thd = \frac{1}{n}

For summation sign use \sum tag,

\sum\limits_{i = 1}^n Abs (t_i - t_{i-1})\end{equation}

\limits is used to set limits on summation sign. Here, i=1 goes down and n goes up. You write texts preceding _ to put them down (subscript) and use ^ to superscript.

For using only one math symbol you can use \ensuremath{} tag. For example,


If angle in degree is \ensuremath{\theta} then the slope is ..

Here are latex tags for some of the math symbols:

\Phi
\lambda
\Pi
\epsilon

You can find a detailed list of latex symbols here:
http://web.ift.uib.no/Teori/KURS/WRK/TeX/symALL.html


Installation Instructions of Latex for Fedora Core

Apply following commands after opening a terminal and logging into root. Alternatively you can apply su command and provide root password for instant switching.

$ su
Password:
# yum install tetex-latex evince-dvi xdvik


Installation Instructions of Latex for Ubuntu

Apply following commands if you are using Ubuntu

# sudo apt-get install tetex-base tetex-bin


Installation Instructions for Windows (XP, Vista, Seven)

Download basic-miktex from here: http://miktex.org/2.9/setup and run the installer.


Compiling Tex Documents

Now let’s learn how to compile latex document file. Here’s a sample tex file,

\documentclass[12pt]{article}
\usepackage{amsmath}
\title{\LaTeX}
\date{}
\begin{document}
  \maketitle 
  \LaTeX{} is a document preparation system for the \TeX{} 
  typesetting program. It offers programmable desktop publishing 
  features and extensive facilities for automating most aspects of 
  typesetting and desktop publishing, including numbering and 
  cross-referencing, tables and figures, page layout, bibliographies, 
  and much more. \LaTeX{} was originally written in 1984 by Leslie 
  Lamport and has become the dominant method for using \TeX; few 
  people write in plain \TeX{} anymore. The current version is 
  \LaTeXe.
 
  % This is a comment; it is not shown in the final output.
  % The following shows a little of the typesetting power of LaTeX:
  \begin{align}
    E &= mc^2                              \\
    m &= \frac{m_0}{\sqrt{1-\frac{v^2}{c^2}}}
  \end{align}
\end{document}

Open a text editor. Create a new file and paste the code given above. Save the file with name test.tex.

Now let’s compile the tex file. In Linux, apply following commands on terminal


$ latex test.tex
$ dvipdf test.dvi

A pdf file will be generated with same filename. In Linux if you need to view dvi files you can use either evince or xdvi

$ evince test.dvi &
$ xdvi test.dvi &

In Windows, you might skip generating dvi files. You can use pdflatex.

To compile tex files in Windows you need to apply following command,


D:> "C:\Program Files\TeX\miktex\bin\pdflatex.exe" test.tex

assuming "C:\Program Files\TeX” is your installation directory for basic-miktex.

If there is no error on the tex file it will generate a pdf document which you can open using a pdf reader like Adobe pdf reader or Foxit Reader.


More tips and tricks

Here’s an example of using bullets for following texts:
  • Dining and canteen system
  • Library, reading room system
  • Debate,language club system
  • Games and sports system
  • Washing and cleaning system and Utensil management

\begin{itemize}
    \item {Dining and canteen system}
    \item {Library, reading room system}
    \item {Debate,language club system}
    \item {Games and sports system  }
    \item {Washing and cleaning system and Utensil management }
\end{itemize}


Using tables
Follow this link: http://en.wikibooks.org/wiki/LaTeX/Tables It explains tables well.

Adding newlines: use \\ to add a newline

Using Bold styles: Use \textbf{text here} tag to bold your text.

Italicizing texts: You can use \emph tag or \textit tag to italicize your text. Example,


\emph{set your text here}
\textit{set your text here }

Subscripting: Write texts preceding _ to make them subscripted. To write xi type x_i

Superscript: use ^ to superscript. To write x^2 use x^2 exactly.


Troubleshooting

If you get errors like this frequently,

! Missing $ inserted.

                $
l.128 ...Distance (C_{i}, C_j)\end{math}, where K_
                                                  i, K_j is Cluster.
?

Latex expects including math tag during usage of math notations like superscript, subscript and symbols. Here’s an example,

\begin{math} Your expression for example C_i end{math}

When this syntax is ensured latex will not display those error messages anymore.