Skip to content

Instantly share code, notes, and snippets.

View valaparthvi's full-sized avatar

Parthvi Vala valaparthvi

View GitHub Profile
@valaparthvi
valaparthvi / django_otp_token_generation.py
Last active November 28, 2022 08:53
Generate and Verify Time-based OTP with django-otp.
from django_otp.oath import TOTP
from django_otp.util import random_hex
from unittest import mock
import time
class TOTPVerification:
def __init__(self):
# secret key that will be used to generate a token,
from buckets.fields import S3FileField
from datetime import datetime, timezone, timedelta
from django.conf import settings
from django.db import models
from django.dispatch import receiver
from django.utils.translation import ugettext as _
from django.core.mail import send_mail
from django.template.loader import render_to_string
import django.contrib.auth.models as auth
import django.contrib.auth.base_user as auth_base
@valaparthvi
valaparthvi / view.py
Created August 16, 2017 08:35
Pass user_id from `AccountRegister` to `ConfirmPhone`.
class AccountRegister(CreateView):
model = User
form_class = forms.RegisterForm
template_name = 'account/signup.html'
success_url = reverse_lazy('account:verify_phone')
def form_valid(self, form):
user = form.save(self.request)
if user.email:
@valaparthvi
valaparthvi / main.py
Last active January 25, 2020 20:34
Sentaku Code Example
import sentaku
# Domain object class definition
class ObjectCollection(sentaku.modelling.ElementMixiin):
create = sentaku.ContextualMethod()
ENTITY = ObjectEntity
class ObjectEntity(sentaku.modelling.Element):
@valaparthvi
valaparthvi / fix.txt
Created April 27, 2020 18:26
Docker fix on Fedora 31
open /etc/default/grub as admin
Append value of GRUB_CMDLINE_LINUX with systemd.unified_cgroup_hierarchy=0
sudo grub2-mkconfig > /boot/efi/EFI/fedora/grub.cfg or
sudo grub2-mkconfig > /boot/grub2/grub.cfg
reboot
sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"
@valaparthvi
valaparthvi / devfile.yaml
Last active May 2, 2022 12:50
sample-nodejs-outerloop-devfile
commands:
- exec:
commandLine: npm install
component: runtime
group:
isDefault: true
kind: build
workingDir: $PROJECT_SOURCE
id: install
- exec: