Sunday 8 November 2020

Mysql | Order By Comparing Multiple Columns & Ignore Specific Value While Sorting | Greatest & Least



> SELECT *,greatest(maturity,death) as insurance_date FROM `insurance` order by insurance_date DESC

> SELECT *,least(maturity,if(death='0000-00-00 00:00:00',maturity,death)) as insurance_date FROM `insurance` order by insurance_date DESC


In MYSQL, GREATEST and LEAST are the functions which compares columns columns rather than rows. Best example is an Insurance company’s data where admins want to figure out the day a customer gets his/her money by comparing which date comes first, a maturity date or death date.


Subscribe my Channel:-

http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-

https://www.facebook.com/UnpossibleNS

Twitter Account:-

https://twitter.com/UnpossiblePOG

Blog :-

https://unpossiblepog.blogspot.in/

------------------------------------------------

Hey guys, in this video I am going to sort the table by comparing multiple columns.

For example, I have an insurance table, and two columns, maturity and death have the date-time as data-type.

First we shall sort it by the maximum date among maturity and death, so we shall use the GREATEST function and add columns which will be compared.

We give that value of function as “insurance_date” and then use the  ORDER BY clause.

Now as you can see, it gives the output based on which date is maximum and sort accordingly.

However in insurance, the lowest date matters because company has to give money based on which date occurs first.

So for that we are going to use LEAST function.

But the problem is, if a person is not died then, of course the date field will be empty so the output is incorrect.

To fix that, we have to overwrite the the death date. We are going to use the IF condition inside LEAST function, and if death date is zero, we overwrite it with a maturity date. Also, Maturity Date shouldn’t be empty in any case.

And now we got the output we wanted.

Query link is given in the description.

Don’t forget to like, share and subscribe.Thanks for watching.

Thursday 15 October 2020

Use Hash Value As Different Page For Navigation Like Angular JS | Hashtag | Javascript | Jquery | Ajax




You can download code from: https://unpossiblepog.com/codes/JAVASCRIPT+AJAX-JQUERY/Use-Hash-Value-As-Different-Page-For-Navigation-Like-Angular-JS-Using-Javascript-Jquery-And-Ajax

Code :-

product.php

------------------------------------------

<!DOCTYPE html>

<html lang="en">

<head>

  <title>Bootstrap Example</title>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

</head>

<body>

<script type="text/javascript">

  loc = (window.location).toString();

  res = loc.split("#");

</script>

<div class="container">

  <h2>&nbsp;</h2>



  <div class="row">

    <center>

    <div class="col-md-4">

    

      <a onclick="showDataAjax('#Linux');history.pushState({},'','#Linux');">

        <button type="button" class="btn btn-info btn-lg">Linux</button>  

      </a>

    </div>



    <div class="col-md-4">

      <a onclick="showDataAjax('#Microsoft');history.pushState({},'','#Microsoft');">

        <button type="button" class="btn btn-info btn-lg">Microsoft</button>  

      </a>

    </div>



    <div class="col-md-4">

      <a onclick="showDataAjax('#Apple');history.pushState({},'','#Apple');">

        <button type="button" class="btn btn-info btn-lg">Apple</button>  

      </a>

    </div>

    <center>

  </div>



  <div class="row">

    <div class="col-md-12" id="show-data" style="background-color: #fff68d;margin-top: 15px;height: 100px;">

    

    </div>

  </div>



  <div class="row">

    <center>

    <div class="col-md-12">

      <a  class="btn btn-info btn-lg" style="margin-top: 15px;"

      onclick="history.pushState({},'',res[0]);">Refresh</a>

    </div>

    </center>

  </div>



</div>



<script type="text/javascript">

  function showDataAjax(company)

  {

    $.ajax({

      url: "read_data.php",

      method: "POST",

      data:{company:company},

      beforeSend : function()

      {

      },

      success: function(ajax_data)

      {

        $("#show-data").html(ajax_data);

      }

    });

  }

 

  window.onpopstate = function(event){

    var hash = location.hash;

    showDataAjax(hash);

  };



  function runHash()

  {

    var hash = location.hash;

    if(hash!=="")

    {

      showDataAjax(hash);

    }

  }

  runHash();

</script>



</body>

</html>



------------------------------------------

read_data.php



<center>

<h1>

<?php

echo str_replace(array("#","%20"), array(""," "), $_POST['company']);

?>   

</h1>

</center>





------------------------------------------



This video is about how to dynamically navigate on browser using hashtag and display data based on hash values with the help of ajax jquery & javascript.

For example, when I click on buttons, I am displaying the data using AJAX, but at the same time I am also manipulating the url.

Not only that, when I click on back and forth buttons, the data changes respectively.
Also if I directly open with hash value, it shows the data.
You can also remove the hash value by clicking on refresh button.


Lets start building code from the scratch.


Here is the page design, I using PHP language but you can use any backend language.

I have including a header file, which has JQUERY and boostrap links.


In our main page, I added onclick event and “showDataAjax” function on each button.
I added them statically just to avoid backend language,
Notice that I added hashtag before each value which is important.

And here is the ajax code which shows data in ID.

You can remove hashtag from post data using your backend language.

Lets add history.pushState function with 3 arguments.

1st will be empty array, 2nd will be empty string and the will be the hash value.
Copy paste them and add values respectively.


Notice that your URL hash is also changing.
Now next problem is when I click on back button, it doesn’t change the ajax value.

So for that, add a javascript code.
we shall get the hashvalue and call the function.
Now lets check.
Now, next challenge is what do when when user applies URL with hashvalue.
For that we shall add similar code.

Lets check the direct URL.
As you can see, its working, now to remove hash value, create the script tag at the top of page.

You can also add in common header file but I don’t want to confuse viewers, so I am writing on same page.

On click of refresh page, paste that code, and use array’s first element.
As you can see, this button wipes out the hash value.

Create a function.

Run that function after it’s declaration.


Don’t forget to like, share and subscribe.

Thanks for watching.

Monday 28 September 2020

JQUERY Tutorial | Hide Collapsible Navbar When Clicked Outside It | Bootstrap




You can now download a code from : 
https://unpossiblepog.com/codes/javascript+jquery+bootstrap/Hide-Collapsible-Navbar-When-Clicked-Outside


In this video, I shall create a code in JQUERY to hide bootstrap’s responsive navbar when user clicks outside that navbar.


I have created one bootstrap page.
When I convert User Interface from desktop to mobile version, and click on hamburger icon, the menu appears and same button is used for hiding it.
Lets create a script tag.
Write a function which shall run as soon as the whole page load.
And first we are going to check if jquery is working or not.
Lets refresh. When I click, it shows the alert message.
Now comment it just for now.
Now we have to observe which one is the main class which shows the navbar,
As there different types of navbar for each version of bootstrap,  only the classes names will differ from me but overall the process will be same.
When I toggle, this part is the topmost part which is changing it’s class.
So have to copy the classes of both toggle button and navbar division.
Now we have to find out the class name where user clicks.
As there are different JQUERY versions, one of them is applicable for your version.
For me the second one works so I am going to comment the first one.
Now we are getting the class name of elements where we clicked.
We shall use the IF-ELSE statements and check if the class is same as navbar’s class or not.
However there are some classes which are inside the navbar, So to find out if we click inside navbar too, we shall use this code in alert box.
Now if we click outside navabar, it shall give 0, but if we click inside navbar it shall give 1.
So we shall also use it inside our IF-ELSE statement.
We shall put if statement empty and use the ELSE part.
Here, if we check, when the navbar is expanded, there is an “IN” class present with it.
So in code, we have to find out if that NAVBAR class have “IN” class with it.
If yes, then we shall auto-click the toggle button.
Lets refresh.
It is not hiding when I click inside the navbar, but is hiding when I click outside.
Don’t forget to like, share and subscribe.Thanks for watching.

Sunday 13 September 2020

JQUERY Tutorial | Add Unique Count On Repeated HTML Elements Without Bac...



Automatically add count in repeated elements using only JQUERY.

Boostrap code with JQUERY link:-
https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_default&stacked=h

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

In this video, I am going to show how to add count in incrementing order in elements.
I created an empty html page as you can see.
I am lazy so I am going to copy some html code from w3schools. Link in the description.
In that code, they manually added 1,2,3. Which might take a lot of time if you add one by one.
Let me just remove Order and add LIST in h3 tag.

Now, they already provided one jquery link which is necessary.
Now create a script tag, make sure that it is below those repeated elements.
Create a random function, and call it.

Now, as soon as page loads, it will show an alert message.
After that, remove alert.
If you observe the pattern, H3 tag comes after the class called “col-sm-4”.

So, we shall now call then one by one using jquery.
We have to append the number, so we shall need an integer and increase it by 1 each time.

Don’t forget to like, share and subscribe.
Thanks for watching.

Sunday 6 September 2020

Redirect Outside IFRAME Using Anchor Href & Form Submit Action | Javascr...




This video is about redirecting html page outside IFRAME.
There are usually two types of redirects.
1st is an anchor tag with href, and 2nd is form tag with action.
If we click on any link which is inside iframe, then it redirects only within that iframe section, also browser’s URL doesn’t change.
In given code, iframe page is added called “internal_page.html” which has anchor tag and form.
The anchor link redirects to “welcome.html” page.
So, to redirect outside iframe, use the “base” tag with target as “_parent”.
Now, if we refresh and and click on it, the browser’s URL is changed to the page we wanted.

However, the form redirect is the tricky one.
Because, we have base tag in initial page, the basic action tag itself redirects on browser URL which we don’t want.
So, just remove base tag from internal page.
The action page redirects to PHP file but you can use any language you want because logic will be same.

If name is admin, then create a base tag in if statement’s bracket, create an anchor tab, give it an ID.
Hide it using CSS.
Now in script tag, create a javascript to auto-click that anchor tag.

Let’s refresh.
If we type something else, it redirects within an IFRAME, but if we type admin, it shall redirect itself to welcome page.

Don’t forget to like, share and subscribe.
Thanks for watching.


Tuesday 1 September 2020

Drum Beginner - Unpossible POG Musics | Free HIP-HOP Music | LMMS Experi...



This is the second time I am creating my own music using LMMS Software.
It is a bit awkward to upload music on the internet. I hope it is not
cringey. Enjoy.

Thursday 20 August 2020

Connecting Java Gradle With Google Drive | Part 1 | Groovy



You can download library from:- https://unpossiblepog.com/research-and-development/GRADLE+JAVA/Google-Gradle-API-In-Java-For-Google-Drive-And-Google-Calendar

Create a connection between java and google drive using gradle.

Quickstart link:-
https://developers.google.com/drive/api/v3/quickstart/java

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
This video is about creating a connection between java and your google drive through gradle.
In this part, we shall display files list in command prompt.
Linux OS is mostly recommended.
Java version 1.8 or greater & also gradle version 2.3 or greater are required.
You will also need google account with google drive enabled.
Open the browser and search “java google drive quickstart”.
Go inside this link.
Check versions in terminal or command prompt before proceeding forward.
Click on “Enable the Drive API” button.
Download configuration.
Create a folder.
Open it in terminal.
Paste the first command.
Select 1 for groovy and for second question, hit enter without typing anything.
It will create basic files & folders for gradle.
Second command will also create 2 more folders.
Now, copy that credentials.json file into src -> main -> resources folder.
Rename it if the file name is not credentials.json.
Go back and open build.gradle file in text-editor.
Paste the gradle code, save it and close it.
Create a java file with same name as they told at location src  -> main -> java.
Open java file in editor. Paste the code.
Remove _READONLY.
SetPageSize decides how many results do you want to be displayed.
I shall type 4.
Now open the command prompt and type “gradle run” and hit enter.
It will open link in browser.
Click on “allow".

Close the tab.
Now if you check terminal, you will see the list of files.
Lets try again, now it will not open any link on browser and will display results directly.
Required links are given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 


Monday 17 August 2020

Root Cause & Solution Of The UnsupportedClassVersionError | Linux Only |...




Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: JavaProgram has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Commands:-
update-alternatives --config java
update-alternatives --config javac

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
Now we shall find out the root cause & solution of the UnsupportedClassVersionError which occurs while running java program for LINUX users only.
This thing occurs when we successfully compiles the code using javac command but throws an error when we run the program.
Lets create a program.
I am opening the terminal where our java file is present.
Now, there is nothing wrong with syntax, compiling is successful but this error is thrown.
The main reason is that we are using different JVM version for compiling and different JVM for running the code.
Don’t forget to add sudo before commands.
Type your password.
If we check runtime version, the version 8 is set.
Press enter or already set number.
However, if we check compiler version, the 11th version is set.
So to change it, enter the SELECTION number which is in front of it. In my case, its 2.
And now, if we recompile and execute, it shall work fine.
Code is given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 


Sunday 2 August 2020

Google Calendar API Tutorial #3 | Delete Events | Get Event IDs | 2020




Download VENDOR Folder (Only for PHP version 7.2+): https://unpossiblepog.com/research-and-development/php/Vendor-Folder-For-Google-Sheet-Drive-Calendar-With-PHP-Version-7.2-And-Onward

PHP Google Calendar Delete EVENTS.

Google Calendar PHP Connection:-
https://youtu.be/Q-498CAa1xE

Google Update Alert :-
https://youtu.be/5COjnEc4d9E

Delete event Code Link:-
https://developers.google.com/calendar/v3/reference/events/delete

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In this tutorial, we shall delete google event using PHP code.
For that, you must first connect PHP with google calendar which are shown in those tutorials.
Both of those links are given in the description.
Now, if you are able to display or add events, you can continue watching further.
I gave a link in the description for a code for deleting event.
In that function, first argument is calendar ID and second is event id.
To find calendar ID, follow my steps.
You will find calendar ID here, which I am already using in code.
Now, we can get the event ID in two ways.
1, while adding a new event. And 2nd by getting events list from LOOPS.
1st, I shall comment the loop code, and add the event.
Here, use getID function.
Lets run the code.
We do get the ID, but ignore the “slash N”, which I accidentally printed in code.
You can store that ID in database or session or anywhere for later use.
Comment that ADD-EVENT code.
Now we shall just copy that in our code directly.
Now we use that provided code.
And use calendar ID and event ID.
As you can see, the event was added by the code is here.
If we refresh, it will be vanished as you can see.

However what if you don’t have event ID, so for that, enable the DISPLAY EVENT code.
& use that delete function here.
Lets create some events manually.
Notice that the third event is from different calendar which will not be delete as it belongs to different calendar.
Now they are vanished like a magic.
Code link & other required links are given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 

Sunday 26 July 2020

Evil Within Human - Unpossible POG | Free HIP-HOP Music | LMMS Experiment




This is the first time I am creating my own music using LMMS Software.
It is a bit awkward to upload music on the internet. I hope it is not
cringey. Enjoy.

Tuesday 14 July 2020

Quickest & Easiest Way To Sort Date Array In Java




Quickest way to sort date-time array in JAVA.



------------------------------------------------
Code :

package tutorials;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Set;
import java.util.TreeSet;

public class SortDateTime {
    public static void main(String[] args) throws ParseException {
        String dateArray[]={
            "2019-01-02 03:05",
            "2019-01-02 03:05",
            "2019-01-02 03:00",
            "2019-01-02 05:00",
            "2019-01-01 15:00",
            "2018-05-05 00:30",
            "2020-04-03 40:00",
            "2020-02-01 59:00"
        };
        SimpleDateFormat f=new SimpleDateFormat("yyyy-MM-dd HH:mm");
       
        Set<Long> s=new TreeSet<Long>();
       
        for(int i=0;i<dateArray.length;i++)
        {
            s.add(f.parse(dateArray[i]).getTime());
        }
       
        for(Long l:s)
        {
            System.out.println(f.format(l));
        }
       
    }
}

------------------------------------------------
Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In this video, we shall sort date-time array in java in the quickest and easiest way possible.
This technique has one drawback which i shall explain at the ending of this video.
I already created a file and inside it there is a string array which has format of like date-time.
I am recommending you to use netbeans as it provides auto-suggestions.
We are going to need a SimpleDateFormat class.
Import required package.
Then we are using set & treeset with LONG as data-type.
In for loop, we are going to find out the length of array and add each array element in set.
but before that, we are converting date-string  into long number using simpledateformat’s function called getTime().

The SET class already ordered data in ascending order.
Then we are going to use FOR:EACH loop.
and in that, we call each data and again convert long into Date-time format.

As per input and output, 2018 should be at the top.
Also, if date is same but hours and minutes are different, then also those values get sorted.

The only drawback of this technique is that, it skips one element if that same element is already present in array.

Code link & other required links are given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 


Sunday 5 July 2020

JAVA Google Calendar API | Part 2 | Display All Events On Browser Using JSP Framework



You can download library from:- https://unpossiblepog.com/research-and-development/GRADLE+JAVA/Google-Gradle-API-In-Java-For-Google-Drive-And-Google-Calendar

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------


Google Calendar Java Part 1 :-
https://youtu.be/zPsSUEGDfVY

Google Calendar Java Part 1. 5:-
https://youtu.be/0daf87wjLs4

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In part 2 of Google Calendar connection with JAVA, we are going to display events from beginning & display them on web browser using JSP framework.
There are two parts that I have made. Links are given in the description. 1st part is mandatory which shows how to connect java with google calendar and display events in terminal.
The second part, which is actually 1.5, is the tutorial on how to create JSP Project using Gradle.
The reason why it is mentioned as 1.5 and not 2 is because it is a separate topic on its own.

And in this part, we are going to merge whatever we made in 1 & 1.5, which reduces redundant steps and also makes this video short.

Form part 1 & 1.5, those two folders were created.

From 1st, we first get all available events by making small changes in code.
As you can see, no future events are available.

Go to our java file, and just add zero in DateTime constructor and that is it.
Now if you re-execute, you will get result starting from first event.
You can make changes in setMaxResults function value to change maximum count of results.

Now from part 1.5, which has JSP enabled, we shall copy some files and folders from part 1.
So go inside Connection folder, go inside  src-> main, copy JAVA and RESOURCES folder and go to JSP, paste them in src -> main folder.
Now, again go to connection folder and copy tokens folder, and paste it in JSP where the build.gradle file is.

Now the copy-pasting is done, now go to connection folder, and open build.gradle file in text-editor, in my case, the sublime text.

Now go to JSP and also open it’s build.gradle in text editor.

We have to cut-paste the Calendar JAVA file inside ORG folder to access package.

Now we have to copy-paste the build gradle requirements from connection’s gradle to JSP’s gradle.
First, for the plugin, use JSP gralde’s syntax.
Then copy-paste that whole paragraph.

Copy-paste the function.

Copy paste the libraries and commands.

Now we are going to run to make sure that build.gradle is correct or not.
Run that IP address in browser’s URL.
It is working.

Now, open servlet in text editor at where we are going to call calendar class.
Notice that we move this quickstart file inside org folder, open that in text editor.

Because it is inside ORG folder, name the package as ORG.
Also notice that servlet has the package called org.gradle.demo which denotes the servet file is inside which folder.

Now import that org package to access CalendarQuickstart.java file.

In CalendarQuickstart file, rename the function from main to getEvents, you can use any new name and return type as string.
What we are going to do is to convert events into string and return them to display them in Servlet.
Make sure to return that string at the ending of function.
Now call that class inside servlet, and create and instance, in my case CQ.
I forgot to append string here.
Notice that the function throws Exception, so we have to call that function in try-catch block.
Copy the output link and call that function.
Lets go to terminal, close previously executed gradle using CTRL+C, and execute the command again.
Now if we click on hello, we shall see all the events.

Required links are given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 


Sunday 14 June 2020

Gradle JSP Quick Setup Tutorial | JAVA & Groovy Language | Web Application



Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------

Official Gradle JSP Guidelines:-
https://guides.gradle.org/building-java-web-applications/

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In this video, I shall create JSP application using gradle in the quickest way possible.
There are plenty of tutorials available on internet for installing gradle and java, so we shall skip that part.
There is an official document from gradle to setup JSP. That link is given in the description.
There are requirements that you should have.

Configuring basic JSP doesn’t require more than 5 minutes.
And we are using groovy as a build.

First instruction is to create folder structure like this.
Open the file system or my computer, I already created a TUTORIAL folder, go inside it and start to create new folders.

Now come to home folder, which is webdemo, and create a new file “build.gradle”.

Click on GROOVY tab if kotlin is selected by default.

Next, open webdemo folder in terminal or command prompt.

Even though the gradle version is greater than 4.10, don’t use that wrapper.

type the same command as they provided.

It will create some files and folders inside webdemo.

Now, create more folder as they told you, and create HelloServlet.java file inside that folder.

There are the number which indicates what is the purpose of that code.

Now come back to webapp folder and create two new files, index.html and response.jsp.

Copy paste the code in index.html.

copy paste the code in response.jsp.

Now, copy this id and paste it in plug in.

After that, go to terminal and type the command they provided.

It will provide a URL. Copy that and paste it in browser.

If you click on hello, the GET method is called.

Force refresh it.

To access JSP, type name and click on button.

So, that is it. The core JSP is ready.

Required links are given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 


Monday 8 June 2020

Java Google Calendar API | Linux Terminal & Gradle Groovy | Display Events | Fix redirect_uri_mismatch



You can download library from:- https://unpossiblepog.com/research-and-development/GRADLE+JAVA/Google-Gradle-API-In-Java-For-Google-Drive-And-Google-Calendar

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------

Official Google Developer page for google calendar JAVA API:-
https://developers.google.com/calendar/quickstart/java

Google Console  page:-
https://console.cloud.google.com/

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In this video, I shall make a connection between Google calendar and JAVA using gradle and display events in terminal or Command prompt.

Following operation requires Linux as it provides more flexibility for performing tasks.

Output can later be used in any framework like Spring, JSP, hibernate etc.

Lets go to google and search “google calendar quickstart java” go to developers.google.com link.

Requirements :
1. Google account with google calendar enabled.
2. Linux OS (debian family). I am using LUBUNTU. install linux in vmware or virtualbox if you don’t have LINUX as BOOT OS.
3. JAVA JDK version 1.8 or grater.
4. Then, gradle version greater than or equals to 2.3.



For people who doesn’t know what is gradle, in simple words, it is a build-tool which has 2 types, Groovy and Kotlin. And both of them can use any language Syntax for its script.
Kotlin is mostly used for android development and has file extension of .gradle.kts but groovy is mostly is used for webserver and with extension .gradle.

We are going to use groovy build and JAVA.

Then lets go to calendar.google.com and create an event. The red line is the current time so make the event after that line.

Now open file system. Create a folder in home with any name in my case “GoogleCalendar”.
Open that folder in terminal.

I already installed Java and gradle but still, show you the commands to install them.
Sometimes, you get older version of gradle, so you can upgrade it by using this command.
Then click on enable Google Calender API button.
Select Web server, now, type same url as I showed you. make sure that C in callback is capital.
Click on CREATE.
Download configuration.
Remember that file can be renamed if same file name already exists.

Now, in our newly created folder, create another folder with name CALLBACK. C capital.
Now in terminal, go inside callback folder using cd command.

Check if you have installed java and gradle correctly with required version.

Now, type the command they provided.

Type 1. To select Groovy.
For second question, don’t type anything, press enter directly.

Now if you check folder, some folders & files were automatically created.

Now paste the second command, which will create more folder in your project.

As per instructions, copy-paste credentials.json file from downloaded folder to this path.

Make sure to rename as credentials.json if name is different.

Next instruction is to copy-paste the gradle code in build.gradle file.

After that we have to create a java file at location as they told us.

Paste the code in it.

Here, remove “_READONLY” if you also want to change calendar events in future.

Now lets run the command “gradle run”.

It shall directly open the link in browser, but there is an error called “redirect_uri_mismatch”.

So to solve that, first cancel process by pressing ctrl+c in terminal.

Go to google console.

Left-top-menu, APIs & Services, and select credentials.

As you can see, the top Client Id is what we created on 7th of june, click on it, add URI, make sure to make same configuration as I do.

If you see in java code, the port number is 8888. So change that port in configuration.

Also, go to main callback folder and inside tokens folder, delete the file.
Lets clear the terminal and rerun the command.
It automatically opens the link in browser and you can see this page.
Select your google account,  click on advanced, go to quickstart unsafe, Allow.

You will see this message.
Now if you see it in terminal, you will see the upcoming event that we created at the beginning.
Lets rename it to verify. You can also create multiple events that will not be a problem for program to execute.

Now you can close terminal, and rename the folder.
Now open the renamed folder in terminal with same command and there will not be any problem in future.

In next tutorial, I shall show you how to get all events and display them on browser using JSP framework through gradle.

Required links are given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 


Monday 1 June 2020

JAVA Tutorial | Easiest Way To Get List Of Dates Between Two Dates






Code :-


import java.text.SimpleDateFormat;
import java.util.*;

public class DateList {
   
    public static void main(String[] args) throws Exception {
        String from="2020-01-01";
        String to="2020-05-30";
       
        Date d_from = new SimpleDateFormat("yyyy-MM-dd").parse(from);
        Date d_to = new SimpleDateFormat("yyyy-MM-dd").parse(to);
       
        //System.out.println(d_from.getTime());
       
        long t1=d_from.getTime();
        long t2=d_to.getTime();
       
        SimpleDateFormat f=new SimpleDateFormat("yyyy-MM-dd");
       
        if(t1<t2)
        {
            //1 = 1000
            for(long i=t1;i<=t2;i+=86400000)
            {
                System.out.println(f.format(i));
            }
        }
       
    }
   
}


------------------------------------------------
Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------


Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In this video, I shall show you the easiest way to get list of dates between two dates in JAVA.
Here I am using netbeans IDE and the date format as year-month and date.

 I shall be converting string to date by using date and SimpleDateFormat classes.
With netbeans, you will be assisted to import required packages and handle exceptions.

However, I shall manually handle exception by throwing it in main function line.
Main strategy is to convert date into milliseconds.

Now using LONG as data type is important because the milliseconds are large numbers.
First thing I shall do is to verify if from-date is lesser than to-date by applying if statement.

Now, I shall use for loop, a variable start with from-date and stop at to-date.
In for loop, I shall add 1 day in milliseconds.
One day is 86400 second.
However, 1 second equals to 1000 milliseconds, so add more three zeros.

Let check the output.

Now, the only thing left is to convert milliseconds to date.
For that, SimpleDateFormat variable is required.
Use format function with 1 argument of milliseconds.

The JAVA code handles even a leap as you can see, 29 days in February. 2020 which is the worst year.

The code link is given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 


Thursday 14 May 2020

QR Code Reader API | Using PHP And Linux OS And Xampp | Khanamiryan Github




QR Codes for testing


You can now download a whole API With VENDOR from:
https://unpossiblepog.com/codes/PHP/KHANAMIRYAN-QR-Code-Reader-For-PHP-version-7.2-And-Onward-With-Composed-Library

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------

QR Code Github link:-
https://github.com/khanamiryan/php-qrcode-detector-decoder

GD library commands :- (first try without running those commands)
sudo apt-get install php5-gd
sudo apt-get install php7.0-gd
 sudo apt-get install php7.1-gd
sudo apt-get install php7.2-gd

LUBUNTU : Install, Launch & Uninstall Xampp | Install Sublime Text | Complete PHP Configuration:-
https://youtu.be/X09awd5Q8Bk

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In this video, you will learn how to integrate QR code reader on website using PHP.
In this case, I will be using khanamiryan’s github package because people on internet claims that
it is the purest form of QR Code reader.
(Link in the description.)
Requirement is any linux from Debian family with xampp installed and php version better than 5.6.
Download the package.
Put that in htdocs folder of xampp, extract it.
Make sure to change permission to make it editable for everyone.
Rename it if you want to.
Inside that folder, there is a readme file which provides same steps as given below in github link.
So go back to htdocs folder and open qr code’s folder in terminal.
Install composer by tying this command. --> sudo apt install composer
Then enter your password.

Now, I provided in descriptions, 4 commands of installing GD library for each PHP versions from 5.6 to 7.2.
I suggest you to skip installing GD library, and install only if the main command gives you an error.
Now I shall be executing main command as they described by copy-pasting it in terminal.
Now if you check inside folder, there is vendor folder downloaded.
I shall be creating index.php file in main folder.
Lets check if it is working.
Now add PHP tag and paste the code they provided.
echo the text variable.
Now I have some QR code images, I shall paste them in our folder.( I shall provide them in blog link given in description.)
And paste the file name here.
Now, if you execute, there will be an error like Class QrReader not found.
So to fix it, rename function as this. (Zxing\QrReader).
And now if you execute, it will display content hidden inside QR code.
Lets try different QR code.
Don’t forget to like, share and subscribe.
Thanks for watching. 


Monday 4 May 2020

Google Sheet API | Part 3 | Delete Records From Spreadsheet | Remove Row...



Download VENDOR Folder (Only for PHP version 7.2+): https://unpossiblepog.com/research-and-development/php/Vendor-Folder-For-Google-Sheet-Drive-Calendar-With-PHP-Version-7.2-And-Onward

code :-

$requests = [
  new Google_Service_Sheets_Request([
      'deleteDimension' => [
          'range' => [
              'sheetId' => '0',
              'dimension' => 'ROWS',
              'startIndex' => 8,
              'endIndex' => 9
          ]
      ]
  ])
];

$batchUpdateRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
    'requests' => $requests
]);

$response = $service->spreadsheets->batchUpdate($spreadsheetId, $batchUpdateRequest);
print_r($response);



------------------------------------------------

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------

Google Sheet API | Part 1 | Connect And Display Sheet Data Using PHP | Latest:-
https://youtu.be/CI0xL93Xtpg

Google Update New Configuration :-
https://youtu.be/5COjnEc4d9E

DELETING ROW IMP Link #1:-
https://developers.google.com/sheets/api/samples/rowcolumn#delete_rows_or_columns

DELETING ROW IMP Link #2:-
https://developers.google.com/sheets/api/guides/batchupdate#example

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
This is the video of Deleting Rows in Google Sheet using API.
First, if you don’t know how to connect google sheet with PHP, then watch both videos.
Links of those tutorials are given in description.
Now, as you can see, the current code I have is to display data from google sheet on browser.
Also, I provided two links which are important for deleting rows.
First link is to understand the array structure for deleting.
Second link is a PHP code that we have to implement.
Now In a code, make sure that the scope is SPREADSHEETS and not SPREADSHEET_READONLY
Here, comment the code which fetches the data.
Copy the code from top up to response variable.
Paste it just below spreadsheetID variable.
Now, we actually need one GOOGLE SERVICE SHEETS REQUEST. So remove the second but be careful not to mess the structure.
We also don’t need FIELDS sub-array.
Open the array structure link.
So according to this, the first parent should be “requests” which is already given in code.
So we don’t need to change it.
The second parent is “DELETE DIMENSION”. Paste it.
Third is “RANGE”.
Now RNAGE has 4 key value pairs, so paste them one by one.
Now, the first key which is sheetID is not same as spreadsheetID.
But rather it is sub-sheet.
And it is denoted as GID which you can find in URL.
In my case, the GID is 0.
Now we are deleting rows, so paste ROWS.
Now in spreadsheet, there are numbers which are actual index that we are going to use.
Make sure not to use any quotes, just type numbers.
Also a side note is, startIndex 8 means it does not delete the 8th row, deleting will start
from 9th row up to 10th row.

So if we refresh and check sheet, you see that data from row 9 and 10 are deleted and the
rest were moved upward by 2 positions.
If you want to delete only 1 row that is 9th row, then type 9 at END-INDEX and type 8 at
START-INDEX.

Now the 9th row is deleted.
You can also copy the whole code from blog link which is given in the description.

Don’t forget to like, share and subscribe.
Thanks for watching. 



Wednesday 22 April 2020

Azure SAML 2.0 With PHP Login API | SimpleSAMLPhp | Login With Microsoft...




### Make sure to create index.php file inside your (renamed)folder. ###

index.php code :-

<?php
require_once 'lib/_autoload.php';
$as = new SimpleSAML_Auth_Simple('default-sp');
$as->requireAuth();

$attributes = $as->getAttributes();

echo '<pre>';
print_r($attributes);
echo '</pre>';

$url = $as->getLogoutURL();
echo '<a href="' . htmlspecialchars($url) . '">Logout</a>';

?>

------------------------------------
Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------

Azure Tutorial | Login Using Microsoft Azure Active Directory And PHP | Single Sign On ( SSO ):
https://youtu.be/IbJt7tr8kL0

Azure Link:
https://portal.azure.com/

SimpleSAMLphp Download Link:
https://simplesamlphp.org/

SimpleSAMLphp install documentation:
https://simplesamlphp.org/docs/stable/simplesamlphp-install

List Of Timezones:
https://www.php.net/manual/en/timezones.php

Index.php Code Link:


Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
This tutorial is about about Microsoft Azure’s SAML coonection with PHP.
Previously I made tutorial about Azure’s Simple SSO. You can check that out if you want to.
The Objective of SAML and Simple SSO tutorial is the same, that is to login using Microsoft account. But there is a huge difference between the approaches and security they provide.
1st is, Simple Single Sign On (SSO) is just a procedure where you can perform login operation. But SAML is a language which has similar structure as XML. That XML then helps to generate a configuration. Developers had to store those configuration in code or in database so that user can login later. You will understand that at the end of tutorial.
2nd is, in Simple SSO, anyone with microsoft email account can perform login. But in SAML, you can decide who which user can login.
3rd is, In Simple SSO, you must have original microsoft email account like xyz@outlook.com, but in SAML you can create subdomain account. For example, if your email address is abc@outlook.com and if your friend “DEF” doesn’t have any email account, you can create his email as def@xyz.microsoft.com.
Which doesn’t exists as an email but can login in your web application. Here XYZ.microsoft.com becomes a subdomain for your friend’s id.

4th is You can use Simple SSO for public websites like e-commerce or social media to create account by adding a button as LOGIN WITH MICROSOFT ACCOUNT, but SAML is mostly used
for private access websites like any admin sites or management systems where logins need restrictions.

There are few requirements for SAML implementation
1. At least 1 microsoft email account.
2. LINUX or Windows Operating systems with XAMPP  installed. (Just for testing)
3. LINUX hosted live website with SSL implemented and with an access of CPANEL, WHM or FTP (eg filezilla).
4. Linux Operating system (with zip compressor) or Windows OS (with WinRAR, or 7zip),

Lets jump to PORTAL.AZURE.COM.
I am using trial version which is available for 14 days max.
Go to top menu, and select Azure Active Directory, this AZURE ACTIVE DIRECTORY is IdP, means Identity provider which authenticates if user has permission to access website or not.
Go to enterprise application and then new application.
If you are using trial version, you will see something like this but in pink color, which says something about create a trial version or something like that. I don’t know, Just click on it and you click on “skip for now”.
Then this type of page will appear.
Click on “Create your own application”, Give any name,  click on “Integrate any other”.
Then create it and wait for around 20 seconds, they will redirect you on configuration page automatically.
Now we shall create users with subdomains for your friends, colleagues or clients.
Go to top menu, Azure Active Directory, then users. Create new user.
Click on show password.
Save the user id & password somewhere else.
Click on create.
I shall create another one to demonstrate how the SAML authentication works.
Lets go to enterprise application by clicking on side-menu, Azure Active Directory.
Enterprise Apps.
Select then app we created from the list.
Click on Set UP SINGLE SIGN ON.
Select SAML.
Now I have one website with SSL enabled.
Copy that path, go back to azure site, click on edit button of BASIC SAML Configuration.
Paste the link in, Entity ID and reply URL.
Actually, I shall just rename entity id, because you can give any name if you want to.
Then save it.
Don’t test it now because more configuration is yet to perform.
Now click on SAML Signing Certificate edit button.
then New Certificate, make sure to have same configuration as I have for signing option and algorithm.
Save it.
Now refresh the page.
The certificate configuration is generated automatically.
Now you can test it using your own main account.
As you can see even I don’t have any access right now.
Also notice that, in URL there is SAML2 written, means the restriction is provided by SAML module.
For that i shall go to “users and groups”, then “add user”, select a user from list.
I shall add myself.
Then,  go to single sign on, and click on test, and click on “sign in as current user”.
As you can see, I successfully redirected after logged it.
Now I shall give access to steve rogers sub-user.
And lets see if he gets an access or not.
First I shall try tony stark who doesn’t have an access.
Click on “Sign in as someone else”.
But even then it gives me direct access to this site so click on “use a different account”.
They ask me to change password because we are using default password.
But still it will not redirect me.
Lets try using steve rogers account.
And you see, that it redirects me.
Now copy logout URL and paste it in URL browser to logout from any account.
Now lets jump to PHP code.
Go to google and search “simpleSAMLphp”
Go to website, click on download.
Make sure not to download from GITHUB as they don’t provide vendor folder which is required for login.
Download the latest version from top link which is has the extension of tar.gz which is compressed version like .rar or .zip file
Now go to “documentation”, and click on “Using SimpleSamlphp as SAML service provider”.
this is just a documentation although you should avoid it because it tells you to make virtual host on your computer which doesn’t help at all.
But if you are using LINUX OS, then execute this command in terminal.
Go to the folder where you downloaded it.
Go back and open that folder in terminal.
type tar then space, then xzf then space then type the filename. Hint,is just type first few letters of that downloaded file and press tab it will automatically paste it’s name.
Then we have to rename this file to any name by using MV command.
If you are using windows OS, then just extract that folder using winrar or 7zip and rename that folder to anything you want.
You can ignore the rest of the information.
I am using sublime text for text-editor. You can use notepad ++ or netbeans etc.
If you see inside it, there is a vendor folder which has libraries.
Open xampp and try to access the project using localhost.
As you can see there is an error, also notice that it automatically redirect so somewhere else.
Open the file config.php which is  inside config folder.
Re-write the baseurlpath.
First add the folder name that we renamed, in my case, it was unpossible_2, then www.
Save it.
Let’s again try to access website and you see that there is no error even when it auto-redirects.
Now we are ready to implement it on live server.
Compress this folder.
Upload it in live website via cpanel or you can upload whole folder through FTP without compressing it.
But will take a lot of time to upload file via FTP. Choice is yours.
After uploaded, extract that file.
Now lets go to azure website. and in application configuration, click on “edit button” of BASIC SAML config.
Now paste that extra path in reply url. which is your website, then your folder, then www.
Save it.
Then copy the whole URL.
Go inside that folder and open config folder.
Then open config.php.
Here paste that path we copied.
Scroll down, and add any timezone you prefer.
add any random password.
Save it.
Then lets access that URL.
And you will see that it redirects.
Click on configuration tab.
Everything is working.
Now go to cpanel, and open authsources.php file.
Now go to azure site and copy entity id.
Copy it and paste it in code.
Then copy azure AD identifier and paste it in Idp value.
Now lets refresh website.
Go to authentication tab, click on “test configured authentication sources”,then click on admin.
Type the password that we gave in config file.
Now again access www folder.
Go to federation tab.
Click on XML to SImpleSAMLPHP metadata converter.
Here you have to add xml file.
so go to azure site and save the xml file.
Browser that downloaded XML file and click on parse.
Now scroll down.
Here the provide you the PHP code and tell us to paste it in “samp20-idp-remote” file.
Copy this code
Go to cpanel.
Go inside metadata, and find the file “samp20-idp-remote” .
Open it.
and paste that code in this file. close php tag.
save it.
No again access www folder on browser.
Click on authentication tab.
Click on “test configured authentication sources”.
then default-sp.
You will be redirected to login.
Once logged in, you will see yours details like email ID, name etc.
And there is a logout button too.
Click on it to logout from current account.
Lets try that again using incorrect account.
Let try using correct account.
Now it is very lengthy to fetch out required info from Default user interface they provided.
So I made a manual code to directly get the file.
Link of that code is given in the description.
Add that in index file.
Also in azure configuration, change the reply url path, just remove /www.
Paste index.php file inside your folder.
Lets access that index.php file.
And you will see that code is now displaying that data in array.
You can get any data and push it in SESSION to maintain login.
Also there is a logout button at the bottom.

Don’t forget to like, share and subscribe.
Required links are given in the description.
Thanks for watching. 


Tuesday 14 April 2020

Google API Update Alert 1 | Google Sheet And Google Calendar With PHP | ...




Download VENDOR Folder (Only for PHP version 7.2+): https://unpossiblepog.com/research-and-development/php/Vendor-Folder-For-Google-Sheet-Drive-Calendar-With-PHP-Version-7.2-And-Onward

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------

Google Sheet API | Part 1 | Connect And Display Sheet Data Using PHP | Latest:
https://youtu.be/CI0xL93Xtpg

Google Sheet API | Part 2 | Create New Sheet | Add & Update Cell Values:
https://youtu.be/X9h47ht-NnY

Google Sheet API | Part 1 | Connect And Display Sheet Data Using PHP | Latest:
https://youtu.be/Q-498CAa1xE

Google Calendar API Tutorial #2 | Access Different Calendars Using PHP:
https://youtu.be/9FfWnfpx9Kw

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
Google recently added some extra steps, for security reasons, while we create credentials for developing APIs for PHP.
It is making direct impact on my 4 tutorials on GOOGLE APIs which are on google sheet and calendar so I had to make this video as soon as possible.
Plus the process has a huge bug. I shall tell you how to bypass that bug and make the code work.
In this case I am using google sheet, but steps are similar for google calendar too.
Here you will see that, I created a folder in HTDOCS of xampp.
If you go to quickstart, and click on enable API, there is an extra INPUT you have to do. For my 4 tutorials, you have to select “web server”, and give the path which is for security reason so that no other website will access same API and code.
I am using localhost just for testing, and folder name as “google_update”, make sure to have same folder on both sides, and I shall give the name as quickstart.php. You will see that quickstart file later.
Download the credentials.
Paste it in that newly created folder.
Open that folder in terminal.
execute the command they provided.
Once done, copy the php code, create a new file as quickstart.php in our folder. Paste the code.
Make changes as same as I do in that code.
In terminal, make sure you are in that folder, then execute this command.
When clicked on “ALLOW”, you will see a huge bug.
The output was supposed to be like this. but, they provide you verification code in URL.
This change was done by google in coronavirus quarantine so it is possible they they didn’t get time to test it.
I understand that they are human too, they will fix it.
If you observe, the process directly executed the file.
So just copy the verification code and paste it in terminal.
hit enter. And you will be connected with API.
Now what you can do is comment those lines and then execute file in browser.
You can execute it without any request variables.
Sometimes you get error like this for token.json which says “file_put_contents(token.json), permission deined”
So just go to it’s properties and make it executable for everyone by changing the permission.
Now you can continue watching my tutorials.
Don’t forget to like, share and subscribe.
Required links are given in the description.
Thanks for watching. 


Thursday 9 April 2020

Google Sheet API | Part 2 | Create New Sheet | Add & Update Cell Values


------------------------------------------------

Download VENDOR Folder (Only for PHP version 7.2+): https://unpossiblepog.com/research-and-development/php/Vendor-Folder-For-Google-Sheet-Drive-Calendar-With-PHP-Version-7.2-And-Onward

Hey guys, this is UNPOSSIBLE POG.
In previous part, we saw how to connect GOOGLE SHEET with PHP, and display data. If you haven’t watch that, then you can click on top corner or link is given in the description.
In this part, we shall learn how to create new spreadsheet and how to add & update data in it.
First of all, I shall get rid of those comments.
Then first we shall learn how to create new spreadsheet.
Go to the link that I provided in description, copy the code in PHP tab, comment previous display code, from below service variable up to bottom.
We shall paste it here.
Add any title you want.
And execute it.
It will respond with spreadsheet ID.
Lets go to google sheet’s home page, and you will find that spreadsheet.
Remember that newly created sheet always creates subsheet named “sheet1“ inside it by default.
I shall just delete it because I am not going to use it.
Next is to add & update data in out sheet.

We shall need spreadsheet ID and range.
Go to the description and click on "Add / Update spreadsheet values” link.
Skip that “Writing to single range”, because it is useless.

But before that, we shall append values, means add new rows in spreadsheet.
Copy the code, paste it after range.
Now I am going to add two new rows. So follow my format.
Notice that we are only adding 3 columns that is from A to C.
2 after A doesn’t matter right now.
And “VALUEINPUTOPTION” can have two values, either RAW or USER_ENTERED.
RAW means, the data goes as it is as you can see.
“USER_ENTERED” on the other hand performs operation before sending data to spreadsheet.
For examples, it can calculate the values.
As you can see, it showed addition.
But if you use RAW for same syntax, then it gives you an error, so keep a note.
Lets comment it.

We shall use spreadsheet ID & range again. But range now matters the most when it comes to update.
Lets try some data so that, spreadsheet will start updating from 6th row.
Updating data is vary risky so be careful while executing otherwise it can remove your important data.
Now we put 6 so that it will start operation from 6th row.
As you can see, data is replaced.
But what if we add row number which is empty?
It adds new rows in spreadsheet.
So that is it.
Don’t forget to like, share and subscribe.
Required links are given in the description.
Thanks for watching. 
Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------
How to connect with Google sheet and display data:-
https://youtu.be/CI0xL93Xtpg

Create new Spreadsheet:-
https://developers.google.com/sheets/api/guides/create

Add / Update spreadsheet values:-
https://developers.google.com/sheets/api/guides/values

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/

Saturday 4 April 2020

MS Azure Tutorial | Login Using Microsoft Azure Active Directory And PHP...



Download Whole API with Composed Repository (Only for PHP v7.2 & Plus):- https://unpossiblepog.com/research-and-development/PHP/Magium-Active-Directory-With-VENDOR-For-Microsoft-Azure-SSO-Only-For-PHP-Version-7.2-And-Onward

Hey guys, this is UNPOSSIBLE POG.
In this video, I shall make a connection between microsoft azure and PHP, in short, an authentication using microsoft account through cloud service.
This service is one of the type of “Software as a service” that is SaaS.
As you know, microsoft Azure is a of the cloud-service provider where you can store your data, use it, execute it.
We are using AZURE to authenticate user’s account on their servers rather than our own server or computer.
What do I mean by that?
Suppose you have a website called www.xyz.com, than rather than creating your own login form, you can use microsoft’s login page. So what are the advantage?
Some of them are,
1, if you create your own login page, then it may have loopholes from where hackers can hack into your website. (Loophole maybe like sql injection, bruteforce login)
2, your code can validate email pattern but can not identify if they are real or not. For example if an intruder whats to access your service, then he can create add an email like random-person123@hammer.com which has same pattern as any email but may not exists in real world.
There are many more, but lets skip that for now.

There are 4 important requirements that you need to have.
1) Microsoft account (free trials / Purchased )
2) Should have a live website hosted on servers, with access of CPANEL, WHM or FTP (Filezilla)
3) Any SSL certificate should be installed on that domain. (HTTPS)
4) Linux Operating systems (Debian family) In your PC or LAPTOP with xampp installed in it (PHP version > 7 is recommended)

Lets get started.
Go to portal.azure.com
If you are using trial version, then click on “skip for now”
From top menu, click on “Azure active directory”
 Click on App registration.
Click on “New registration”
Type any random name that you want for application.
Make sure to select Multi tenant (tenant = users) with personal microsoft account.
Platform is optional.
Click on REGISTER.
Now scroll down,  and make select on “YES” on “Treat application as a public client”, and save it.
Then again, click on TOP MENU, “AZURE ACTIVE DIRECTORY”, then select the application we created.
Make sure to copy “APPLICATION (CLIENT) ID”, we need that later on.
Then click on “ADD a Redirect URI”.
You came back to same page of configuration.
Now click on “Add a platform”, and select “WEB”.
Now, I have one website with HTTPS enabled.
For now I shall use that link as redirect URL.
That UNPOSSIBLE_1 is just a folder that I am going to create later in my website, so don’t panic.
Make sure to tick “Access tokens” and “ID tokens”  checked, and click on configure.
You can also tick tokens configuration from here if you want to.
Now click on “Certificates and Secrets”,"New Client Secret”, add random description.
Click on “Add”.
Now make sure to copy this client for later use because next time when you come on same page, they won’t display you the secret value.
Lets again go to, top menu, Azure Active Directory, App registration, you can see that we have certificates ticked for our application.

Now lets jump to PHP.
I provided you the github link the the description.
Download ZIP,
Go to downloaded folder and paste it in HTDOCS folder of XAMPP.
I already downloaded it.
Extract it.
Now rename the extracted folder as the same name that we gave in the folder in my case its “UNPOSSIBLE_1”.
I am using sublime text for editor, but you can you anything like netbeans, notepad++ etc;
Notice that there is a folder called, “examples”, and inside it there is WWW, we are using this index.php as an executable program. So paste that path in redirect URL and save it.
In directories, go to HTDOCS and open your folder in terminal.
Now this is where things get tricky.

Open composer.json file inside your folder and copy those lines and paste it in require array of composer.json file.
Now here, type this.
In terminal type “sudo apt-get install composer” and enter your password.
I already installed composer.

Depending on your php version, type those commands, for CURL,
Sudo apt-get install php-curl
Oops, don’t forget to add SUDO before that command


Now run this command
“composer require, then name of library”
means “composer require  magium/active-directory”

You may see some problems like this, because there are many extension that may require for that JSON to run.
In simple words, currently we installed “php-curl”, which is one of the extension we needed.

You can paste those problems below in comment box, I shall try to find the solution to those problem. Most of the time, the problem could be the “mission extensions” in your system.
You can ignore this orange thing.
Now if you look inside program, there is a vendor folder which was generated by execute composer.json file.
Now we have to compress that file in ZIP only and upload it in LIVE WEBSITE using CPANEL, you can also you upload a whole folder via FTP, so that you don’t have to compress folder.(FTP takes more time to upload)
You will have to upload that zip file in public_html.
Once uploaded, go to file system, and extract that zip file.
Your folder will appear, now go inside that folder, then example, then the www.
Edit the index.php.
Add comma here.
HERE, have to add  new array key as ‘redirect_url’.
Add client ID, client secret, directory as common.

I made a mistake here, type “return_url” as a “key”.

Now, lets test it,  paste our link in browser’s URL.
You will be automatically redirected to Microsoft LOGIN.
Which means, that index.php file can be used as a login page for your web application.
You see that, they provide you some info about user, you can user’s email and name in PHP session  to maintain login and to create account.
Share it with your colleagues, friends, or employees to implement Microsoft azure authentication in your website.

Required links are given in the description.
Thanks for watching. 
Don’t forget to like, share and subscribe.
-------------------------------------------------------
Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/

Friday 20 March 2020

Easiest Way To Change Date From One Timezone To Any Another Timezone | PHP And MYSQL | CONVERT_TZ


Code :-
<style type="text/css">
    body {
  font-family: Arial, Helvetica, sans-serif;
}
</style>
<body>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'test';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname);

if(! $conn ) {
   die('Could not connect: ' . mysqli_error());
}
else
{
    echo "DATABASE CONNECTED<br/>";
}

//CONVERTING TIME FROM NEW YORK(USA) -> KOLKATA(INDIA)
//FROM = NEW YORK
// TO = KOLKATA
$from_exact_date_time='2020-02-15 09:00:00';
$from_timezone=new DateTimeZone('America/New_York');
$from_datetime=new DateTime('now',$from_timezone);
$from_format=$from_datetime->format('P');
echo "New York format : ".$from_format."<br/>";

$to_timezone=new DateTimeZone('Asia/Kolkata');
$to_datetime=new DateTime('now',$to_timezone);
$to_format=$to_datetime->format('P');
echo "Kolkata format : ".$to_format."<br/>";

$query="SELECT CONVERT_TZ('".$from_exact_date_time."','".$from_format."', '".$to_format."') as converted_date";
$data=mysqli_query($conn,$query);

$output=mysqli_fetch_array($data);

echo "NEW YORK DATE/TIME IS : ".$from_exact_date_time."<br/>";
echo "KOLKATA DATE/TIME IS  : ".$output['converted_date'];


?>
</body>
------------------------------------------------
Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------
World Time Buddy :-
https://www.worldtimebuddy.com/

List of timezone : -
https://www.php.net/manual/en/timezones.php

Code Link : -

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys, this is UNPOSSIBLE POG.
In this video, I shall tell you the easiest way to convert date-time from one timezone to any other timezone using PHP and mysql.
In this example I will be converting NEW YORK time to KOLKATA time.
There is a website called “worldtimebuddy” (NOT SPONSORED) which will tell you exact time difference between two timezones.
Link in the description.
I am adding kolkata time and if you click on it, you will see that when in NEW YORK, the date-time is 15th of march 2020 2:00AM, at that time in kolkata, the time is 15th of marth 2020 11:30 AM.
Moving back to code I already added a code of database connection of MYSQLI.
In our code, FROM is NEW YORK and TO is KOLKATA.
First we shall get timezone.
In PHP manual, you will get all the available timezone list. Search for desired timezone.
Then in code, we shall get datetime of that timezone.
It’s link is also given in description.
Then get the difference format.

Same thing we have to do for “TO Timezone” that is, for KOLKATA.
Lets verify.
Remember that those formats are based on UTC.
If you want to convert from UTC then the format is always +00:00.
Then we write an SQL query, there is a function in query called CONVERT_TZ with 3 arguments.
1st argument is the time that you want to convert.
2nd argument is the format of that date, in your case, it is NEW YORK’s format.
3rd argument is the format of timezone that we want to convert.
If everything is correct, then the should be 15 march 2020 : 11:30 AM.
Lets try another date-time.
If in new york the time is 9 AM, then in kolkata it should be 18:30 of same date.
Required links are given in the description.
Thanks for watching. 
Don’t forget to like, share and subscribe.

Saturday 7 March 2020

Google Sheet API | Part 1 | Linux Only | Connect And Display Sheet Data ...




Download VENDOR Folder (Only for PHP version 7.2+): https://unpossiblepog.com/research-and-development/php/Vendor-Folder-For-Google-Sheet-Drive-Calendar-With-PHP-Version-7.2-And-Onward

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
------------------------------------------------
Social Media Links :-

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys, this is UNPOSSIBLE POG.
In this video, I shall tell you how to connect connect xampp PHP with google spreadsheet.
In first part, I shall show you how to display data on browser.
There are few requirements that your should have.
1st is to use linux OS. Most preferable is the operating system from Debian Family.
If you want to know how to install and use PHP in LINUX, then tutorial video’s link is given in description.
Now lets get started, go to google and search google spreasheet api php.
Go inside this link, “developer.google.com"
In latest edition of this link, they improved some steps to make integration easier.
Now it says you require php version more than 5.4.
Go to htdocs location.
Create a new folder.
Change it’s persmission to write inside it.
Open the IDE, and assign the folder in it. I prefer sublime text.
Open it in terminal.
now install composer by using this command.
“sudo apt-get install composer”
As you can see I already installed it.
Go to website and enable your google sheet api credentials.
Download it’s configuration.
Copy-paste it in your new created folder which is in htdocs. in my case its google_sheet.
Now we shall run provided command in folder’s terminal.
It may take more than 1 minute because the command is downloading  composer files from google server which are must to run the API.
Copy paste the code in newly created file.
Make sure to close PHP tag.
Now here, you have to make many changes.
First, remove underscore-readonly text from scope.
Add DIR before those two file locations.
Now, by default, google provided some default spreadsheet link which is common for multiple people but we don’t want that so create a new spreadsheet.
Now copy its id which is after D-slash upto another slash, and paste it in code.
Now each spreadsheet has it’s own name, which is at the left corner.
The name is sheet1, so type it in range variable.
And also column are available from A to C.
Lets first run it in terminal because we are going to create a secret key for security purpose.
Well, I forgot to add slash there.
Lets return it.
Now they provide a link, copy it and paste it in browser’s url.
Login into email ID.
Click on advance then go to quickstart unsafe.
Allow access, and copy paste this code in terminal.
There is another mistake that I have made.
Oh yaa, the sheet name was incorrect. Make sure that you should type sheet’s name before exclaimation sign.
Rerun it.
Umm, the output did come but I think that I was jumping on 5th column but in excel sheet there are only 3 columns so make sure that, you only give column number up to maximum available columns in spreadsheet.
 Now to run this code in browser, just comment those lines and open that page in browser.


Required links are given in the description.
Thanks for watching.
Don’t forget to like, share and subscribe.