Friday 21 December 2018

Java Tutorial : Text File As Database Table | Episode 3 | Update Data Fr...



Code :-
import java.io.*;
import java.util.*;
class update_file
{
    public static void main(String ar[])
    {
        update_file uf=new update_file();
        uf.update();       
    }
    public void update()
    {
        /////////phase 1
        System.out.println("Enter the ID of employee that you want to update.....");
        Scanner sc=new Scanner(System.in);
        int id_to_change=sc.nextInt();
        String to_change_column_names[]={"first name:","last name:","Salary:","Location:"};
        int yes_no[]=new int[4];
        String to_update[]=new String[4];

        System.out.println("Select the columns that you want to update (0: No/1: Yes)");
        for(int i=0;i<4;i++)
        {
            System.out.println(to_change_column_names[i]+"");
            int temp=sc.nextInt();
            yes_no[i]=temp;
        }

        ////////////////phase2
        System.out.println("_______________________________________________________");
        System.out.println("Add new values to the columns");
        for(int i=0;i<4;i++)
        {
            System.out.println(to_change_column_names[i]+"");
            if(yes_no[i]==1)
            {
                Scanner sc1=new Scanner(System.in);
                String temp_val=sc1.nextLine();
                to_update[i]=temp_val;   
                System.out.println();
            }
            else
            {
                System.out.println("Cannot be changed");
            }
        }

        //////////////////phase 3
        StringBuffer sb=new StringBuffer();
        try
        {
            BufferedReader br=new BufferedReader(new FileReader("Database.txt"));
            String s="";
            while((s=br.readLine())!=null)
            {
                String data[]=new String[6];
                data=s.split(",");
                if(id_to_change==Integer.parseInt(data[0]))
                {
                    String row=data[0]+",";
                    for(int i=0;i<4;i++)
                    {
                        if(yes_no[i]==1)
                        {
                            row=row+to_update[i]+",";
                        }
                        else
                        {
                            row=row+data[i+1]+",";
                        }

                    }
                    sb.append(row);
                    sb.append("\n");
                }
                else
                {
                    sb.append(s);
                    sb.append("\n");
                }
            }
            //System.out.println(sb.toString());

        ////////////////// phase 4
        File f=new File("Database.txt");
        PrintWriter pw=new PrintWriter(new FileOutputStream(f,false));
        pw.print(sb.toString());
        pw.close();
        }
        catch(Exception e)
        {

        }
    }
}

Hello guys, this is unpossible pog and and on youtube, this guy requested
me to make a code in java to perform update operation.
If
you want to skip intro, then jump to this time.
For
lot of you guys who don’t know, i made tutorials on how to use text
file as database using java.

I only made videos of inserting and
displaying data but not on how to update data.
When
I was trying to write a program however, I found out that it is vary
complex.
Let
me explain you.
SO
this is my table structure with 5 columns.
And
here as you can see, that there can be multiple “SET” keywords
that can be applied to multiple columns, and same goes to “WHERE”
clouse, where there can be multiple condition and other complications
like “AND-OR” and “IN” and “EQUALS TO”.
Now
I shall explain the simplest one, in that there is only unique ID in
condition, but you can select multiple columns.
I
solved the problem of selecting which columns will be updated by
flagging is either as 0 or 1.
If
u didn’t understand it, dont worry, you will understand when I
start writing a code.



Now,
in previous tutorials, we wrote a code on now to insert and display
data from text file. So let me just run it.
As
you can see, the data is entered in text file.



Because
the udate code is huge, I am going to create a new .java file, save
it as the same location where the text file is.
Make
a class and main function.
Now,
there are 4 phases,
In
first phase, we will get which ID will be in where condition and
create some arrays.
Here,
we are not updating ID, because in live projects, we don’t often do
that.
The
Array yes_no are made to give the flag to columns that is O or 1.
In
the for loop, we are asking users to select columns to be updated
Lets
check it, it should be an array.



First,we
will enter ID, then we will type either 0 or 1.
So
far so good.



Now
in second phase,we shall ask user to enter the value of columns which
user want to update.
We
shall store that in “to_change_clumn_names” array.
If
the flag is 1, then , we shall create scanner variable, and insert
values.
In
else, we shall tell user that you can not change this value.



As
you can see, the program is denying user because of the 0 flag he
gave.



In
phase three, we will modify data but won’t upload it in text
file. It will be in phase 4.
But
now in phase 3, we shall get data from text file,now from here, it
gets more complex.
We
shall need, a stringbuffer variable the store the modified value.
In
abstract word, in phase it, we go to each row, and find out whether
it’s ID matches with ID that we enter, if no, then we skip the
change, but if YES, then we find which columns should be updated and
swap their values.
We
append those value in StringBuffer.



Now
lets run it,
Actually
I forgeot to append, when flag is 1.



Now
in phase 3, we are writing the data in text file, it is vary easy.
Make
sure to close the printwriter, otherwise the file won’t be updated.
Lets
run the program and check in text file, whether or not the data has
been modified.
We
shall the value of employee where his ID is 1.



To
confirm it again, we shall the information of ID equals 2.



Thnak
you for watching, Dont forget to like share and subscribe.




Thursday 29 November 2018

The Unplanned Trip To Shirdi | No Hotel And Travel Booking | #Fun









One day, my colleagues (friends) asked me to come with them to visit Shirdi and refresh the mind from the work load. These guys are my first 20's friends, so I said "YES, Sure!" immediately. On the night of journey, I joined the rest of the crew, we were total 9 guys and getting a new experience to travel without booking any hotels and most traveling sources. I think it is an important experience to learn how to manage money and travel safely. Panicking is not an option. The thing that I learnt is "Help can be given to those who just simply ask for it". So I would like to thank the crew and the people that we meet who gave us helping hands.

Sunday 11 November 2018

JSP Tutorial | Creating MVC Web Application In Java | Servlet | Netbeans...




















Hello
guys, this is unpossible pog and in this video, I shall tell you how
to create MVC framework using jsp and servlet
First
I will show you the live example, blue dart’s old website was
developed using JSP MVC concept. They just forgot to give proper
names to servlet but whatever.
The
main reason to hide web page is to make it safe from hackers by not
leaving file names like .html . Jsp etc
So
lets create a web application in netbeans.
Give
any random name. Click next twice. And click on finish.
Now
lets run the web app first.
Ok,
so lets add my youtube channel name there.
Now
right click on default packages, and add servlet. Give the random
name, click on next and make sure to click on “Add information to
deployment descriptor” which will create web.xml file
automatically.
The
servlet file is open.
Then
go to web pages, then web-inf, and open web.xml.
You
can see the servlet’s name. Now lets create a link go from one
page to another.
Create
jsp page, and give it a any name, in href, give the name of jsp file
that we have created along with it’s extension.






Now
lets refresh project, and when you click you will go to second page
but the problem is that in URL you are reavealing the file name.
So,
go to web.xml and in url pattern, give the any name which will hide
the file name. Copy that name and replace it in href.
Inside
try, You can see that there is un necessory content, so just comment
that, and we shall create reuest dispatcher variable, and add
“second_page.jsp” file in getRequestDispatcher’s first
argument.
Now
we are forwarding, so lets re-run project and now when you click on
link, we went to send page without revealing the second_page.jsp.
But
what happen you u want to send value thrugh url, so for example, go
to youtube and search something, you can see that result is the
servlet, and we send value as thanos in search_query variable.
Go
to index page, and create variable as “search” and give the
value.
Oops,
there should be question mark.
Now
go to servlet, create string variable, and in getParameter, give the
variable name, in our case its “search”.
Now
we set attribute, give any random name in first argument, and in
second argument, add string variable “A”.
Now
go to second_page.jsp file and use jsp syntax to print value of
search using request.getAttribute, paste the name of variable from
servlet to second page, now lets run the project.
Thnak
you for watching, Dont forget to like share and subscribe, and in
next part, I will create working with model that is database, so stay
tuned.



Tuesday 9 October 2018

How To Change Account Picture | Ubuntu 18.04 | GNOME | Login Profile Pic...







You can watch the video, or follow the instruction given below.

Hello guys, this is unpossible pog, in this video, there are steps which can help you to change your account picture in ubuntu 18.04 GNOME Desktop environment. That profile picture mostly seen on your login screen.
Steps
1. Click on right top corner of screen.
2. Click on your account
3. Click on advanced settings
4. Click on picture image
5. Select the image for given list or click on "Select file" to add custom image.

To confirm, login from the account, and select your account to see your profile picture.

Saturday 29 September 2018

Download Free Images (Location : Konkan)






















These are the images that I took from my village. You can download it and use it for free.

Monday 24 September 2018

Javascript Tutorial : Dropdown One Option Tag With Multiple Values





















Code :-



<script type="text/javascript">
    function get_values()
    {
        var a = document.getElementById('multiple_values').value;
        var array=a.split(",");
        var st='';
        for(i=0;i<array.length;i++)
        {
            st=st+" -> "+array[i];
        }
        //alert(array[2]);
        st="Values are "+st;
        document.getElementById('display').innerHTML=st;
    }
</script>

<select onchange="get_values();" id="multiple_values">
    <option value="">
        Select
    </option>
    <option value="586,896,8856">
        Numbers
    </option>
    <option value="Unpossible,pog,youtube">
        Characters
    </option>
</select>
<div id="display">
   
</div>

 _______________________________________________

More info














Hello
guys, this is unpossible pog and in this tutorial I shall show you
simplest way to apply multiple values on sslect tag that is in
dropdown option.
First
lets try sending single value, in script tag, create get_value
function, and in select tag, on change event, call that function.
The
function is called.
So
lets get the single value.
Give
an id to select tag, and call that id in getElementById function.
Store
that in variable a.
Now
the simplest way is to compress multiple values into one single value
and divide them using special character, in my case it is “comma”.
And
in javascript function, split them. Give comma in split function.
Array[0]
means the first variable that is in number it is 586, and in
characters it is “unpossible”.
If
you want to display all the values, then follow the steps that I am
showing.
Create
div and give specific id to it.
Thats
it guys, don’t forget to like share and subscribe.
And
I see you in the next video.








Friday 21 September 2018

Journey To Village Episode 2 : Behind The Scene Of Short Film And The Crew





The main reason to visit my village is because the village is the shooting location of short film. Even thought films are long or short, there is a crew working behind to setup movie's props like lights, putting something or taking it out from the screen, assisting directors/camera man/actors. Crew increases the speed of shooting depending upon the manpower and experienced members.

Monday 23 July 2018

Add States in Dropdown When Nation Is Selected | Add Values In Dropdown box Using Javascript | HTML tutorial

Code :-
<html>
    <head>
        <script>
            function random_function()
            {
                var a=document.getElementById("input").value;
                if(a==="INDIA")
                {
                    var arr=["Maharashtra","Delhi"];
                }
                else if(a==="USA")
                {
                    var arr=["Washington","Texas","New York"];
                }
             
                var string="";
             
                for(i=0;i<arr.length;i++)
                {
                    string=string+"<option value="+arr[i]+">"+arr[i]+"</option>";
                }
                document.getElementById("output").innerHTML=string;
            }
        </script>
    </head>
    <body>
        <select id="input" onchange="random_function()">
            <option>select option</option>
            <option>INDIA</option>
            <option>USA</option>
        </select>
        <div>
           <select id="output" onchange="random_function1()">
        </div>
    </body>
</html>
Dialogs :-

Hey guys, this is unpossible pog.
Today’s tutorial will be how to add values in dropdown when we select other dropdown.in this case we are adding states or cities in dropdown when you select contries.
First create a normal dorpdown, give it an ID as “input”.
I shall add nations in it.
Let’s check it.
Now add script tag, and create a function with any random name.
In select tag, onchange event, call the function name.
Now, the function is called correctly.
But we don’t need alert, so I shall remove it.
Lets create a variable “a” to get nation name from dropdown.
Then create division and give it an ID as “output”.
Lets print the nation’s name.
So far so good.
Now we need if else statements.
Give equals to symbol “three times”.
Add states in array.
We need a string and for loop.
We are appending the string.
Change “a” to “string”.
Let’s check if all states are coming or not.
Before and after array, add option tag in double quote.
Add name if you want to send it through form.
Add select tag inside div just to make an illusion.
So thats it guys, if you want code, then the link is in the description.
don’t forget to Like,share and subscribe. Thank you for watching, bye.





Friday 15 June 2018

Java Tutorial : Auto Completing JTextField | Auto Suggesting Textbox | Java Swing

Java Tutorial : Auto Completing JTextField | Auto Suggesting Textbox | Java Swing
Code :-
Watch the video above to understand how to autocomplete jtextfield
Code of set 
Set<String> s=new TreeSet<String>();
        s.add("unpossible");
        s.add("pog");
         s.add("steve rogers");

Copy below code in key_released event of jtextfield.

if(evt.getKeyCode()==KeyEvent.VK_BACK_SPACE||evt.getKeyCode()==KeyEvent.VK_DELETE)
        {
           
        }
        else
        {   
            String to_check=jTextField1.getText();
            int to_check_len=to_check.length();
            for(String data:s)
            {
                String check_from_data="";
                for(int i=0;i<to_check_len;i++)
                {
                    if(to_check_len<=data.length())
                    {
                        check_from_data = check_from_data+data.charAt(i);
                    }
                }
                //System.out.print(check_from_data);
                if(check_from_data.equals(to_check))
                {
                    //System.out.print("Found");
                    jTextField1.setText(data);
                    jTextField1.setSelectionStart(to_check_len);
                    jTextField1.setSelectionEnd(data.length());
                    break;
                }
            }
        }

Monday 11 June 2018

Linux Remote Desktop Connection In Home LAN | Ubuntu And Linux Mint | Re...














Hey
guys, this is unpossible pog, today I shall show you how to configure
remote desktop connection using two linux operating systems on home
LAN.
In
this examples, I shall be using ubuntu and linux mint. Both are
connected to same router. Ubuntu is connected by LAN wire and mint
is connected by wifi.
First
you need to install remmina remote desktop client software.
So
open the terminal and type this command "sudo apt-get install remmina" on both ubuntu and linux
mint.
As
you can see, I already installed this.
Now
I am using ubuntu as srever and linux mint as client.
So
first go to client that is linux mint and search for desktop sharing.
Now
check allow other user to view your desktop.
Now
open remmina software on both computers.
Now
go to mint and open terminal, and type command ip addr show.
Now
the inet is ur ip address.
Type
that ip address there and select VNC. And click on connect.
Allow
it from linux mint.
And
now linux mint is connected to ubuntu.
Whatever
changes I am doing, they are occurring on both desktop.
So
thats is guys.
don’t
forget to Like,share and subscribe. Thank you for watching, bye.















JAVA Swing Auto-Suggesting Textfield Tutorial COMING SOON!

Monday 30 April 2018

Codeigniter Database Tutorial | Database Connection | Display Data On Bu...







I created a video about how to connect with database and fetch data from table using MVC (Model, view and controller) of Codeigniter. It's a bit complicated process so before you see how to connect, you must master in normal php coding.
Model :- A place where you perform database operations(CRUD).

View :- A place where you interact with user.(GUI/website).

Controller :- A place where you connect model and view and also perform some validation if you want to.

Wednesday 18 April 2018

Thunderbird Mail Software

Some Opinions on Thunderbird mail Software

I never used any of the email-sending softwares to send any e-mails. I prefer to send email on web-browsers. When I installed ubuntu, they gave me Thunderbird  preinstalled. I think it is a useful alternative for MS-outlook. I am thinking about using it to send resumes to companies instead of copying their email addresses and then paste it in email box. ๐Ÿ˜‰๐Ÿ˜…

Sunday 15 April 2018

Java Script Tutorial | Change Images On Button Click Dynamically Without Refreshing Page

code for images appearing dynamically without refreshing page:-

<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
        <script>
            function change1()
            {
                document.getElementById("changing_image").innerHTML='<img src=Desert.jpg>';
            }
           
            function change2()
            {
                document.getElementById("changing_image").innerHTML='<img src=Lighthouse.jpg>';
            }
           
            function change3()
            {
                document.getElementById("changing_image").innerHTML='<img src=Peng%20uins.jpg>';
            }
        </script>
    </head>
    <body>
        <a onclick="change1()"><button>Image 1</button></a>
        <a onclick="change2()"><button>Image 2</button></a>
        <a onclick="change3()"><button>Image 3</button></a>
        <div id="changing_image"></div>
    </body>
</html>

Sunday 4 March 2018

PHP Code | Add Parent On Array | Parent Child JSON Array Using PHP


code in php to add parent Element on array
<?php
$array1=array();
for($i=1;$i<=10;$i++)
{
    array_push($array1,['id'=>$i]);
}
$array2->numbers=$array1;
echo $final_output= json_encode($array2);
?>

Tuesday 13 February 2018

Include Other Web Pages On Button Click | Dynamic Page Using JavaScript And HTML | WAMP


Source Code:- Home_Page.php 


<center><h1 style="background-color: darkgreen"><font color="yellow">Dynamic Page</font></h1></center>
<table border="1" height="100%" width="100%">
    <tr>
        <th width="20%" onclick="document.getElementById('dynamic').innerHTML='<iframe src=Pagignation.php width=100% height=100%></iframe>';     ">
         First Page  
        </th>
        <th rowspan="4" id="dynamic">
        
        </th>
    </tr>
    <tr height="85%">
        <th>
           
        </th>
    </tr>
</table>

Sunday 11 February 2018

Sunday 4 February 2018

PHP Tutorial | Easiest Way To Add Pagination On Web Site | Using php, phpmyadmin, Javascript

Watch video and you follow my steps to perform pegination on web site..

Source code :-

<html>
    <head>
        
       
    </head>
<body>
    <?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "tutorial";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

$sql = "SELECT * FROM employees";
$result = $conn->query($sql);
while($row = $result->fetch_assoc())
        {
            echo "id: " . $row["id"]. " - Name: " . $row["name"]."<br/>";
        }
?>
        <button onclick="getElementById('page').innerHTML='Dynamic Display'">Click here</button>
      
    <div id="page"></div>
</body>

Friday 2 February 2018

PHP Tutorial : Find Upcoming Date From Database | WAMP | LAMP | phpmyadmin



Source Code :- Next_day.php
<?php
//$name=$_POST["name"];
$con=new mysqli("localhost","root","","test");
$result=$con->query("select * from dates order by date ASC");
$year=date("Y");
while($row = $result->fetch_assoc()) {
       // echo "Date:" . $row["date"]." Day :". $row["name"]."<br/>";
        if($year==  substr($row['date'], 0, 4))
        {
           
            if((int)substr($row['date'], 5, 6)==(int)date("m"))
            {
                if((int)substr($row['date'], 8, 9)>(int)date("d"))
                {
                    echo "Upcoming Date:" . $row["date"]." <br/>Upcoming Day :". $row["name"]."";
                    break;
                }
            }
            else if((int)substr($row['date'], 5, 6)>(int)date("m"))
            {
                echo "Upcoming Date:" . $row["date"]." <br/>Upcoming Day :". $row["name"]."";
                break;
            }
        }
    }
?>

Sunday 28 January 2018

PHP Tutorial : Include Page On Button Click Without Refreshing Main Page | Dynamic Page Loading

Remember that this technique has 1 drawback, watch the video above to understand it. Comment down if you have any questions.
Source Code :-
dynamic.php
<head>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){ $("b").click(function()
    {
    document.getElementById("include").innerHTML = "<?php echo include('Second.php');
?> "; });
    $(document).on("click", "a.remove" , function()
    { $(this).parent().remove(); }); });
</script>
</head>
<body>
<b><input type='submit' value='Add second page'></b>
<div id='include'></div>
</body>

Second.php
<?php
echo 'This is second page';
?>

Using CodeIgniter For The First Time

Hello visitors, this is unpossible POG. And Oh My God! I am using CodeIgniter for the first time. I am using Linux OS (Ubuntu 17.10) and Netbeans IDE for assisting me in coding. It is challenging to work on MVC because I develop web page in normal PHP code. I may not create any tutorials on it because I am newbie. Although Java's OOP concept is helping to know how controller actually works. I hope it will help me to reach next level.

Friday 26 January 2018

How To Set Today's Date By Default In Calendar | WAMP | PHP Tutorial



Source code :- tutorial.php
<?php
date_default_timezone_set("Asia/Kolkata");
?>
<form>
<input type="date" value="<?php     echo date('Y-m-d');          ?>">
<input type="submit" value="Send">
</form>

Monday 22 January 2018

WAMP Tutorial : Restrict Direct URL Access And Redirect To Login Page [Download Code From Links]

Source code :-  Copy paste those codes, and give the file name same as given below. Enjoy.
login.php

<form action="check.php" method="post">
Enter username<input type="text" name="name">
Enter username<input type="password" name="pass">
<input type="submit" value="login">
</form>

check.php


<?php
session_start();
$uname=$_POST['name'];
$pass=$_POST['pass'];
if($uname=='unpossible' && $pass=='pog')
{
$_SESSION['logged_in']='1';
include('sensitive_data.php');
}
else
{
echo "get out from here";
}
?>

sensitive_data.php

<?php
if(isset($_SESSION['logged_in']))
{
?>
this page has sensitive data. very important data.

<?php
}
else
{
include('login.php');
}

?>

Sunday 21 January 2018

Wordpress Tutorial : Metro Post Layout Free Version | Coding Is Needed




Hey guys, I am working in IT company as a website developer and one client asked to create a blog site. He wanted home page blogs in metro layout (Like windows 8,8.1,10 start menu). I saw one easiest way to make metro post layout but for that we have to pay $24. So I thought I can create a manual code for post layout. With this, we don't have to pay a one bit. In the video below, I showed to you can create metro post layout in wordpress. Enjoy. ๐Ÿ˜‰ 


LINUX Wordpress Error Solved : unable to create directory wp-content/upl...