Skip to content

Instantly share code, notes, and snippets.

View 4k45hv3rm4's full-sized avatar
💻
If world were perfect . It Wouldn't be...

Aakash Verma 4k45hv3rm4

💻
If world were perfect . It Wouldn't be...
View GitHub Profile
@4k45hv3rm4
4k45hv3rm4 / copilot_overview.py
Created June 2, 2023 06:24
Copilot Overview
# Copilot Overview
Copilot is an AI-powered coding assistant that provides suggestions based on the context it sees. It takes into account the files you've opened and interacted with, installed packages and libraries, the code you're writing, and comments you add.
## Installing the Extension (Github Copilot)
To use Copilot, you first need to install the Copilot extension in your code editor. You can install Github Copilot (In VsCode).
## Dealing with Repetitive Code
Copilot is especially helpful when it comes to handling repetitive code. By describing your needs in comments, Copilot can provide suggestions based on the provided description. These suggestions can be customized to ensure they work as expected.
### Examples
@4k45hv3rm4
4k45hv3rm4 / common.js
Last active July 17, 2021 06:24
Validate Mobile Number function
validateMobile(phone) {
const pattern = /^([0]|\+91)?[6789]\d{9}$/; //Regex Valid for all Indian mobile numbers
if (!isNaN(phone) && phone.match(pattern) ) return true;
return false;
}
},
@4k45hv3rm4
4k45hv3rm4 / models.py
Created January 31, 2021 18:05
Django user model for signals
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
class Profile(models.Model):
"""
User Profile
"""
user = models.OneToOneField(User, on_delete=models.CASCADE)
@4k45hv3rm4
4k45hv3rm4 / file.py
Last active September 8, 2020 06:21
install pipenv
Install git ( check git --version)
Create an Heroku account
Install Heroku CLI
Login heroku
Copy the project in a seperate folder
Create a virtual enviroment
Run manage.py runserver not gonna run due to unmigrated files
check pip freeze if nothing installed
Check which version django,requests or other libraries you have or need to install it.
from django.urls import path
from account.views import (
home,
login_view,
logout_view,
account_view
registration_view,
)
{% extends 'base.html '%}
{% block content %}
<div class="col-md-6 m-auto p-4 text-white" style="justify-content: center; align-items: center">
<p>Account</p>
<form method="post">
{% csrf_token %}
{%for field in account_form %}
<p>
{% extends 'base.html' %}
{%block title %}Register{% endblock %}
{% block content %}
<div class="container jumbotron">
{% if registered %}
<strong>Thank You for Registering with Us.</strong>
<a href="{% url 'index' %}" class="btn-link btn">Return to the HomePage</a><br>
{% extends 'base.html' %}
{% load static %}
{%block title %}Login{% endblock %}
{% block content %}
<div class="container jumbotron text-justify">
<h1 class="display-4">Login Here </h1>
<form id="login_form" class="form" method="post" action="{% url 'login' %}">
{% csrf_token %} <!-- for security reasons -->
{% extends 'base.html' %}
{% load static %}
{%block title %}Login{% endblock %}
{% block content %}
<div class="container jumbotron text-justify">
<h1 class="display-4">Login Here </h1>
<form id="login_form" class="form" method="post" action="{% url 'login' %}">
<!--important for security reasons -->
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">