Skip to content

Instantly share code, notes, and snippets.

View data-scientist-ml1's full-sized avatar

Data Scientist data-scientist-ml1

  • Lahore, Pakistan
View GitHub Profile
@data-scientist-ml1
data-scientist-ml1 / serializers.py
Created December 18, 2023 14:23 — forked from orehush/serializers.py
DRF simple JWT logout flow
from django.utils.text import gettext_lazy as _
from rest_framework import serializers
from rest_framework_simplejwt.tokens import RefreshToken, TokenError
class RefreshTokenSerializer(serializers.Serializer):
refresh = serializers.CharField()
default_error_messages = {
'bad_token': _('Token is invalid or expired')
}
@data-scientist-ml1
data-scientist-ml1 / Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015.md Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015. Distillation of knowledge gained from a decade of Python consulting, Python training, code reviews, and serving as a core developer. (https://www.youtube.com/watch?v=wf-BqAjZb8M)

Raymond Hettinger's professional at doing code review and architecture review

P vs. NP. Pythonic vs. Non-Pythonic.

How to make use of PEP 8

  1. Golden rule of PEP-8: PEP-8 onto yourself. PEP 8 is style guide, not a law book.
  2. Care about intelligibility, not simply visually better
  3. Transforming (Java) API to pythonic ones

Why not PEP 8

@data-scientist-ml1
data-scientist-ml1 / VSCode-turn-off-auto-complete.json
Last active December 13, 2018 13:17
Turn off auto-complete (intellisense) in VSCode
// Turn off autocomplete in Visual Studio Code
// Adapted From https://ourcodeworld.com/articles/read/505/how-to-disable-autocompletion-and-intellisense-in-microsoft-visual-studio-code
// Add the following lines to user settings
// OPTIONAL WORD WRAPPING
// Controls if lines should wrap. The lines will wrap at min(editor.wrappingColumn, viewportWidthInColumns).
"editor.wordWrap": "off",
// Controls the indentation of wrapped lines. Can be one of 'none', 'same' or 'indent'.