Skip to content

Instantly share code, notes, and snippets.

@therealak12
therealak12 / clockify-delete-records.js
Created March 20, 2023 08:03
Automatically delete Clockify records
const timer = ms => new Promise(res => setTimeout(res, ms))
const delayMs = 4000;
const repeat = 30;
async function deleteRecord () {
for (var i = 0; i < repeat; i++) {
document.querySelector('.pointer.cl-non-selectable.cl-component-divided-left.cl-d-flex.cl-dropdown-toggle.cl-no-arrow').click()
document.querySelector('a[data-cy="delete-button"]').click()
document.querySelector('button[class="cl-btn cl-btn-danger"]').click()
await timer(delayMs);
@therealak12
therealak12 / admin.py
Created July 4, 2021 16:54
users admin file
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import gettext_lazy as _
from .models import EmailUser
class EmailUserAdmin(UserAdmin):
fieldsets = (
(None, {'fields': ('email', 'password')}),
from django.urls import path
from rest_framework_simplejwt.views import TokenRefreshView
from .views import EmailTokenObtainPairView, RegisterView
urlpatterns = [
path('register/', RegisterView.as_view(), name='token_obtain_pair'),
path('token/obtain/', EmailTokenObtainPairView.as_view(), name='token_obtain_pair'),
path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
]
from django.contrib.auth import get_user_model
from rest_framework.response import Response
from rest_framework.status import HTTP_201_CREATED, HTTP_400_BAD_REQUEST
from rest_framework.views import APIView
from rest_framework_simplejwt.views import TokenObtainPairView
from ..serializers.user import UserSerializer, TokenObtainPairSerializer
class RegisterView(APIView):
from django.contrib.auth import get_user_model
from rest_framework import serializers
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer as JwtTokenObtainPairSerializer
class TokenObtainPairSerializer(JwtTokenObtainPairSerializer):
username_field = get_user_model().USERNAME_FIELD
class UserSerializer(serializers.ModelSerializer):
@therealak12
therealak12 / auth_backends.py
Last active May 26, 2021 09:43
django email auth backend
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend
class EmailBackend(ModelBackend):
def authenticate(self, request, **kwargs):
UserModel = get_user_model()
try:
email = kwargs.get('email', None)
if email is None:
@therealak12
therealak12 / models.py
Last active March 21, 2021 17:57
override django's default user model
from django.contrib.auth.base_user import BaseUserManager
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.utils.translation import ugettext_lazy as _
class CustomUserManager(BaseUserManager):
"""
Custom user model manager where email is the unique identifiers
for authentication instead of usernames.
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/info_window_width"
android:layout_height="wrap_content">
<TextView
android:id="@+id/cta_action_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.CornerPathEffect;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;