Skip to content

Instantly share code, notes, and snippets.

View mentix02's full-sized avatar
💻
coding away

Manan mentix02

💻
coding away
View GitHub Profile
from typing import Dict
from pprint import pprint
def parse_dataset(filename: str) -> Dict[str, str]:
data = {}
with open(filename) as f:
for line in f:
line = line.rstrip()
if line.startswith(">"):
<!DOCTYPE html>
<html lang="en">
<head>
<title>DJ Book Search</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.css" />
</head>
<body>
@mentix02
mentix02 / views.py
Last active February 11, 2021 07:09
from django.views import View
from django.http import JsonResponse
from django.views.generic import TemplateView
from book.search import search
class IndexView(TemplateView):
template_name = 'index.html'
from typing import Dict, List, Union
from django.conf import settings
from requests import get
from urllib.parse import urlencode
BASE_URL = 'https://www.googleapis.com/books/v1/volumes'
DEFAULT_THUMBNAIL = {'thumbnail': 'https://bit.ly/2NG0A8J'}
from django.conf import settings
from django.dispatch import receiver
from django.db.models.signals import post_save
from rest_framework.authtoken.models import Token
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs):
if created:
a {
color: blue;
}
.link {
color: blue;
cursor: pointer;
text-decoration: underline;
}
import React from "react";
import { useUsername } from "../store/auth/hooks";
function Account() {
const username = useUsername();
return <h2>Welcome, {username}</h2>;
}
@mentix02
mentix02 / auth.ts
Last active December 2, 2020 01:17
interface TokenResponse {
token: string;
}
export interface Credentials {
username: string;
password: string;
}
const BASE_URL = "http://localhost:8000";
import React, { useState } from "react";
import { Redirect } from "react-router-dom";
import { useDispatch } from "react-redux";
import { logIn } from "../store/auth/actions";
import { Credentials, getToken } from "../api/auth";
import { useAuthenticated } from "../store/auth/hooks";
function Login() {
import React from "react";
import { Route, Redirect } from "react-router-dom";
import { useAuthenticated } from "../store/auth/hooks";
function PrivateRoute({
children,
...rest
}: {
children: JSX.Element | JSX.Element[];