Tuesday, 10 January 2017

How to reach from Swargate to Vishrantwadi

If you are arriving in the night at swargate between 9:00 to 10:00 pm, you can reach to vishrantwadi quickly as follows:

  1. Take the Pune station bus from outside of Swargate City bus Depot.

    Cost = Swargate to Pune Station = Rs. 10/-
  2. When conductor will say this is the last stop, board there.
  3. Now you are at the bus stand of Pune station. It is a small one and having 3 tracks which is its identity.
  4. You will get next bus within 10-15 min approx for Vishrantwadi and last bus will be on 11:30 pm.

    Cost = Pune Station to Vishrantwadi = Rs. 15/-
Otherwise, you can wait inside City bus Depot for the bus from Swargate to Vishrantwadi which costs Rs 20/- and a long wait time unless you are lucky ;)


Hope this helps,

Happy Journey!

Tuesday, 19 July 2016

Fix/Solution of MySQL 5.7 warning for SSL in Netbeans/Eclipse

If you are running MySQL 5.7.x and Netbeans 8.1 and you come across this warning,

"WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification." 
Don't worry! The culprits are:

1. MySQL 5.7.x (Actually its a good feature but really annoying to new users)

2. MySQL Java Connector Jar File

Solution for Culprit 1:

If your traditional code for JDBC is like:

 /*
  * To make java and mysql connectivity
  */
 package com.java.databases;
 import java.sql.*;
 /**
  *
  * @author mayur
  */
 public class Java2MySQL {
   public static void main(String[] args) {
     String dbname = "ram_db";
     String uname = "root";
     String passw = "ramayan";
     String url = "jdbc:mysql://localhost:3306/";
     String driver = "com.mysql.jdbc.Driver";
     try {
       Class.forName(driver);
       System.out.println("Connection is Registered");
       Connection conn = DriverManager.getConnection(url+dbname, uname, passw);
       System.out.println("Connection is Open");
       conn.close();
       System.out.println("Connection is closed");
     } catch (Exception e) {
       System.err.println("Something is wrong!! Please wait while we fix it");// e.printStackTrace();//(Something is wrong!! Please wait while we fix it);
     }
   }
 }

So the modified code is:

 /*
  * To make java and mysql connectivity
  */
 package com.java.databases;
 import java.sql.*;
 /**
  *
  * @author mayur
  */
 public class Java2MySQL {
   public static void main(String[] args) {
     String dbname = "don_db";
     String uname = "root";
     String passw = "";
     String url = "jdbc:mysql://localhost:3306/"+dbname+"?autoReconnect=true&useSSL=false";
     String driver = "com.mysql.jdbc.Driver";
     try {
       Class.forName(driver);
       System.out.println("Connection is Registered");
       Connection conn = DriverManager.getConnection(url, uname, passw);
       System.out.println("Connection is Open");
       conn.close();
       System.out.println("Connection is closed");
     } catch (Exception e) {
       System.err.println("Something is wrong!! Please wait while we fix it");// e.printStackTrace();//(Something is wrong!! Please wait while we fix it);
     }
   }
 }

You will find that we have appended [+dbname+"?autoReconnect=true&useSSL=false" ] to the part after URL of database.

Example:

 Connection con = DriverManager.getConnection
 ("jdbc:mysql://localhost:3306/"+dbname+"?autoReconnect=true&useSSL=false","root","");

Solution for Culprit 2:

Change the driver version of mysql connector other than 5.1.39. I have checked for 5.1.38,5.1.36.

Just use these versions and you program will be free from warning.

I have tested this with Eclipse also.

Hope this will help you !

Saturday, 3 October 2015

Installing CUDA on Ubuntu 12.x/14.x Distros

Hi All,

This has been a long time that I have not published articles.  I am trying to learn CUDA for Parallel programming architecture.

First few words about CUDA [a/c to my understanding]:

Compute Unified Device Architecture[CUDA] is technology developed by NVIDIA. The purpose of

CUDA is to let the processor for executing the programs/instructions in parallel manner. Simple !!



Now let's see most cumbersome task that we all are waiting for Install NVIDIA SDK on Ubuntu

To test are NVIDIA  drivers going to work fine for us,

first we will Install ubuntu as under windows installation.

Copy cuda_6.5.14_linux_64.run on desktop of ubuntu.

Log in as root

run update for ubuntu
# apt-get update

To install compiler
# apt-get install build-essential

To switch to Text,

Alt+Ctrl+F1

Enter username and password

login as root.

stop GUI service

# service lightdm stop

# chmod +777 cuda_6.5.14_linux_64.run

# ./cuda_6.5.14_linux_64.run

if absolute path demanded by NVIDIA, press y

and enter for /home/user option.

It will say installation skipped

then reboot with

# reboot -h

Now, again with GUI do following steps:

Login as root.

Switch to text console

Alt+Ctrl+f1

login as root

# service lightdm stop

#./cuda_6.5.14_linux_64.run

now reboot system manually

Now after system gets booted, enter two commands as general user:

 export PATH=/usr/local/cuda-6.5/bin:$PATH
 export LD_LIBRARY=/usr/local/cuda-6.5/lib64:$LD_LIBRARY_PATH

Now we are ready to run our hello world program for NVIDIA CUDA.

As the name suggests. the extension of our program will be .cu

So copy-paste "hello world" from this link in gedit

http://computer-graphics.se/hello-world-for-cuda.html

Save to desired directory.

Now time to compile and run.

compile with:  nvcc -cuda hello.cu
run with:      ./a.out

You output will be:

Hello World !!

Ta..Da... CUDA has been installed successfully.

Installing FreeGLUT in CodeBlock



Install FreeGLUT (Be Careful )

1.       Download : http://www.transmissionzero.co.uk/software/freeglut-devel/
From above location, download freeglut-mingw.zip
Extract the file in any folder.

2.       Now create two copies of GNU GCC Compiler.

a.       First is 32 bits and copy following files as directed:
        
File
From (FreeGLUT\)
To(MinGW32\)
freeglut.dll
bin
bin and C:\Windows\System32\
Freeglut.h
Freeglut_ext.h
Freeglut_std.h
glut.h  (optional as in previous step)
include\GL
include\GL
libfreeglut.a
libfreeglut_static.a
lib
lib

b.      Second one, 64 bits is other copy for it do as follows:

      File
From (FreeGLUT\)
To(MinGW64\)
freeglut.dll
bin\x64
bin and C:\Windows\SysWOW64\
Freeglut.h
Freeglut_ext.h
Freeglut_std.h
glut.h
include\GL
include\GL
libfreeglut.a
libfreeglut_static.a
lib\x64
lib

3.       Now move to settings of Compiler in CB.
a.  For 32 bits Compiler version,

Don’t forget to update Toolchain Executables as per need ,here, C:\TDM-GCC-32

Linker Settings =>Link Libraries
C:\TDM-GCC-32\lib\libfreeglut.a
C:\TDM-GCC-32\lib\libfreeglut_static.a

In “Other Linker Options”
-lOpenGL32 -lglu32 –lfreeglut

Search Directories Tab => Compiler
C:\TDM-GCC-32\include
Search Directories Tab => Linker
C:\TDM-GCC-32\lib

b.  For 64 bits Compiler version,
Don’t forget to update Toolchain Executables as per need ,here, C:\TDM-GCC-64

For toolchain Executables (in order of appearance)
gcc.exe
g++.exe
g++.exe
ar.exe
windres.exe
mingw32-make.exe

Linker Settings =>Link Libraries
C:\TDM-GCC-64\lib\libfreeglut.a
C:\TDM-GCC-64\lib\libfreeglut_static.a

In “Other Linker Options”
-lOpenGL32 -lglu32 –lfreeglut

Search Directories Tab => Compiler
C:\TDM-GCC-64\include
Search Directories Tab => Linker
                  C:\TDM-GCC-64\lib

4.       Now, create empty project with choosing compiler suitable to your OS. Right click on Project and go to the project properites and Build Targets => build type => GUI application
5.       Now download and extract this zip file:
6.       And place *.h and *.cpp files into CB project locations.
7.       Now again confirm Compiler from Rt Click on project => Build options.
8.       Now rebuild => build => run.

                You will get this output:

Installing GLUT in CodeBlock



For GLUT:
Considering we are having Codeblock and MinGW compiler,
      1.      Download this file: http://www.deannicholls.co.uk/site/files/glut.zip
      2.      Now perform following steps:
Extract the 'Glut.zip' file you downloaded and do the following:-

Copy glut32.dll into your 'C:\Windows\System32' folder (If you're using Windows 7 64-bit, you'll need to copy this file into 'C:\Windows\sysWOW64').

Copy glut.h into the ‘include\GL’ folder in the MinGW compiler folder.This folder will be 'C:\MinGW\include\GL'.

Copy libglut32.a into the 'MinGW\lib' folder. If you installed CodeBlocks and MinGW to the default directory in Step 3, this folder will be 'C:\Program Files\CodeBlocks\MinGW\lib'.

      3.      Go to CB=>Settings=> Compiler => Copy your “GNU GCC Compiler”
      4.      Rename your new compiler.
      5.      In Linker Settings => Link Libraries, add the following lines:
opengl32
glu32
glut32

      6.      Your GLUT compiler is ready and its time to execute program:


 // Created by: Dean Nicholls  
 // Date: 18th June 2010  
 // Created For: http://www.levelbylevel.com  
 //  
 // This is a small OpenGL application which will display a  
 // blue sphere on a black background.  
 //  
 // This Program was created to acompany the tutorial  
 // for setting up CodeBlocks, MinGW, OpenGL and GLUT.  
 // Found at: http://www.levelbylevel.com  
 //  
 // It is not intended to be a guide or even a good  
 // template for building a graphic application. It is  
 // therefore not properly commented or efficient.  
 // However feel free to use this code in any way you wish.  
 #include <iostream>  
 #include <GL/glut.h>  
 using namespace std;  
 GLfloat mat_ambient[] = {0.5, 0.5, 0.5, 1.0};  
 GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};  
 GLfloat mat_shininess[] = {50.0};  
 GLfloat light_position[] = {10.0, 10.0, 10.0, 0.0};  
 GLfloat model_ambient[] = {1.0, 0.5, 0.5, 1.0};  
 void setupMaterials() {  
      glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);  
      glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);  
      glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);  
      glLightfv(GL_LIGHT0, GL_POSITION, light_position);  
      glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient);  
 }  
 void changeColour(GLfloat r, GLfloat g, GLfloat b, GLfloat A) {  
      model_ambient[0] = r;  
      model_ambient[1] = g;  
      model_ambient[2] = b;  
      model_ambient[3] = A;  
      glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient);  
 }  
 void init(void) {  
      glClearColor(0.0, 0.0, 0.0, 1.0);  
      setupMaterials();  
      glEnable(GL_LIGHTING);  
      glEnable(GL_LIGHT0);  
      glEnable(GL_DEPTH_TEST);  
      glEnable(GL_CULL_FACE);  
      glFrontFace(GL_CCW);  
      glShadeModel(GL_SMOOTH);  
 }  
 void reshape(int w, int h) {  
      GLfloat fAspect;  
      if(h==0) h=1;  
      glViewport(0,0,w,h);  
      fAspect = (GLfloat)w / (GLfloat)h;  
      glMatrixMode(GL_PROJECTION);  
      glLoadIdentity();  
      gluPerspective(60, fAspect, 0.5, 100.0);  
      glTranslatef(0,0,-1);  
      glMatrixMode(GL_MODELVIEW);  
      glLoadIdentity();  
 }  
 void display(void) {  
      int slices = 30;  
      int stacks = 30;  
      float radius = 0.2;  
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  
   glPushMatrix();  
     changeColour(0.0, 0.0, 1.0, 1.0);  
     glTranslatef(0.0, 0.0, 0.1);  
     glutSolidSphere(radius, slices, stacks);  
   glPopMatrix();  
      glFlush();  
   glutSwapBuffers();  
 }  
 void keyboard(unsigned char key, int x, int y) {  
      switch (key) {  
           case 27:  
                exit(0); // Exit the application if 'Esc' key is pressed  
      }  
 }  
 void animate() {  
      glutPostRedisplay();  
 }  
 int main(int argc, char * argv[]) {  
   glutInit(&argc, argv);  
   glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);  
   glutInitWindowSize (800, 600);  
   glutCreateWindow (argv[0]);  init();  
   glutKeyboardFunc (keyboard);  
   glutDisplayFunc (display);  
   glutReshapeFunc (reshape);  
   glutIdleFunc(animate);  
   glutMainLoop();  
   return 0;  
 }  

7.       Create empty project with new compiler as its current compiler.
8.       Now extract  deannicholls_glut_tutorial_main.zip and paste main.cpp inside the location of CB project.
9.       Now, confirm again by setting compiler from Build Options.
10.   After that, rebuild => build => run.

Sunday, 6 September 2015

Running Graphics Program of C on Windows 7 64 bits In CodeBlocks IDE 13.12


Today we are going to see how to run C graphics program on 64 bits Windows 7 using CodeBlocks 13.12. 

It will require only 12 steps. Follow with caution and you are done.

These are the instructions I have tried for 64 bits windows 7:
  1. Download zip file from this repository: https://github.com/stahta01/windows-games
    This one is having latest files of Graphics Libraries.

  2. Now either you are using external GCC compiler or internal GCC compiler doesn’t matter, just follow the universal procedure recommended for this.
  3. Copy the following files 
From(windows-games-master\WinBGIm)
To (MinGW)
include folder  => graphics.h
Include
src folder => Winbgim.h
Include
lib folder => libbgi.a
Lib

           If any of the files are already at destination, please overwrite as these are going to work for 64
           bits versions.

4.  Now, go to Setting => Compile and Debugger => Selected Compiler => GNU GCC Compiler.
           -  I will recommend to make copy of existing compiler and rename it. So that any kind of mess will not
           disturb other type of program execution. 



     5.    Now in Linker settings => Add => File => C:\MinGW32\lib\libbgi.a
      
     6.    Go to right part, other settings paste these parameters:
           -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
       
     7. Now half of the configuration has been done.

          
     8. Create simple empty project using codeblocks and add file with extension .cpp.
  
     9.     Most IMPORTANT part is now:

      
Now, right click on Project Name => Build Options => selected Compiler.

       You have to select the compiler which you have configured.
       Otherwise you will get:
       i. Memory access violation error "Process-returned-1073741819-0xc0000005" 
               or 
      ii. Segmentation fault.
  
     After successfully completing above steps, try the following program with Hello.cpp   
  
     This is my sample program to print name of screen:

 #include<graphics.h>  
 #include<conio.h>  
 main()  
 {  
   int gd = DETECT,gm,left=100,top=100,right=200,bottom=200,x= 300,y=150,radius=50;  
   initgraph(&gd, &gm, "C:\\TC\\BGI");  
   rectangle(left, top, right, bottom);  
   circle(x, y, radius);  
   bar(left + 300, top, right + 300, bottom);  
   line(left - 10, top + 150, left + 410, top + 150);  
   ellipse(x, y + 200, 0, 360, 100, 50);  
   outtextxy(left + 100, top + 325, "My First C Graphics Program");  
   getch();  
   closegraph();  
   return 0;  
 }  


    10.  Now, rebuild the project.

    11.  After that, compile and run.

    12.  You will definitely see such message printed,



Thursday, 25 June 2015

Wireless Connectivity in CentOS 6.x

Hi,

Banging your head on wall for not able to connect with Free wifi in campus or coffee shop?

Its time to end it.

Just two commands and you are done.


For CentOS 6/RedHat 6:

# rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm

Then install Ralink NIC adapter:

# yum install kmod-r8168

It will take sometime to show its action (even for 8GB RAM & 1TB system ;)

After some installation instructions, I hope you will see wireless connection in Linux !!

#CentOS6 #CentOS7 #Redhat #Ralink #Wireless #Wifi