Saturday, 6 June 2020

Expense Handler Application with advance technologies

Budget Planner 

One of the application developed with Ionic 4 and Python-Flask. 



Here we have used a new technologies to understand how it works and the advantages.

Saturday, 25 April 2020

Sample code for Authorization in Python

Achieving Authorization using JWT in Python


Here we are going to access an get API using python authorization by checking the username, password and generating JWT token.

kindly install below packages to proceed with the code.
install flask_jwt 
install flask_restful 
install flask 

once the above steps has been completed, we will be created three files 
app.py - main application file
security.py - security file
user.py - user

Code: app.py


Code: security.py


Code: user.py



If you need further explanation, kindly mention in the comments so that i can give a brief on code flow.
   



Wednesday, 15 April 2020

Windows BCD error code 0x0000098


Windows BCD error and it works and your files will be safe

File:\BCD
Error code: 0x0000098


Note:
If you are using windows genuine version kindly insert the installation media and follow the below steps:
-Start up your computer with the USB or DVD Windows 10 recovery media.
-Select your language time format and keyboard and click next.
-Click (repair now) then (troubleshoot), windows will automatically try to repair your system.

If you are using non-licensed version:


Start your computer and enter F11 and select the trouble shoot option



select Command prompt and enter the below commands:

C:\diskpart 
and press enter.

DISKPART> list disk 
and press enter to know which drive to target.

DISKPART> sel disk 0 
assuming your drive with windows is disk 0 and press enter.

DISKPART> list vol 
to view all the partitions and press enter.

Select the EFI partition volume which is using FAT32 next to the NTFS volume

DISKPART> sel vol 2
to select the fat32 EFI volume and press enter.

DISKPART> assign letter=m 
to assign an arbitrary drive letter to it and press enter.

DISKPART> Exit 
to exit the diskpart tool and press enter.


> cd /d m:\EFI\Microsoft\Boot\  
press enter

> bootrec /fixboot 
press enter

> ren BCD BCD.old 
and enter to backup the existing Boot Configuration Data
(BCD) store.

> bcdboot c:\Windows /l en-us /s m: /f ALL 
press enter to recreate the BCD store.

Close the command prompt windows then turn off pc and restart the computer.



Sunday, 12 April 2020

parameters are of unsupported type sqlite python

Details:

This is one of the common error a beginner will be facing when he is working on Python and SQLite bridging. Below is a scenario provided for better understanding with example.

Error:

insert_data = "INSERT INTO users VALUES (?, ?, ?)"
    user = [
        {1"Ram""abc@123"},
        {2"Rahim""wel@123"},
        {3"Raju""pass@123"}
    ]
    cursor.executemany(insert_data, user)

When you run the above code you will get the error:
(venv) D:\python\Course_sample\source_database>python dataBase.py
parameters are of unsupported type

This is because when ever we try to insert into database from python, they data has to be a tuple.
In the above code you can see list of set which we try to insert.

Fixed:

#insert data query
    insert_data = "INSERT INTO users VALUES (?, ?, ?)"
    user = [
        (1"Ram""abc@123"),
        (2"Rahim""wel@123"),
        (3"Raju""pass@123")
    ]
    cursor.executemany(insert_data, user)

The above code will get executed and the data will get inserted into the database properly.

Sunday, 5 April 2020

Lambda in python with example

Lambda:

In the below example you can see two methods have been created and clearly explained to show how Lambda works

friends =  [
    {"name""Ram""age":26}, 
    {"name""Raju""age":30}
]

#method with for loop 
def findAge(name):
    for friend in friends:
        if(friend["name"== name):
            return friend
    
    return f"{name} not found"

#method with Lambda expression 
def findAgeLambda(name):
    friend = next(filter(lambda x: x["name"== name, friends))
    return friend

print(findAge("Ram"))
print(findAgeLambda("Raju"))  

Output:

{'name': 'Ram', 'age': 26}
{'name': 'Raju', 'age': 30}

Difference between Set, List and Tuple in python


Set:
  • (regressive)unordered list of data
  • Mutable unordered(regressive) set of values
  • initialized using emptySet = set()
  • Every element is unique
  • A set is created by placing all items inside {}
  • Eg: my_set = {1, 2, 3}
List:
  • Ordered list of data
  • Mutable ordered set of values
  • Initialized using list = []
  • can contain duplicate
  • A list is created by placing all items inside []
  • Eg: my_list = [1,2,3]
Tuple:
  • Ordered list of data
  • Immutable set of values
  • Initialized using tuple = ()
  • can contain duplicate
  • A tuple is created by placing all items inside ()
  • Eg: my_tuple = (1,2,3)



class composition in python with example

Composition is a concept that models a has a relationship. It enables creating complex types by combining objects of other types. This means that a class Composite can contain an object of another class Component. This relationship means that a Composite has a Component.

Example:

class Garage:
    def __init__(self*cars):
        self.cars = cars

    def __str__(self):
        return (f"Total {len(self.cars)} cars in the Garage")

class Cars:
    def __init__(selfnameyear):
        self.name = name
        self.year = year

    def __str__(self):
        return ("{} is moving to Garage in {}".format(self.name, self.year))


car = Cars("Ferrari""2019")
car2 = Cars("Rolls""2020")
car3 = Cars("Benz""2021")
garage = Garage(car, car2, car3)

print(car)
print(car2)
print(car3)
print(garage)

Output:
Ferrari is moving to Garage in 2019
Rolls is moving to Garage in 2020
Benz is moving to Garage in 2021

Total 3 cars in the Garage

Expense Handler Application with advance technologies

Budget Planner  One of the application developed with Ionic 4 and Python-Flask.  Ionic 4 code:  https://github.com/logeshbuiltin/Expense...