Create a theme directory

Go to /app/design/frontend

1.Declare your theme


<?xml version="1.0" encoding="UTF-8"?>
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
     <title>My First Theme</title> <!-- your theme's name -->
     <parent>Magento/blank</parent> <!-- the parent theme, in case your theme inherits from an existing theme -->
     <media>
         <preview_image>media/preview.jpg</preview_image> <!-- the path to your theme's preview image -->
     </media>
 </theme>

2.Add registration.php

<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/stark/my-first-theme',
    __DIR__
);

Magento 2 Index Management

|| Magento2 reindex on local server

You can’t reindex from admin web. you have to reindex from command line

  1. go to command line from magento2 installation root directory

  2. php bin/magento indexer:reindex

if you got any error like ‘php’ is not recognized as an internal or external command,

so you need to Add E:\xampp\php to your PATH Environment Variable.

final command:
E:\xampp\htdocs\magento2>php bin/magento indexer:reindex

git

1. git is a vms/vcs version control system
2. git so fast, off line work
3. most necessity of git (code revision)

Keep in mind that it takes
	->commit(লোকাল এ যে কাজগুলি করেছেন সেগুলোকে রেকড করা) 
	->push 	(আপনি লোকাল এ যে কাজগুলি করেছেন সেগুলোকে সারভারে তোলা)
	->pull	(সারভারে থেকে কাজগুলি লোকাল এ নামানো)
	
git some of tools
	-> status		[check]
	-> add			[file add to git]
	-> diff			[if you want to see which line is modified]
	-> log			[if you want to see whole day work]
	-> show			[show up by individual hash id]
	-> checkout		[How was the whole project, if you want to go there]
	-> reset		
	-> reflog
	-> branch
	-> merge
	-> stash

Git bash cmd: 

Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark
$ ls							[just check, is there have any file?]


$ git init						[git initialized]
Initialized empty Git repository in E:/xampp/htdocs/nedstark/.git/


$ ls -al						[list of all file]


$ echo "" > new.txt			   [new file include in git]


$ git status
Untracked files:
nothing added to commit but untracked files present (use "git add" to track)


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git add new.txt				[file add to git]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git status
        new file:   new.txt

		
Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git commit -m "added some text"		[changed file to be record]
 
 
Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git status
On branch master
nothing to commit, working directory clean


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git status
        modified:   new.txt

		
$ git diff							[if you want to see which line is modified]
diff --git a/new.txt b/new.txt
 Hello world
+
+
+Hello jupiter


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git commit -m "added some more text" new.txt


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git status
On branch master
nothing to commit, working directory clean


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git log						[if you want to see whole day work]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git show 95fdea				[individual hash id]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git checkout 95fdea			[How was the whole project, if you want to go there]
Note: checking out '95fdea'.


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark ((7588b3e...))
$ cat new.txt					[if you want to see file content]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark ((7588b3e...))
$ git checkout master			[if you want to back last commit]
Switched to branch 'master'


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git log


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git reset --soft 95fdea		[soft reset]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git diff HEAD					[if you want to see changed line]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git reset --hard 95fde		[Hard reset]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git reflog					[if you want to back reset file]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git reset HEAD@{1}
Unstaged changes after reset:
M       ami.txt


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git reset --hard
HEAD is now at 9999cf3 Three


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git stash						[Temporary save]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git stash pop					[return code from stash]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git stash list				[list of stash]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git stash clear				[if you want to clear stash list]


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git remote add origin https://github.com/md-ataur/git-test.git   

								
Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git remote show


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git remote show origin


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git push origin master
Username for 'https://github.com': md-ataur


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git pull origin master


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ echo "" > .gitignore


Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git status
On branch master
Untracked files:
     .gitignore				[edit page and put this *.zip]



Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git add new.zip
The following paths are ignored by one of your .gitignore files:
new.zip
Use -f if you really want to add them.

Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git add .gitignore

Dell@Dell-PC MINGW64 /e/xampp/htdocs/nedstark (master)
$ git commit -am "gitignore"




File Download

/* download.php */

<?php

if (isset($_GET['file_name'])) {
    $filename = $_GET['file_name'];
} else {
    $filename = NULL;
}

$err = "Sorry, the file you are requesting is unavailable";

if (!$filename) {
    echo $err;
} else {
    $path = 'uploads/' . $filename;
    if (file_exists($path) && is_readable($path)) {
        $size = filesize($path);
        header('Content-Type: application/octet-stream');
        header('Content-Length: ' . $size);
        header('Content-Disposition: attachment; filename=' . $filename);
        header('Content-Transfer-Encoding: binary');

        $file = @fopen($path, 'rb');
        if ($file) {
            fpassthru($file);
            exit;
        } else {
            echo $err;
        }
    }
}
?>

File upload & Delete

<?php
$conn = mysqli_connect("localhost", "root", "", "fresh");

/* This is for delete file */
/*
if (isset($_REQUEST['file_name'])) {
    $filename = $_REQUEST['file_name'];
    $query = mysqli_query($conn, "DELETE FROM user WHERE profile_image='$filename'");
    if (mysqli_affected_rows($conn) > 0) {
        @ unlink("uploads/$filename");
        echo "Your file succefully delete";
    } else {
        echo "Your file not delete";
    }
}
 * */



/* file upload from this here */
if (isset($_FILES['filefield'])) {

    $name = $_REQUEST['name'];
    $file = $_FILES['filefield'];
    //echo "<pre>";
    //print_r($file);

    $upload_directory = "uploads/";

    $allowed_extensions = array("gif", "jpg", "jpeg", "mp3", "mp4", "tiff", "bmp", "doc", "docx", "ppt", "pptx", "txt", "pdf");
    $ext = substr($file['name'], strrpos($file['name'], '.') + 1);
    if (!in_array($ext, $allowed_extensions)) {
        die('only "gif", "jpg", "jpeg", "mp3", "tiff", "bmp", "doc", "docx", "ppt", "pptx", "txt", "pdf" files allowed to upload');
    }

    $max_file_size = 10485760;
    if ($file['size'] >= $max_file_size) {
        echo "Only the file size less than $max_file_size mb allowed";
    }

    $path = md5(microtime()) . '.' . $ext;

    if (move_uploaded_file($file['tmp_name'], $upload_directory . $path)) {

        // This query file name insert in to the database
        $query = mysqli_query($conn, "INSERT INTO user SET name='$name', profile_image='$path' ");

        //if (move_uploaded_file($file['tmp_name'], $upload_directory . $file['name'])) {
        echo "Your file successfully uploaded";
    } else {
        echo "The file can't moved";
    }
}
?>
/* file upload finished */

<form action="" method="post" enctype="multipart/form-data">
    <label>Name
        <input id="name" type="input" name="name" />
    </label>

    <label>Upload File
        <input id="filefield" type="file" name="filefield" />
    </label>

    <label>
        <input id="Upload" type="submit" name="Upload" value="Submit" />
    </label>



    <!-- This part is file name fetch from database and show up table -->

    <table width="700" border="1">
        <tr>
            <td>Name</td>
            <td>File Name</td>
            <td>Image</td>
        </tr>

        <?php
        /*
        $query = mysqli_query($conn, "SELECT name, profile_image FROM user");
        $hold = mysqli_fetch_all($query, MYSQLI_ASSOC);
        //echo "<pre>";
        //print_r($show);
        foreach ($hold as $data) {
            extract($data);
            ?>     
            <tr>
                <td><?php echo $name; ?></td>
                <td><?php echo $profile_image; ?></td>
                <!--<td><img src="uploads/<?php //echo $profile_image;?> "/></td>-->
                <td>
                    <?php
                    $file_ext = substr($profile_image, strrpos($profile_image, '.') + 1);
                    if ($file_ext == 'jpg') {
                        ?>
                        <img src = "uploads/<?php echo $profile_image; ?>" width = "100" />
                        <?php
                    }

                    if ($file_ext == 'pdf') {
                        ?>
                        <a href="uploads/<?php echo $profile_image; ?>"><img src = "uploads/pdf.jpg" width = "100" /></a>
                        <?php
                    }
                    if ($file_ext == 'docx') {
                        ?>
                        <a href="uploads/<?php echo $profile_image; ?>"><img src = "uploads/docx.jpg" width = "100" /></a>
                        <?php
                    }
                    ?>
                    <a href="download.php?file_name=<?php echo $profile_image; ?>"><input type="button" value="Download" name="download"></a>
                    <a href="upload.php?file_name=<?php echo $profile_image; ?>"><input type="button" value="Delete" name="delete" /></a>     
                </td>

            </tr>
            <?php
        }
        
        */
        ?>
    </table>

</form>

strpos, strrpos, substr


$string = "search the position of the first, search the position of the last inside the string";
$search = "position";
$pos = strpos($string, $search);
echo $pos;
echo "<br>";
echo "<br>";

$pos2 = strrpos($string, $search);
echo $pos2;
echo "<br>";
echo "<br>";

$return = substr($string, $pos);
echo $return;

echo "<br>";
echo "<br>";
$return2 = substr($string, $pos2);
echo $return2;

echo "<br>";
echo "<br>";
//Find the position of the last occurrence of "php" inside the string:
echo strrpos("I love php, I love php too!","php");

echo "<br>";
echo "<br>";

//Find the position of the first occurrence of "php" inside the string:
echo strpos("I love php, I love php too!","php");

Image uploading Problem

|| File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini file

|| solved: Go to the file directory public_html wp-admin then put the php.ini file, and include following code


upload_max_filesize = 64M;
post_max_size = 32M;
safe_mode = off;

Black and White color on hover effect for picture


/* This is for html file

<div class="image-1">
	<img src="<?php echo $this->getSkinUrl('images/product1.jpg');?>" />
</div>

*/

.image-1 {
  filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\' filterRes=\'800\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+ */
    filter: gray; /* IE6-9 */
    -webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */
    -webkit-backface-visibility: hidden; /* Fix for transition flickering */
    -webkit-transition: all 0.5s ease;
       -moz-transition: all 0.5s ease;
        -ms-transition: all 0.5s ease;
         -o-transition: all 0.5s ease;
            transition: all 0.5s ease;
}

.image-1:hover {
 filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\' filterRes=\'800\'><feColorMatrix type=\'matrix\' values=\'1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0\'/></filter></svg>#grayscale");
    -webkit-filter: grayscale(0%);
}

/* example westects site */