This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var junction_font = new FontFace('Junction Regular', 'url(fonts/junction-regular.woff)'); | |
| junction_font.load().then(function(loaded_face) { | |
| document.fonts.add(loaded_face); | |
| document.body.style.fontFamily = '"Junction Regular", Arial'; | |
| }).catch(function(error) { | |
| // error occurred | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| // Use IntelliSense to learn about possible attributes. | |
| // Hover to view descriptions of existing attributes. | |
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |
| "version": "0.2.0", | |
| "configurations": [ | |
| { | |
| "name": "Debugpy attach", | |
| "type": "python", | |
| "request": "attach", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io | |
| import cv2 | |
| import base64 | |
| import numpy as np | |
| from PIL import Image | |
| # Take in base64 string and return PIL image | |
| def string_to_image(base64_string): | |
| imgdata = base64.b64decode(base64_string) | |
| return Image.open(io.BytesIO(imgdata)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function clearNextInterest(){ | |
| const selector = "div > input[type='checkbox']:checked"; | |
| const next = document.querySelector(selector); | |
| if(next){ | |
| next.scrollIntoView(); | |
| next.click(); | |
| setTimeout(clearNextInterest,500) | |
| }; | |
| }; | |
| clearNextInterest(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class HttpMethod { | |
| static GET = "GET"; | |
| static POST = "POST"; | |
| static PUT = "PUT"; | |
| static DELETE = "DELETE"; | |
| } | |
| const request = async ({endpoint, params, method = HttpMethod.GET}) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Reference: https://adamj.eu/tech/2021/05/13/python-type-hints-how-to-fix-circular-imports/ | |
| from __future__ import annotations | |
| from typing import TYPE_CHECKING | |
| if TYPE_CHECKING: | |
| from models import Book | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from functools import wraps, partial | |
| import logging | |
| def attach_wrapper(obj, func=None): # Helper function that attaches function as attribute of an object | |
| if func is None: | |
| return partial(attach_wrapper, obj) | |
| setattr(obj, func.__name__, func) | |
| return func | |
| def log(level, message): # Actual decorator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {typeof tableOfContents.items === "undefined" ? null : ( | |
| <Toc> | |
| <h3 className="uppercase">Table of contents</h3> | |
| <ContentsList items={tableOfContents.items} /> | |
| </Toc> | |
| )} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # reference: https://stackoverflow.com/questions/11014262/how-to-create-an-immutable-dictionary-in-python?utm_source=pocket_mylist | |
| class imdict(dict): | |
| def __hash__(self): | |
| return id(self) | |
| def _immutable(self, *args, **kws): | |
| raise TypeError('object is immutable') | |
| __setitem__ = _immutable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| from django.utils import timezone | |
| from django.db.models.query import QuerySet | |
| class SoftDeletionQuerySet(QuerySet): | |
| def soft_delete(self): | |
| return super(SoftDeletionQuerySet, self).update(deleted=timezone.now()) | |
| def restore(self): | |
| return super(SoftDeletionQuerySet, self).update(deleted=None) |