Context Encryption using Natural Language Processing

I’ve drafted a proposal for context encryption using NLP. It is a draft and might need a revision.

Abstract:

With the advancement in Natural Language processing, it is now possible to devise schemes to change the context of sentence, paragraph or article so that the original context is hidden. Such schemes would be required in post-quantum world. I propose a novel method of Context Encryption which will contextually encrypt the sentence. The proposed model adds another layer to the encryption model of PGP. The proposed system will be using Stanford NLP Parser to get the structure of sentence and replace it with the sentence of similar structure.

To download, click the following link :  Paper- Context encryption using NLP

Can we predict earthquake?

7 day prediction map

Earthquake prediction at 1 May 2013 1o:20 AM

Scientists since ages have  said that earthquakes cannot be accurately predicted. I tried to develop a simple program which might tell where the next earthquake  might happen in next 3 days.   I  used the following assumptions to draw the earthquake prediction map.

Assumption 1: smaller earthquakes are triggered before the major earthquake.

Assumption 2 :  the longer the gap between earthquakes of smaller magnitude and current period, the higher is the probability of  earthquake of major magnitude(near to  6.0 richter scale or even greater than that).

These assumptions are really vague and to start the initial predictions. However,  I suggest to   adjust the weight of heatMap  by using multivariate linear regression. There can be additional hidden parameters like  solar discharge which interferes with earth magnetic field and maybe the core which later affects the movement of tectonic plates.  Such variables are not used in the present code.

The latest electron flux can be seen from the below image

.

 

 

Here goes the code. The most of the code is taken from Google HeatMap documentation.

Continue reading

Breaking myth about C and C++

Breaking Myths about C and C++ – Part 1

Myth C++ is a high level Language

Reality The Answer is NO. Both C and C++ is middle level language. Though, C++ tends toward high –level languages but still it has some middle-level languages feature like pointers. If there are pointers, we can interact with address; we can do that in C++ too.

Myth High level languages are modern and middle-level languages are their ancestors.
Reality This is not at all true. FORTRAN is a high-level language and provides a higher degree of abstraction from C but it was developed earlier and has less features and less flexibility. FORTRAN, BASIC and PASCAL are high-level languages developed much earlier than C or C++. They have one thing common in them, they are non-structured. All the ancient languages are non-structured while modern languages are highly structured. Structured languages are Pascal, Ada, Java, C#, C++, C, Modula-2

Myth we cannot declare a variable with the name main

Reality Yes we can as main is not a keyword, but it will confuse compiler, therefore it is suggested that we should avoid using it.

Myth
#include<stdio.h>
int i;
void func1(void);
void func2(void);
int main(void)
{
i =100;
printf(“%d\n”,i);
func1();
func2();
}
void func1(void)
{
int i =0;
printf(“%d\n”,i);
}

void func2(void)
{
printf(“%d\n”,i);
}
The output of this program will be
100
0
0

Reality
The output will be:
100
0
100

If global variable is declared again locally, the value of global variable in that scope changes locally according to changes in that scope but the changes are not reflected globally.

Myth There are two qualifiers that control how variables may be accessed or modified: const and volatile. A variable cannot be both const andvolatile at the same time.

Reality const prevents the variable’s value to be changed if explicitly specified by the program whereas volatile allows the variable’s value to be changed in ways not explicitly specified by the program. For example, a global address may be passed to the operating system’s clock routine and used to hold the real time of the system. In this situation, the value is not changed explicitly changed by the program. Therefore, system clock cannot be changed by any naïve user as well as it gets changed automatically.

Myth extern is another way to declare global variables and extern is used to declare the global variables and function from within the main function.

Reality It is true that when a variable is declared preceding with the extern specifier, it becomes global variable but it is used for different purpose. Suppose, a variable is declared extern, then it is not required to define the variable in the same file and there can be many declarations but only one definition. It is used to make compiler understand that the given variable has external linkages. Thus, compiler will not generate errors if the variable is not defined. extern can be used to declare functions and main functions from outside any function. It is usually used in header files. In C++, While providing linkage specification of function for other languages, extern definition should be written outside any function.

extern “Java”
{
void MyName( )
void ResourceAllocator( )
}

The ‘Maya’ of static

What if you want to implement main() function in the program. What should be the syntax?
public static void main( string[] args)
is the customary declaration of main() function followed by its definition.

Why to declare main() function static?
The reason is that there is only one main() method in a particular class and it doesn’t require an object to access the main(). main() is available througout the execution of program.In fact, all the fields and methods declared static are available throughout the class and are stored in a heap whereas local variables are stored in stack

let us take an example, it will clear some of my and ur doubts:
class Demo
{
private int count ;
public static void main(String[ ] args)
{
int newValue;
system.out.println(newValue + ” = ” +count );
}
}
Here, the field private to the class (if not static) when used in main() give Compile Time Error. as main() is static.To make it code compilable, alter the code so that
class Demo
{
private static int count ;
public static void main(String[ ] args)
{
int newValue;
system.out.println(newValue + ” = ” +count );
}
}

When ‘Demo’ is executed , it creates ‘count’ variable immediately as it is declared as a static member of class. But ‘newValue’ is created only when main() is called. Variables inside a method are dynamically created when they are called.

Can static field be shared?
Yes static field can be shared. For example
class A
{
static int a;
A()
{
int value;
}
}
if we instantiate in another class the object a1, a2, a3, a4… of class A. All we share the variable ‘a’ with individual ‘value’ variable. The advantage of such a variable is that a lot of space is saved but it also has disadvantage: any object can modify its value.

How to access static members?
Inside class, static fields are accessed by their name only, while outside class the static field are accessed in this way.
classname.fieldname
only if it is public.

In constructor, can we declare static methods or fields?
The answer is obvious no. The constructor is used to instantiate object and we know that the static members r available throughout the class, not when the object is instantiated.

Now let us consider the code:
class xyz
{
public double x()
{ …. }
public static int getcount()
{
x();
return count;
}
}
It will give an compile time error as static method getcount() cannot access non-static method x().
To access the non-static method, we need to instantiate an object in getcount()
{
xyz x1= new xyz();
x1.x();
return count;
}
Recall C! Is there any such restriction related to static storage class??

Till now, we saw that static methods can access members outside the function only if
(i) they r static or
(ii) they r accessed by the object which belongs to that class.

Are there any such restriction on non-static members?
I didn’t find any, non-static methods can access both static and non-static methods.

There are some static blocks in the program. Like static method, static blocks can access only static members. Static blocks are executed first, that too only once. Static block execution is followed by static sub blocks and then by non-static blocks.

class A
{
static //static block
{

}
{ //non-static block

}
}

Why static blocks are created?
I’m not really sure why they r created but they can be created to avoid repetition of initialization. Remeber, non-static members can use static members.

Why non-static blocks are created?
I think they are useful in creating anonymous classes.

updating xml stored in oracle tables

REM **********************************************************************
REM Set Environment parameters
REM **********************************************************************

SET scan off;

set serveroutput on size 100000;

select ‘START TIME: ‘||to_char(sysdate,’mm/dd/yyyy hh24:mi:ss’) from dual;

DECLARE
xml_text1 clob;
xml_text2 clob;
xml_text3 clob;
xml_text4 clob;
xml_column_name VARCHAR2(50) := ‘demo.xml’;
sql_stmt1 VARCHAR2(2000);
sql_stmt2 VARCHAR2(2000);
sql_stmt3 VARCHAR2(2000);
sql_stmt4 VARCHAR2(2000);
BEGIN
xml_text1 :=’ –….. put your xml data here…

‘;

xml_text2 :=’ –….. put your xml data here…

‘;

xml_text3 :=’ –….. put your xml data here…

‘;

xml_text4 :=’ –….. put your xml data here…

‘;

sql_stmt1 := ‘update BL1_XML_CONFIG set XML = :1, SYS_UPDATE_DATE = SYSDATE where OBJECT_NAME = :2 and SCHEMA = :3’;

sql_stmt2 := ‘update BL1_XML_CONFIG set XML = XML||:1, SYS_UPDATE_DATE = SYSDATE where OBJECT_NAME = :2 and SCHEMA = :3’;

sql_stmt3 := ‘update BL1_XML_CONFIG set XML = XML||:1, SYS_UPDATE_DATE = SYSDATE where OBJECT_NAME = :2 and SCHEMA = :3’;

sql_stmt4 := ‘update BL1_XML_CONFIG set XML = XML||:1, SYS_UPDATE_DATE = SYSDATE where OBJECT_NAME = :2 and SCHEMA = :3’;

EXECUTE IMMEDIATE sql_stmt1 USING xml_text1, object_name, schema_name;
EXECUTE IMMEDIATE sql_stmt2 USING xml_text2, object_name, schema_name;
EXECUTE IMMEDIATE sql_stmt3 USING xml_text3, object_name, schema_name;
EXECUTE IMMEDIATE sql_stmt4 USING xml_text4, object_name, schema_name;

commit;

END;
/
SET scan on
REM **********************************************************************
REM Get time
REM **********************************************************************
select ‘END TIME: ‘||to_char(sysdate,’mm/dd/yyyy hh24:mi:ss’) from dual;

Universe as I see

Please note: this is a monologue on thoughtful evening and has no scientific basis. This might be true or false.

Plasma universe is primordial whereas big-bang universe is it’s re-incarnation.

I might be wrong but I’ll try to answer this question.  I cannot say what was present in the beginning  but Plasma Universe is more plausible. The cosmological noise was uniform across the universe. However,  temperatures differences became a norm with every big-bang. This is just a hypothesis.

The Hawking’s Grand Design looks incomplete to me. There’s more into it. I’ll not say it’s wrong. It’s half-truth.I’ll start with simple example.

The light is propagating at constant velocity in the universe. Nothing can travel faster than light.So, how come light can’t escape black hole?

the centripetal force on light = mv^2/r

How come light can feel the force since it is massless? Hmm. something else is in play. There is mass in play. Maybe, universe itself has mass, something which exists solely for the propagation of the light. the mass of the space fabrics itself determines the speed of light. We also know the mass and energy are interchangeable.

why E=mc^2? why the speed of light.

suddenly, a mass of nuclear particles is converted into universal mass, which is very different kind of mass it doesn’t interact with normal mass , it just sweeps through it.so, what is the mass of universe?

mass of universe (occupied by photon)= E carried by photon/ (speed of light)^2 = theoretical mass of light

Now, acceleration due to gravity is powerful enough to attract such minimal mass of universe. since the universe itself has moved towards black hole, it seems that light cannot escape from it.

So, why does black hole doesn’t annihilate the complete universe? Why universe is expanding at rapid rate? If universe has a mass, so where is this ever expanding mass coming from? let’s ask what is blowing that ‘universal balloon’ that number of holes like ‘blackholes’ cannot flatten it?

The answer is : blackholes themselves but from other universe:)

Think as universe is getting dragged into black holes but it doesn’t interact with matter but only with photon! Assuming the black hole is symmetrical spherical object, it might be pushing the universe fabric outwards on the other side and reversing the effects on star and galaxies it engulfed. So, if a new black hole is created in this universe, it might create a new universe appearing as a new bright star. Thus, in initial universe, the speed of universe is more than the speed of light. If two black holes have the same mass in this universe, these two black holes will emit the universal mass and light in the same universe. Initially, there might be one black hole giving birth to the universe, but later, due to probability, this universe will have more than two black holes feeding the newly created universe.

In initial few seconds, the universe is expanding at speed light and due to loss of mass of engulfed objects and their explosion,extra universal mass is also getting created. Later, galaxies and black holes are created which started dragging back universal fabric and bending it. So, black holes are wombs used by universe to give birth to other universes. It might be appear strange that a single universe can be nurtured in many wombs,but universe is not a simple baby. Infact, some universe remains in womb for very long time. What happens if there is no black hole from other universe to feed a particular universe. There is no universal mass for black holes to drag and all black holes in this universe which will come very to each other and probably will collapse into each other. This is called a situation of big-bang.

So, what is the effect of expanding and sweeping of the universal fabric? That effect is called ‘time’. The more space sweeps through the body,the more time we have spent in the universe.It means that the speed of light is the speed of fabric. If this is the case, the assumption that the speed of light is constant might be invalid. The speed of light at any place in this is directly to the rate  of  expansion of the universal fabric at that part of the universe or maybe the light is independent and only the time is only directional proportional to the rate of expansion of the universal fabric. what could constitute this universal fabric?  Is it neutrino which sweeps through and goes undetected?

The universal fabric or undetected mass which was present with me few hours ago has already reached to Mars. What happens to time if black holes come near to each other? Universe has started shrinking and probably, rest of the matter is already spread to different universe. The time will start going backwards for the people who stays at the event horizon of universe and probably their world is about to collapse. the people leaving at event horizon will feel all of sudden but probably, it will appear as very slow period. It should be noted that 10 minutes would be equal to nearly 1 million years on the earth.

When this process completes and big bang initiates, the time of this universe is zero.

Irrespective of whether the above assumptions are true or false, nothing gets destroyed and nothing gets created.

how to handle _root with mutliple swf

I was working to create a  flash-based football game application.  Inside the game, a football player moves in various direction when I press the arrow keys. However, it was not working fine after I dd some changes.

The code of football player goes like this.

function step(who) {
	//check to see if the football player in question is controlled by the player or by the computer
	if (_root["football"+who].code == "player") {
	....

It looked like a decent piece of code until I added some other features. The problem is I was loading some other .swf after loading this .swf. As a result, _root gets changed everytime a new movie is loaded. _root always point to latest .swf unless _lockroot is true.

this._lockroot = true;

Using the below code, I was able to ensure that the given .swf will be treated as root.

  onClipEvent (load)
  {
    this._lockroot = true;
  }
  game_mc.loadMovie ("football.swf");

Writing your first JDBC Application?

Ok, after a long time, here is core technical blog for all of u.
If u r wondering how to access MySQL database using JAVA program. The answer is JDBC application!

Before going to coding, u must understand certain aspects of JDBC programming.

1. You must include Jconnector in the classpath of ur machine so that Java program can interact with ur database schema. Further, you must import packages to use built-in SQL execution functions in Java.

2. You have to register the JDBC driver so that u can open a communication channel to database.

3. Then, you have open the Connection using getConnection() Method.It’s use is demonstrated later in the code.

4. After, the Connection is established, you need to execute a query. For that purpose, it requires using an object of type Statement for building and submitting an SQL
statement to the database.

5. After the execution of query, the result is stored in ResultSet. You will often use the appropriate ResultSet.getXXX() method to retrieve the data from the result set.

6. Atlast, it is always safe to close all the resources instead of relying on JVM’s garbage collection.

Here is the sample code!
//STEP 1. Import packages

import java.io.*;
import java.sql.*;
public class cleaning
{
public static void main(String[] args)
{

Connection con=null;
Statement stmt =null;
ResultSet rs=null;
try
{
//STEP 2: Register JDBC driver
Class.forName(“com.mysql.jdbc.Driver”);

//STEP 3: Open a connection con=DriverManager.getConnection(“jdbc:mysql://localhost:3306/student?user=root&password=it”);

//STEP 4: Execute a query
stmt=con.createStatement();
String sql;
sql = “SELECT RollNo, FirstName, LastName, FirstSem FROM Finalyr”;
rs = stmt.executeQuery(sql);

//STEP 5: Extract data from result set
while(rs.next()){
String rollno= rs.getString(“rollno”);
String firstname = rs.getString(“firstname”);
String lastname = rs.getString(3);
int firstsem = rs.getInt(4);
System.out.println(“Roll no.: ” + rollno +”, “+ firstname+ ” “+lastname+”,Ist Sem:”+firstsem);
}

//STEP 6: Clean−up environment
rs.close();
stmt.close();
conn.close();
}
catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}
catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}finally{
//finally block used to close resources
try
{
if(con!=null)
con.close();
}
catch(SQLException se){
se.printStackTrace();
}
}
}
}

nJoy!

how to create an application in Flex?

Create a user interface using MXML to accept user-supplied keywords and display photos

  • Write a method and event handler using ActionScript
  • Request and handle RSS data from Flickr using Flex HTTPService
  • Create a bindable XML variable used to populate a Tile component
  • Cast data as XML
  • Create a namespace for the XML thumbnail and description data
  • Create an item renderer to display photo thumbnail and description in the Tile component
  • Create a custom component
  • Customize the application display

tutorial link: http://learn.adobe.com/wiki/display/Flex/1d.+RIA+Tutorial