Skip to content

Instantly share code, notes, and snippets.

View deepanshumehtaa's full-sized avatar
💭
If Good things are not coming to you, Snatch them™

Deepanshu mehta deepanshumehtaa

💭
If Good things are not coming to you, Snatch them™
View GitHub Profile
@deepanshumehtaa
deepanshumehtaa / linear_regression_cdac.ipynb
Created February 14, 2020 01:34
Linear_Regression_cdac.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@deepanshumehtaa
deepanshumehtaa / .env
Created December 19, 2020 13:25 — forked from moonwalkerpoday/.env
Djangoで環境変数?ならdjango-environを使おうか。 ref: https://qiita.com/moonwalkerpoday/items/9da47dda80d3ddac9a62
# MySQL
DATABASE_URL=mysql://hogehoge:[email protected]:3306/db_name
# AWS Settings
DJANGO_AWS_S3_BUCKET_NAME=huga-storage
DJANGO_AWS_ACCESS_KEY=xxxxxxxxxxxxxxxxxx
DJANGO_AWS_SECRET_KEY=xxxxxxxxxxxxxxxxxx
def list(self, request, *args, **kwargs):
"""GET the List of Obj"""
qs = self.paginate_queryset(self.get_queryset())
serializer_data = self.serializer_class(qs, many=True).data
paginated_data = self.get_paginated_response(serializer_data).data
return Response(data=paginated_data, status=status.HTTP_200_OK)
class XYZAPIView(APIView):
"""
src: https://github.com/bitsy-ai/printnanny-webapp/blob/04bb214fc83f1f860b1b2aa157dd2e90b610a06f/print_nanny_webapp/subscriptions/views.py#L19
"""
from django.http.response import JsonResponse
from typing import Any, Dict
from django.apps import apps
from django.views.generic.base import RedirectView
from django.contrib.auth.mixins import LoginRequiredMixin
import json, logging
import stripe
m2m
class Post(models.Model):
slug = models.SlugField(max_length=200, unique=True)
likes = models.ManyToManyField(User, related_name='blogpost_like', blank=True)
post = get_object_or_404(Post, slug=slug)
if post.likes.filter(id=request.user.id).exists():
post.likes.remove(request.user)
Uppercase in pycharm: Ctrl+Shift+U
How to Unstage changes?
>> git reset .
>> all red
Remove all unstage changes (remove changes in red)
>> git clean -f
# Best
def lengthOfLongestSubstring(self, s: str) -> int:
l = 0
r = 0
occ = {}
mx = 0
while r < len(s):
if s[r] not in occ:
occ[s[r]] = 1
r += 1
@deepanshumehtaa
deepanshumehtaa / Sort Merge Quick Heap.py
Last active March 20, 2024 05:27
Sort Merge Quick Heap
class Solution:
"""BEST"""
def merge(self, li1, li2):
merged = []
i, j = 0, 0
while i < len(li1) and j < len(li2):
if li1[i] <= li2[j]:
merged.append(li1[i])
@deepanshumehtaa
deepanshumehtaa / Efleet_gsheet_script.py
Last active January 20, 2025 08:28
Efleet_gsheet_script.py
"""
Author: Deepanshu Mehta
Script to Fetch data from EV Gsheets and Populate them into db
it requires `car-master-sheet.json`
python -m venv env_ev_allocation
source env_ev_allocation/bin/activate
pip3 install -r requirements.txt
python3 EV_allocation_data_dump.py
to check for psql:
@deepanshumehtaa
deepanshumehtaa / custom_pagination.py
Last active July 4, 2023 15:21
Custom Pagination
import math
from django.db import connection
from rest_framework.response import Response
class CustomPagination(object):
"""
author: Deepanshu Mehta