Skip to content

Instantly share code, notes, and snippets.

View Shrestha7's full-sized avatar
:octocat:
Working from home

Swastik Shrestha Shrestha7

:octocat:
Working from home
View GitHub Profile
@Shrestha7
Shrestha7 / GithubLicenseGuide.md
Last active June 5, 2024 11:27
github license guide

How to choose a license for your GitHub repository

“Explain me like I’m 5!” Imagine you made a cool toy, and you want to share it with your friends. But you also want to set some rules for how they can play with it. These rules are like licenses for open source projects. Here are some popular ones:

  • public domain: This is like saying, "Play with my toy however you like! You can even say it's your own."

  • mit license: You say, "You can play with my toy and even change it, but you have to say I made the first version."

@Shrestha7
Shrestha7 / main.py
Created April 9, 2023 15:33
To add a .env file outside the .exe file when using PyInstaller, you can use the --add-data option to include the .env file in the distribution. Assuming that your .env file is located in the root directory of your project, and you want to include it in the same directory as the PyInstaller-generated .exe file, you can use the following command:
pyinstaller --add-data=".env;." myscript.py
# This command tells PyInstaller to include the .env file in the distribution, and to place it in the same directory as the .exe file.
# Note that the --add-data option takes two arguments separated by a semicolon: the first argument is the path to the .env file, and the second argument is the destination directory for the file. In this case, the destination directory is the current directory, denoted by the . symbol.
# After running this command, PyInstaller will generate a new directory containing the .exe file and the .env file, as well as any other necessary files for your script to run.
@Shrestha7
Shrestha7 / consumeapi.py
Last active February 23, 2022 01:54
consume api in python
import requests
import pprint
url='https://'
response = request.get(url)
pprint.pprint(response.json())
@Shrestha7
Shrestha7 / models.py
Created October 19, 2021 11:32
file handling in models
from pathlib import Path
from typing import Reversible
from django.db import models
from os import listdir, path
from os.path import isfile, join
import os
import glob
# Create your models here.
class insp(models.Model):
@Shrestha7
Shrestha7 / models.py
Created October 18, 2021 08:58
listing the path of directory templates
from pathlib import Path
from typing import Reversible
from django.db import models
from os import listdir
from os.path import isfile, join
import os
# Create your models here.
class insp(models.Model):
@Shrestha7
Shrestha7 / book_delete.html
Created November 13, 2020 08:18
Django crud with ajax delete part 4
{% load crispy_forms_tags %}
<form method="post" data-url="{% url 'book_delete' book.id %}" class="delete-form">
{% csrf_token %}
<div class="modal-header">
<h5 class="modal-title" >Delete Book</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
@Shrestha7
Shrestha7 / book_list.html
Created November 13, 2020 08:14
Django crud with ajax update part 3
{% extends 'base.html' %}
{% block content %}
<h1 class="page-header">Books</h1>
<button class="btn btn-primary show-form" data-url="{% url 'book_create' %}">
<span class="glyphicon glyphicon-plus"></span>
New Book
</button>
<table class="table" id="book-table">
<thead>
@Shrestha7
Shrestha7 / book_create.html
Created November 13, 2020 07:12
Django crud with ajax create part 2
{% load crispy_forms_tags %}
<form method="post" data-url="{% url 'book_create' %}" class="create-form">
{% csrf_token %}
<div class="modal-header">
<h5 class="modal-title" >Create Book</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
@Shrestha7
Shrestha7 / base.html
Created November 13, 2020 07:08
Django crud with ajax part 1
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bookstore</title>
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
</head>