How to connect two activities in Android?

Define onClick attribute of button with function to be called as value of the attribute.

android:onClick = login

 where login is the name of function that is called when button is clicked.

 Now define Intent object inside this login() function.

Intent myIntent = new Intent( this, DashBoard.class);

 You need to add second activity name in AndroidManifest.xml file to make operating system know about the existence of second activity.


This is step that we usually forget to do. So keep in mind.

Posted in Uncategorized | Leave a comment

How to use Auto Complete Edit Text in Android?

Get the object of AutoCompleteTextView.

AutoCompleteTextView mAutoView = (AutoCompleteTextView)findViewById(;

Create array of ArrayAdapter.

ArrayAdapter<String> myAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1 ,new String[] {"delhi","delhi2","bangalore","mumbai","pune"});

 Set the adapter of AutoCompleteTextView.


And you are done!

Posted in Uncategorized | Leave a comment

Hello World Program in Java

To write a simple program in Java that prints “Hello World” on console, follow the following steps:

  1. Make a public class named Application.
  2. Define a main function in it.
public static void main(String args[]) 

Make sure method signature should be same as above, otherwise it will give error at run time.

3. Display the text “Hello World” using println().

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

And you are done.

Here is the full source code.

public class Application {
    public static void main(String[] args) {
        System.out.println("Hello World!");
Posted in Uncategorized | Leave a comment

Writing Differential Equations in LaTeX

LaTeX is very useful for doing maths assignments, preparing reports and thesis. I made report in  LaTeX during my six weeks training. Today I tried to write the solution of a differential equation in   LaTeX.

The main things used in it are:

Fractions : These can be written as:


Subscripts: These are wriiten as


here 1 is subscript of C

Differential Equation:


\frac{du}{dt} and \frac{d^2 u}{dx^2}

Partial Differential Equation:


\[ \frac{\partial u}{\partial t}
   = h^2 \left( \frac{\partial^2 u}{\partial x^2}
      + \frac{\partial^2 u}{\partial y^2}
      + \frac{\partial^2 u}{\partial z^2} \right) \]

Summation Sign




\[ \sum_{k=1}^n k^2 = \frac{1}{2} n (n+1).\]



\[ \int_a^b f(x)\,dx.\]

I thin its enough for writing a maths assignment.

Here is the file that I have tried.

\title{Equation-Writing in Latex}
\author{Priyanka Kapoor}
\usepackage{amsmath} % allows you to put text in the math environment.

\section{Linear Differential Equation}
\[ \frac{d^2w}{dx^2} - \frac{4u^2w}{l^2}
   = \frac{-qlx}{2D}+\frac{qx^2}{2D}  \]
Here u, l, q, D are constants.\
Auxiary Equation is \
\[ D^2-\frac{4u^2}{l^2}w=0 \]
\[ (D+\frac{2u}{l})(D-\frac{2u}{l})=0 \]
\[ D=\frac{-2u}{l},\frac{2u}{l} \]
So C.F is\
 \[ C_1e^\frac{-2ux}{l} +C_2 e^\frac{2ux}{l} \]
 \[ C_1cosh(\frac{2u}{l})x \]
  Because \[cosh(x) = \frac{e^-x + e^x}{2} \]
  Now Particular Integral (P. I) is
   \[ PI=\frac{1}{(D^2-\frac{4u^2}{l^2})} (\frac{-qlx}{2D}+\frac{qx^2}{2D}) \]
   \[ = \frac{-q}{2D}\frac{1}{(D^2-\frac{4u^2}{l^2})}(lx-x^2)\]

     \[ = \frac{-ql}{2D}\frac{1}{(D^2-(\frac{2u}{l})^2)}x  + \frac{q}{2D}\frac{1}{(D^2-(\frac{2u}{l})^2)}x^2 \]
     Taking 4u\^2/l\^2 common from denominator \
     \[ = \frac{-ql}{2D}\frac{l^2}{-4u^2}(1+\frac{-l^2D^2}{4u^2})^-1 +\frac{q}{2D}\frac{l^2}{-4u^2}(1+\frac{-l^2D^2}{4u^2})^-1 \]
     Solving binomial as it is of the form \[(1-x)^-1=1+x^2+x^3+ ... \]
   \[ = \frac{ql^3}{8Du^2} (1+ \frac{l^4D^4}{16u^4}+ ...)x + \frac{-ql^2}{8Du^2} (1+ \frac{l^4D^4}{16u^4}+ ...)x^2 \]
   \[ = \frac{ql^3x}{8Du^2} - \frac{ql^2x^2}{8Du^2} \]
   Solution of Differential Equation is \
   C. S = A. E + P. I
   \[w = C_1cosh(\frac{2u}{l})x + \frac{ql^3x}{8Du^2} - \frac{ql^2x^2}{8Du^2} \]

Give the commands

$pdfatex DE.tex
$evince DE.pdf

The PDF fiLe produced is

Happy writing with LaTeX 🙂

Posted in Uncategorized | Leave a comment

How to Reset the password of LDAP Server?

This can be done by slappasswd and ldapmodify commands.

Generating the Hash of new password using the following command:

slappasswd -h <the hashing scheme we want to use - for example {SHA}>

The system will then prompt us twice for the new password to use and will finally display the hashed value we’re interested in.

root@priyanka:~# slappasswd -h {SHA} New password:
Re-enter new password:

Then we’ll proceed to modify the entry we’ve identified above using the command:

root@priyanka:~# ldapmodify -Y EXTERNAL -H ldapi:///

The system will start the listening mode for modifying commands:

SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth

First, we enter the entry we want to modify:

dn: olcDatabase={1}hdb,cn=config

Second, we type in the parameter we want to modify:

replace: olcRootPW

Third, we type in the new password generated above :

olcRootPW: {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=

Hit Enter another time to commit the modification and the following line will appear:

modifying entry "olcDatabase={1}hdb,cn=config"

After this, you can exit the listening mode with CTRL+C and restart the LDAP database service using:

service slapd stop
service slapd start

Now login to LDAP using new password. 🙂

Posted in Uncategorized | Leave a comment

Simple Program in PROLOG

PROLOG, which is an acronym of PROgramming in LOGic, is commonly used for handling  this class of reasoning problems. Prolog is a declarative language that focilityuses on logic.

Prolog has been successfull as an AI (Artificial Intelligence) programming language for the following reasons.

  1. The syntax and semantics of prolog are very close to formal logic.
  2. Prolog language has a built in inference engine and automatic backtracking facility.
  3. This language has high productivity and ease of program maintenance.
  4. Prolog language is based on the universal formalism of Horn Clause.
  5. Beacuse of the inherent AND parallelism, prolog language can b implemented with the ease on parallel machines.
  6. The clause of prolog have a procedural and declarative meaning. Because of this, understanding of the languge is easier.
  7. In prolog, each clause can be executed separately as though it is a separate program.  Hence modular programming and testing is possible.

To run a simple program of PROLOG, just to have the knowledge about the structure of PROLOG program, you need to install swi-prolog on linux system with the command:

sudo apt-get install swi-prolog

Write a simple prolog program named
(note: pl is extension of PROLOG program)

/* Some facts about parent relationships */                           
/* A general rule */                                                  
grandparent(GRANDPARENT,CHILD) :-                                     

To run the program:

1. Start prolog


2. Load prolog program

?- [test].

3. Query the program

?-grandparent(WHO, jim).

It will give


Here is the screen shot for whatever we query.


Overview of PROLOG language:

  1. Facts starts with lowercase letter( or enclosed in single quotes) and ends with a period (.)
  2. Rules have syntax: rule:-condition1,condition2. :- is a break , is AND relationship ; is OR relationship.
  3. Variables starts with uppercase letters.

Thats all. 🙂

Posted in Uncategorized | 2 Comments

Changing Functionality of Circle in LibreCAD

I just changed the code of LibreCAD. Changed the functionality of “drawing circle from 2 points” to “drawing flower pattern from two points”.

Make following changes in this file librecad/src/action/rs_actiondrawcircle2p.cpp

     RS_Circle* flower;
     for (int i=0;i<=360;i=i+60){ 
          flower = new RS_Circle(container,data);
          double radian=i*(M_PI/180.0); 

Compile the source code again and choose Draw->Circle->2 Points.

It will draw pattern as follow:


Thats all 🙂

Posted in Uncategorized | Leave a comment