Monday, 6 July 2020

Buy amazon Products

Sunday, 19 February 2017

Simple Shell script to install and run your flask application for first time.

Simple shell script to clone your flask app , installing requirements, activating virtual environment and running the application.
Fork me on GitHub


echo "please enter your repo link" #input your repo link
read input_variable  #Read input
echo $input_variable
gitdir=`basename $input_variable .git`

if  [[ ! -d $CURRENT_DIR/$gitdir ]]
git clone $REPOURL 
elif [[ ! -d $CURRENT_DIR/$gitdir/.git ]]
mv CURRENT_DIR/$gitdir CURRENT_DIR/$gitdir"_backup" 
git clone $REPOURL
cd $CURRENT_DIR/$gitdir
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

Python Simple Flask Redis Tutorial

A simple Flask Redis Tutorial

Install requirements : flask, redis

  • Install virtual environment:  sudo apt-get install python3-venv
  • Creating the python virtual environment:  python3 -m venv venv
  • Add the root of the repository to the python path upon virtual environment activation: echo "$(pwd)/src" > redis-venv/lib/python3.5/site-packages/MY_VENV_PYTHONPATH.pth
  • Activate your python virtual environment:  . venv/bin/activate  Note: To remove the virtual environment from your shell: deactivate
  • Installing required python modules from newly created virtual environment:  Activate your python virtual environment if not already active.  pip install -r requirement.txt
  • Run the app  python

Flask Redis sample application Git Source Code

from flask import Flask, jsonify
import redis
import json

app = Flask("redis")

def index():    
    #value to save in redis 
    value_to_set = "shiva"
    #set value to key
    redis_db.set('name', value_to_set)   
    return json.dumps(redis_db.keys())

if __name__ == "__main__":
    redis_db = redis.StrictRedis(host="localhost", port=6379, db=0)

PHP Form submit without java script and submit button

Submit a form without submit button and  javascript submit

We mostly prefer php form submit either using javascript or normal submit.

But we can submit a form without submit button and  javascript

have a look at the below code


if(isset($_POST['submit_x']) && isset($_POST['submit_x']))
      echo $_POST['first_name'];
      echo $_POST['last_name'];

      // Save logic


<form method="post">
<lable>First Name</lable>
<input type="text" name="first_name" >

<lable>Last Name</lable>
<input type="text" name="last_name" >

<input type="image" name="submit"/>

Saturday, 10 January 2015

Php for each with comma separator except last

Sometimes we write a logic to show comma separated data. But the challenge is not to append comma to the last value.
We can do this by using next() function:
$arr = array('tvs','hero','honda','bajaj');
$copy = $arr;
foreach ($arr as $val) {
    echo $val;
    if (next($copy )) {
        echo ','; // Add comma for all elements instead of last

Friday, 7 November 2014

How to read image Using Jquery & Html5

How to read image  using jquery & html5

File reader API is used to read a file from your local hard drive

We can find Atricle  about File reader



<input id="imageread" type="file" />
<canvas id="img"></canvas>

Jquery Code :

<script src=""></script>
<script type="text/javascript">  $('input').change(function() {     var readimg = new FileReader;     readimg.onload = function() {         var img = new Image;         img.onload = function() {             var c=document.getElementById("img");             var ctx=c.getContext("2d");             ctx.drawImage(img,0,0,200,180);                 }         img.src = readimg.result;                 };      readimg.readAsDataURL(this.files[0]);    }); </script>

Monday, 3 November 2014

Add Extra Field Like Google Plus

Jquery code to add extra field using jquery.



<div class='extdiv'>
<input type="text" class="addmore"  />


<script src=""></script>
$(document).on("keyup",".extdiv .addmore",function(){
    var dynamic = $(this).attr("class");
    var countoftext = $("."+dynamic).length;  // count of entered value
    var nextcount = $(this).parent(".extdiv").nextAll(".extdiv").length; // finding next class count
    if(this.value.length >= 1 && nextcount == 0 )  // if length of textbox values greate than or equal to one and nextdiv class count is equal to zero
        $(this).after("<button>remove</button>"); // appending remove button to that field
        var extrabox = "<div class='extdiv'><input type='text' class= 'addmore' /></div>" // creating required field
        $(this).parent(".extdiv").after(extrabox); // appending