Saturday, 25 March 2017

Calculator Using Batch File

Hello friends,
Here is the code for how to make a calculator by using batch files.
copy and paste the following code in notepad, as given below and then save the file as "calculator.bat"

@echo off
title Batch Calculator by Ankit
color 1f
:top
echo --------------------------------------------------------------
echo Welcome to Batch Calculator by AnKiT :D
echo --------------------------------------------------------------
echo.
set /p sum=
set a ans=%sum%
echo.
echo = %ans%
echo --------------------------------------------------------------
pause
cls
echo Previous Answer: %ans%
goto top/
pause
exit

Have a look on this Video

Friday, 17 March 2017

How to connect android debug bridge over WiFi

Hello Guys,
In this post, we will see how to connect android debug bridge over WiFi. Basically, this method can be used in non-rooted android devices too. We will be needing an USB cable for the first-time setup, then rest all debugging can be done over WiFi. ADB can be used for deploying apps directly from the Android Studio, or we can also use it for flashing ROMs, recoveries, and Kernels.

For Detailed Information, have a look at this video


Procedure:

  1. Download the minimalistic ADB kit from here.
  2. Install it, then check it by typing either one of the bellows in the command prompt.
    adb or fastboot
  3. Connect your mobile to laptop and allow USB Debugging.
  4. In Command prompt, type the bellow set of commands
    adb tcpip 5555
    
    ##To find the mobile ip type:
    adb shell ip -f inet addr show wlan0
    
    ##The ip address will be shown in second line like this:
    ##inet 192.168.1.233/24 brd 192.168.1.255 scope global wlan0
    ##where 192.168.1.233 is the ip address of your mobile.
    
    ##Remove USB cable and type:
    adb connect mobile-ip:5555
    

Now your android mobile is connected in ADB through WiFi.
Enjoyed reading this post, make a little time for sharing the post, with your friends, and help us grow!

Monday, 6 March 2017

Create a PHP script which returns JSON response on GET requests

Hello Guys,
In this post, we will create a PHP script which will return JSON response, when we send GET request to it. Basically, we will be developing a simple API for our requirements. Any PHP API has 3 files,

  1. config.php [The Database Configuration File]
  2. myClass.php [The Class containing functions, for modularity]
  3. index.php [The Handler, which invokes respective functions, on GET Requests]

For Detailed Information, have a look on this video



Without wasting any time, lets jump into the codes,
1. config.php
<?php
define("DB_NAME","test");
define("DB_USER","root");
define("DB_PASS","");
define("DB_HOST","localhost");
?>
2. myCLass.php
<?php
require_once 'config.php';
class myClass
{
 public function check($user,$pass)
 {
  $con=mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);
  $res=mysqli_query($con,"select pass from users where user = '$user'");
  $pa = mysqli_fetch_array($res)[0];
  $arr = array();
  if ($pa == $pass)
   $arr=array('check' => 'True','user' => "$user");
  else
   $arr=array('check' => 'False');
  return $arr;  
 }
 public function register($user,$pass,$email)
 {
  $con=mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);
  $res=mysqli_query($con,"insert into users values ('$user','$pass','$email')");
  if($res)
   $arr=array('check' => 'True');
  else
   $arr=array('check' => 'False');
  return $arr;  
 }
 public function show($user)
 {
  $con=mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);
  $res=mysqli_query($con,"select * from users where user = '$user'");
  $arr = array();
  while($row = $res->fetch_assoc())
  {
   $arr[]= $row;
  }
  return $arr;
 }
}
?>
3. index.php
<?php
require_once 'myClass.php';
$db = new myClass();

if(isset($_GET["user"]) && isset($_GET["pass"]) && isset($_GET["email"]))
{
 echo json_encode($db->register($_GET["user"],$_GET["pass"],$_GET["email"]));
}
else if(isset($_GET["user"]) && isset($_GET["pass"]))
{
 echo json_encode($db->check($_GET["user"],$_GET["pass"])); 
}
else if(isset($_GET["user"]))
{
 echo json_encode($db->show($_GET["user"]));
}
else
{
 echo "API SERVER - Send Request To Get Response.";
}
?>


Hope you enjoyed reading this post, share with your friends and help us grow. Make sure you subscribe us, to get the latest from us.

Sunday, 2 October 2016

My First Phonegap App

In this post, we are going to create a simple basic app using PhoneGap. Phonegap is a software development framework which is used to create cross-platform mobile applications. Phonegap is leading framework which is used to create cross-platform apps. To start with PhoneGap you must have a practical knowledge of HTML, CSS, and JS. You can extend it features using Node.js. PhoneGap produces apps for all popular mobile OS platforms such as iOS, Android, BlackBerry, and Windows Mobile OS etc.

What we are going to cover ?

  1. Running PhoneGap, creating a new project.
  2. Editing the project
  3. Installing PhoneGap client on mobile.
  4. Running the app on the mobile
  5. Uploading the project to GitHub
  6. Deploying app from Phonegap Build
Presuming that you have already installed PhoneGap and git in your system, Let's move forward in creating the application. If you haven’t installed yet, download PhoneGap from here and Git for here. Install it as normal application software and you are good to go.

Step 1

Open PhoneGap by navigating to start > programs > PhoneGap Desktop. After the program launches, click on the plus icon, then click on create a new PhoneGap project. Choose the path, give an appropriate name with an ID as well. Finally, click on the create project button.



Step 2

Now you will see that your project is already in running state. If you are connected to a WiFi then it's well and good, else create a hotspot from your mobile and then connect your machine to that hotspot. After connecting click on stop icon beside your project, then again click on the play button. You will see at the bottom like “Server is running on http://192.168.xxx.xxx:3000“. Now to edit the project you need to navigate to the path where you have setup your PhoneGap project, i.e. your LOCAL Path. Click on the link under the local path of your project. In the window which opens, navigate to the www folder. This is basically the folder where you can make changes to the app. Inside the www directory, you can see a file named index.html, open it with any standard editor (Notepad, Notepad ++, Sublime..). Now replace it completely with the bellow code which I’ve shared. It is a simple code which uses all three CSS, HTML and JS. Save the file after replacing.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
    <meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />
   <title>My First Phonegap Application</title>
   <style type="text/css">
    body{
           background-color:beige;
    }
       .app h1{
           text-align: center;
       }
       .app > .container{
           border-style: solid;
        border-width: 1px;
        border-radius: 5px;
        box-shadow: 1px 1px black;
        margin: 10px;
       }
       .app > .holder{
           text-align: center;
       }
       .holder > button{
           border-style: solid;
        border-width: 1px;
        background-color: #fff;
        border-radius: 10px;
        box-shadow: 1px 1px blue;
       }
   </style>
   <script type="text/javascript">
       function fun1()
       {
           alert("You have cliked on Button 1");
       }
       function fun2()
       {
           alert("You have clicked on Button 2");
       }
   </script>
</head>
 
<body>
    <div class="app">
        <h1>My First App</h1>
        <div class="container">
            This is the dummy content of my first app. I've purely developed it using basic CSS and HTML.
        </div>
        <div class="holder">
            <button onclick="fun1()">Click Me</button>
               <button onclick="fun2()">Click Me</button>
        </div>
    </div>
</body>
</html>

Step 3

In Google Play search for “PhoneGap Developer“, it is basically the mobile client of PhoneGap. This app can be thought of an emulator, which runs the app before deploying it using the PhoneGap build. Download it and install it.

Step 4

After installing the PhoneGap Developer app, open it. You can see the server address field. Inside that field, type the address where the server of your PhoneGap desktop client is running. This IP can be found from the Desktop client.


After typing the server address, click on connect. Once downloaded all the files from the local server (PhoneGap Desktop Client), It will load up the app. There you can see it working. Bellow are some screens of the dummy app.



Step 5 and Step 6 Will be covered in another post, since these two steps require a length process. Specially uploading the code to GitHub. But for time being you can test(debug) your apps directly in your mobile using the PhoneGap Developer App. Hope this post helped. Share this with your friends. Got any queries, drop them in the comment section.

Friday, 30 September 2016

Create a chatbot in python using AIML

In this post, we are going to create an AI-powered chatbot in python using AIML. AIML is Artificial intelligence markup language. A chatbot is that software/ script to which you can talk. It's just like talking to a normal human over the internet. Through ages, chatbot has been evolved in terms of their accuracy. In this, we will use the brain of ALICE, developed by Dr. Wallace.
  1. Install AIML
  2. Download Alice Brain
  3. Group into a single directory
  4. Create a pythonic code to run

Create a chatbot in python

Prior to this step, I'm assuming that you have already worked on python and you know what pip is. Now Installing AIML
sudo pip install aiml
Type the above line inside the console(Terminal/CMD). Download the latest Alice - AIML by clicking here. After downloading extract this zip in a directory (eg: Alice). This is basically the brain of the chatbot. Use the bellow Code snippet to do the rest
import aiml
import os
 
# Create the kernel and learn AIML files
kernel = aiml.Kernel()
kernel.learn('alice/*.aiml')
# Press CTRL-C to break this loop
os.system('clear')
while True:
    x=raw_input('>>')
    y=x.split()
    if 'bye' in y:
        print 'Alice: Tata..'
        break
    else:
        x=kernel.respond(x)
        print 'Alice:',x
Save the above code in the same directory which contains Alice Folder. Very well, now you have created your own chatbot in python using AIML. This is basically an offline chatbot. Liked this post then why don't you share this with your friends.