Showing posts with label Interesting Programs. Show all posts
Showing posts with label Interesting Programs. Show all posts

Thursday, January 5, 2023

Upload file from URL to Server using cURL in PHP


This Post show how to upload data or audio files on server getting from URL and how to download that file in PC using URL.


First put URL in string like below:

$url = 'http://s.cdnpk.eu/pk-mp3/love-dose/s165352040.mp3';

To Download file in PC its a simple short-cut.using download attribute of <a> tag in HTML.

echo "<a href='".$url."' download='myfile.wav'>Download</a>";


Now convert that URL to file using curl.

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
curl_close($curl);

Now create a file on server. And open it in write mode.


  $fileName = "myfile.wav";
  $fh = fopen($fileName, 'w') or die("can't open file");


Write the file which we fetch from URL in 'myfile'. it was in $data variable.

  fwrite($fh, $data);
  fclose($fh);

Close the file that's it. Happy coding. :)


Monday, January 2, 2023

Object Oriented Programming (OOP)

OOP Programming SeekerzZ
Object Oriented Programming (OOP)
Object oriented programming OOP is a programming technique which is used by many programming languages and in this you have to use classes which are a user define data type and you create functions and attributes according to your use and then to use them you have to create an object or instance of that class so that you are able to access the attribute and operation of that class.
Advantages:
The object oriented programming have a main advantage of code reusability that you have to create a class for one time and then just have to create its instance where ever you want to use it.
The main concepts of object oriented programming are given below:
  • ·         Inheritance
  • ·         Encapsulation
  • ·         Overloading
  • ·         Polymorphism
  • ·         Abstraction

As we already discuss all of these topics in over previous posts but for now take a little review of all of them. Inheritance as the name suggests inheriting something from other. In this we have a supper and sub class hierarchy and sup classes are inherited form super classes and was able to use the functionality and attributes of super class. Many type of inheritance is there:
  • ·         Single level inheritance
  • ·         Multi-level inheritance
  • ·         Multiple inheritances
  • ·         Hybrid inheritance

For more there are other two very important concepts in inheritance which is following:
  • ·         Generalization
  • ·         Specialization

Encapsulation mean data hiding in classes we have to define the scope of every object and function by default they are all private. We have normally three scope resolution operator.
  • ·         Public
  • ·         Private
  • ·         Protected
  • ·         Sealed
  • ·         Sealed internal

Overloading provides us the y to define same thing with different meaning there are two type of overloading:
·         Function overloading
·         Operator overloading
In function overloading we have many functions with same name but different data type and in operator overloading we re-write the functionality of different operators like =, <, >, ||, $$ etc.

Polymorphism means many ways. In this we have many ways to class a function it cover the topic of function overriding.
The polymorphic classes contain two types of functions
  • ·         Virtual function
  • ·         Override functions


OOP languages:
There are many object oriented programming languages in which some are pure object oriented and some have both procedural and also object oriented way.
Java and C# are pure object oriented languages
C++, PHP, JavaScript are not pure object oriented but have functionality of it.

Constructor:
The constructor is default functionality in all object oriented languages which come with the classes whenever we create object of the class the default constructor call and execute its code first without calling it.
In C++, Java and C# constructor have the same name as class name and have no data type but in PHP we have to define constructor like this:

Function __construct( ) {  }




Example class in PHP:
<?php
class person{
            function __construct(){
                        echo "<h1>Person Information</h1>";
            }
            private function get_ID($id){
                        echo "<h3>Person ID No is :- ".$id.'</h3>';
            }          
            private function get_name($name){
                        echo "<h3>Person name is :- ".$name.'</h3>';
            }          
            private function get_mob($mob){//have private scope
                        echo "<h3>Person Mobile No is :- ".$mob.'</h3>';
            }          
            public function calle($id,$name,$mob){
                        $this->get_ID($id);
                        $this->get_name($name);
                        $this->get_mob($mob);
            }
}
                        $obj = new person();//object creation
                        $obj->calle(101,'Usman','0307-5230948');//function calling

?>

Sunday, January 1, 2023

Monday, December 26, 2022

Friday, December 23, 2022

Add or Remove Input fields Dynamically Using JQuery - HTML

Add or Remove Input fields Dynamically Using JQuery - HTML
add/remove multiple input fields in html forms


if you are looking to add and remove duplicate input fields, here’s another jQuery example below to do the task for you. This jQuery snippet adds duplicate input fields dynamically and stops when it reaches maximum.

Code:

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

<script>
$(document).ready(function() {
    var max_fields      = 10; //maximum input boxes allowed
    var wrapper         = $(".input_fields_wrap"); //Fields wrapper
    var add_button      = $(".add_field_button"); //Add button ID
    
    var x = 1; //initlal text box count
    $(add_button).click(function(e){ //on add input button click
        e.preventDefault();
        if(x < max_fields){ //max input box allowed
            x++; //text box increment
            $(wrapper).append('<div><input type="file" name="mytext[]"/><a href="#" class="remove_field">X</a></div>'); //add input box
        }
    });
    
    $(wrapper).on("click",".remove_field", function(e){ //user click on remove text
        e.preventDefault(); $(this).parent('div').remove(); x--;
    })
});
</script>



<div class="input_fields_wrap">
    <button class="add_field_button">Add More Fields</button>
    <div><input type="file" name="mytext[]"></div>

</div>




Thursday, December 22, 2022

Fore Ground Extraction and Back ground subtraction from video in Matlab




Gait recognition project Dataset

As i'm currently working on biometric gait recognition project so to complete that project i have to background subtraction to extract foreground from video.

i'm using CASIA data set videos for my experiments.
So background subtraction is the first thing to do in my project so when we have extracted human structure from video we easily perform our algorithms on it to identify its gait.


Matlab code for background subtraction using frame difference:

clc;              % clear command window
clear all;     % clear work space

% Reading video from computer directory
videoObject = VideoReader('001-bg-01-090.avi');

% Determine how many frames there are.
numberOfFrames = videoObject.NumberOfFrames;

% Loop through all frames
for frame = 1 : numberOfFrames

% Extract the frame from the movie structure.

img1 = read(videoObject, frame);
        img2 = read(videoObject, frame+10);

% In above we take two frame to subtract them from each other

% Subtract frames from each other
img3 =  imsubtract(img1,img2);

% Convert the subtracted result to rgb
  img4 = rgb2gray(img3);

% Apply sobel edge detection on rbg frame
  img5 = edge(img4,'Sobel');

% Use morphological approach to fill holes

d =  bwmorph(ege,'remove',1);
 e = imfill(d,'holes');

% And now save them one by one in hard-disk
        outputFolder = '\newdataset\chknew1';
       
       FileName = sprintf('img%.2d.png', frame);

outputFileName = fullfile(outputFolder, FileName);

imwrite(e, outputFileName, 'png');
        
        end


Tuesday, December 20, 2022

Thursday, December 15, 2022

How to Start a Software Company in Pakistan


Graduates coming out from Universities are usually very passionate to start a software house of their own. Once they step into the real world, pictures from the dream word start getting blurred and things start looking much more complex then what they envisioned in their dreams.

An initial thought of putting down few computers together in a nice office, giving a good name to this small setup and taking up the seat of CEO of this house, now looks like nothing more than an exercise of interior decoration. People standing outside on the road, will start rushing into this new facility to get their software ordered and we will start making big deals and will have dollars flowing all around is another aspiration that now looks like a big exaggeration.
So what?
What am I supposed to do?
You need projects to start work. Where to get from? Local market? International market? Or should you start developing a new product? How should you decide?
Project or Product?

Project:
A project is a customer specific order for developing software as per his/her specific needs. For a project to get started you need to have a customer paying for it and signing a deal with you.
Product:
Product is usually a new idea or a modification of existing product, targeting customers all around in some specific business domain and does not need any binding, deal or agreement before hand.
Should I go for Projects or should I innovate a product? That’s a challenging question and in fact draws a baseline of your business motive and is a strategic decision. How to decide? What are the factors to base my decision upon?
Here we go with some important considerations for a new entrepreneur:
Capital:
How much can you invest and for how long can you invest without worrying for ROI (Return on investment).
Let’s say I have 1 million and can invest for 2 years without running into financial crises. Will not need to withdraw single penny from my business, have other sources of income to sustain myself and so on. That looks like a relatively good condition for an innovation, but only if I can innovate something.

What should I innovate?
Should I go for a flying train? No, we are only talking about a software innovation. So what should I? Should I develop a product for NASA for tracking satellites? That would impose a big risk, what if NASA refuses to buy the product or is not interested at all. Should I go for an income tax calculator? I need too much of domain knowledge for that, would I be able to get the services of a Tax consultant to guide me on that? Tax laws are different in different countries so my solution would be country specific, most probably for Pakistani citizens. Are Pakistani citizens literate enough to go for computer based software solutions for tax calculation? Do we have any existing solutions in the market for tax calculation? Does FBR provide any such facility, if so then why would someone like to buy mine? Can I provide more user friendly and precise interface for that matter?
After doing all the needed R&D and putting down the answers for above why’s and what’s, let’s say results are positive. What next? Would it be feasible? What comes under feasibility? To calculate feasibility I will consider following ingredients:
Scope: What should precisely be the scope of this product? All kinds of taxes? Or some specific taxes like income tax, wealth tax etc.
Interfaces: What different interfaces should I provide?
  • Simple desktop utility?
  • Web based online calculator?
  • A web service for any third party vendor?
Resources: What different resources would I need? How much of human resource utilization would it take to complete this product end to end? Then office infrastructure, electricity and power backups, Internet connections and towards the end I will need marketing resources to get the product out the door.
Cost: Cost would be determined based on the scope that I define the interfaces that I choose and accordingly resources that are needed.
Feasibility comes to a point where I can say “Yes” or “NO”. Does it fall within my budget and within the defined period of investment?
If finally I get a big “YES” I will go for it and setup a small facility, hire resources and start development of the product, will do my hard and will patiently wait for the outcome. My software house is up and running.
Now let’s talk about track 2, I don’t have much capital and I’m not willing to take risk associated with my innovation. I need earlier commitments from my clients before starting the development cycle. These conditions dictate me to go for Project oriented setup.

How to start such a setup?
There are two ways to do it; either I should have some references in the market from where I could get a project OR I should go for online options, where I could try bidding for online applications and utilities from sites like “rent-a-coder” etc.
If I could be hunting my own references in the local market, I need to be aware of pros and cons associated with this approach. Being a Pakistani national I know my local market is not very much software literate and/or computer literate so opportunities in the local market for a beginner would not be very encouraging.
Secondly the paying capacity of local market is not too good so I might not get rewarded for the effort which I will put in.
Third and more important issue, our local businessmen always considered “software automation” more of a luxury than a need so they don’t opt for it that easily but now situation is changing; people are getting acquainted with the “goods” of automation specifically the efficiency it brings in.
So keeping in mind these factors associated with the local market I will see if it meets what I need from it. If that’s sounds feasibly a fine start, I can try that out and meanwhile I would also keep building my profile for freelance sites to get myself into that business as well. Sites like “rentacoder.com” give us good opportunities to establish our self online. It might not usually be big order but usually going for a bunch of small orders will get you a good start if you are really putting your hard for it.
So summarizing the discussion whether you are going product oriented or project oriented, you need to plan well and estimate the risks associated with it. Otherwise going by the wind will not get you anywhere.

Sunday, November 20, 2022

Tuesday, November 15, 2022

Interfaces in Java

package inhert;
public class Inhert  {
 public interface person{
         void name(String n);
         void age(int a );
         void clas(int c);
    }
   
    public static class usman implements person{
    public  void name(String n){
        System.out.println("Usman name= "+n);
    }
    public void age(int a){
        System.out.println("Usman age= "+a);
    }
    public void clas(int c){
        System.out.println("Usman class= "+c);
    }
    }
   
    public static class usama implements person{
    public void name(String n){
        System.out.println("Usman name= "+n);
    }
    public void age(int a){
        System.out.println("Usman class= "+a);
    }
    public void clas(int c){
        System.out.println("Usman class= "+c);
    }  
    }
   
  
       public static void main(String[] args){
           usama obj=new usama();
           obj.name("Usama hussain");
           obj.age(20);
           obj.clas(10);
          
           usman obj1=new usman();
           obj1.name("Usman Siddique");
           obj1.age(21);
           obj1.clas(9);
}   }
================================
An interface is a reference type in Java, it is similar to class, it is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface.
Along with abstract methods an interface may also contain constants, default methods, static methods, and nested types. Method bodies exist only for default methods and static methods.
Writing an interface is similar to writing a class. But a class describes the attributes and behaviours of an object. And an interface contains behaviours that a class implements.
Unless the class that implements the interface is abstract, all the methods of the interface need to be defined in the class.
An interface is similar to a class in the following ways:
  • An interface can contain any number of methods.
  • An interface is written in a file with a .java extension, with the name of the interface matching the name of the file.
  • The byte code of an interface appears in a .class file.
  • Interfaces appear in packages, and their corresponding bytecode file must be in a directory structure that matches the package name.
However, an interface is different from a class in several ways, including:
  • You cannot instantiate an interface.
  • An interface does not contain any constructors.
  • All of the methods in an interface are abstract.
  • An interface cannot contain instance fields. The only fields that can appear in an interface must be declared both static and final.
  • An interface is not extended by a class; it is implemented by a class.
  • An interface can extend multiple interfaces.

Declaring Interfaces:

The interface keyword is used to declare an interface.

Sunday, November 6, 2022

Divide Content on multiple pages in PHP : Paging in PHP

Some time we have a lot of data like 600000 records and we want to show them but not all at a time so we use paging to divide them on separate pages in this post i will define how to use paging in PHP.
First we have to create a Database.


Database Name:Paging

Table:


CREATE TABLE `record` (
 
`Id` int(9) NOT NULL,

`Name` varchar(100) NOT NULL,

`Mobno` int(18) NOT NULL,

`Address` varchar(100) NOT NULL

) ;

And We put Dummy data on 100 records in it .
Now Retrieve that data.i use limit property in my query like
SELECT id,name,mobno,address from record limit 0,6

it will limit data in only 6 rows.
Now by using String Query's i create a hyper links containing page no and then on page load get them and use in limit value .


Formula: ( page_no - 1 ) * 6


Query String: <a href='usman.php?page=".$s1."'>".$s1."</a>"


Get Request:if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 


Total Records:
$sql1 = "SELECT COUNT(id) FROM record"; 
$result1 = $conn->query($sql1); 
$getresult = $result1->fetch_assoc(); 
$total = $getresult["COUNT(id)"];
$s=$total/6;



CSS Code For Style:

<style>
  span{padding:10px;margin:10px;
  bottom: 5%;position: fixed;}
  span a{margin: 20px;border: 1px solid green;padding: 10px;}
body{background-color: #eae;}
div{margin:5px auto;width: 50%;border: 5px solid;
background-color: skyblue; padding: 10px;}
div table{margin: auto;}
div table td{border: 5px solid green;}
</style>


PHP Full Code:

<?php
include "conn.php";
echo '<h1 style="text-align:center;">Pagging in PHP</h1>';
if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
$first = ($page-1) * 6;

$sql = "SELECT id,name,mobno,address from record limit $first,6" ;

$result = $conn->query($sql);

if ($result->num_rows > 0) {
while($row = $result->fetch_assoc())
 { 
echo "<div><table border=\"1\">";
echo    "<tr><th colspan=\"2\"width=200> Dummay Data For ".$row["id"]. "</th>";
echo    "<th rowspan=\"2\">";
echo    " Mobile No : ".$row["mobno"]."</th></tr>";
echo " <td>My Name: "  .$row["name"]. "</td>";
echo " <td>Yes My Name "  .$row["address"]. "</td></table></div>";
}} 

$sql1 = "SELECT COUNT(id) FROM record"; 
$result1 = $conn->query($sql1); 
$getresult = $result1->fetch_assoc(); 
$total = $getresult["COUNT(id)"];
$s=$total/6;
?>
<span>
<?php
for($s1=1;$s1<=$s;$s1++){
echo "<a href='usman.php?page=".$s1."'>".$s1."</a>";
}?>
</span>
<?php
$conn->close();
?>
 

Friday, November 4, 2022

Wednesday, November 2, 2022

OnLine Doctor Appointment System Project in PHP - Programming seekerzZ

Read Also:  


OnLine Doctor Appointment System Project in PHP,HTML,CSS,Ajax


This is the complete PHP project on online doctor appointment system using PHP,HTML,Ajax,Javascript,CSS,Jquery and SQL .

To Download source code of Online Doctor Appointment System inbox me on Facebook.

Download From Here


https://www.facebook.com/usman.siddique.7771

OnLine Doctor Appointment System Project in PHP

Wednesday, September 28, 2016

Simple Calculator using MATLAB

How to create Simple Calculator using MATLAB - Matlab for beginners

GUI Video is below the code 


function varargout = mycaltest(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @mycaltest_OpeningFcn, ...
                   'gui_OutputFcn',  @mycaltest_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
function mycaltest_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;

guidata(hObject, handles);


function varargout = mycaltest_OutputFcn(hObject, eventdata, handles) 
varargout{1} = handles.output;


function four_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'4');
set(handles.ans,'String',str);


function one_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'1');
set(handles.ans,'String',str);

function point_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'.');
set(handles.ans,'String',str);

function seven_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'7');
set(handles.ans,'String',str);

function zero_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'0');
set(handles.ans,'String',str);

function two_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'2');
set(handles.ans,'String',str);

function five_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'5');
set(handles.ans,'String',str);

function eight_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
% it will take the value of ans (ans is our static text
str = strcat(str,'8');
%it will concatinate 8 with the privues string
set(handles.ans,'String',str);
%and it will again set the new value to ans static text 

function equal_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
%it will take the value 
str = eval(str);
%the eval function solve the string or evalutae the string
set(handles.ans1,'String',str);
%after evaluation the ans was 
      %shown in the above static text ans1.

function three_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'3');
set(handles.ans,'String',str);

function six_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'6');
set(handles.ans,'String',str);

function nine_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'9');
set(handles.ans,'String',str);

function div_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'/');
set(handles.ans,'String',str);

function add_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'+');
set(handles.ans,'String',str);

function sub_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'-');
set(handles.ans,'String',str);

function mul_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'*');
set(handles.ans,'String',str);

function clear_Callback(hObject, eventdata, handles)
set(handles.ans1,'String','');
set(handles.ans,'String','');







Read Also: