Skip to content

Instantly share code, notes, and snippets.

View jerinisready's full-sized avatar
💭
A catalyst of Change

JK jerinisready

💭
A catalyst of Change
View GitHub Profile
@jerinisready
jerinisready / get_combinations.py
Last active March 17, 2021 14:09
Bit Wise Combinations of items in dictionary! If you have a set of objects, and want to access as a list of their combinations, use this simple snippet which uses bitwise and operator in python!
def get_status(code: int):
"""
This function will return a list of items
"""
_status_set = {
1: 'Alice',
2: 'Bob',
4: 'Charlie',
8: 'David',
@jerinisready
jerinisready / generate_dummy_comments.py
Created December 29, 2020 09:52
A simple script to generate Dummy Product Reviews in django oscar.
from faker import Faker
from random import randint, choice
from oscar.core.loading import get_model
from oscar.core.compat import get_user_model
from oscar.apps.catalogue.reviews.models import ProductReview, Vote
from oscar.apps.catalogue.models import Product
from apps.users.models import User
@jerinisready
jerinisready / calculate_percentage_of_2_fields_django_orm.py
Last active July 13, 2020 04:02
This is how I Implemented (pricedrop upto 40%) column in django oscar. Basically StockRecord model have 2 fields, 'price_excl_tax' and 'price_retail'. What we want is (price_excl_tax - price_retail) * 100 / price_excl_tax. We can use django's Expression wrapper to calculate the max offer price
"""
AUTHOR jerinisready
LICENSE : General Public License. Free to use, modify or publish unless u keep that open source.
This is how I implemented (pricedrop upto 40%) column in django oscar.
Basically StockRecord model have 2 fields, 'price_excl_tax' and 'price_retail'.
What we want is (price_retail - price_excl_tax) * 100 / price_retail.
We can use django's Expression wrapper to calculate the max offer price
@jerinisready
jerinisready / models.py
Created June 15, 2020 05:40
Dajngo Oscar Buy Now
from django.db import models
from oscar.apps.basket.abstract_models import AbstractBasket
from django.utils.translation import gettext_lazy as _
class Basket(AbstractBasket):
BUY_NOW, OPEN, MERGED, SAVED, FROZEN, SUBMITTED = (
"Buy Now", "Open", "Merged", "Saved", "Frozen", "Submitted")
STATUS_CHOICES = (
@jerinisready
jerinisready / __init__.py
Last active October 29, 2023 20:21
How to integrate Stripe payment in Django Oscar!
PAYMENT_EVENT_PURCHASE = 'Purchase'
PAYMENT_METHOD_STRIPE = 'Stripe'
STRIPE_EMAIL = 'stripeEmail'
STRIPE_TOKEN = 'stripeToken'
@jerinisready
jerinisready / intl-tel-input.html
Last active March 24, 2020 07:34
intl-tel-input.html
<input type='text' class="mobile-number" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/16.0.2/css/intlTelInput.css"
integrity="sha256-rTKxJIIHupH7lFo30458ner8uoSSRYciA0gttCkw1JE=" crossorigin="anonymous"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/16.0.2/js/utils.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/16.0.2/js/intlTelInput.js"></script>
<style>
.iti__flag {
@jerinisready
jerinisready / load-video-via-buffering.html
Created January 30, 2020 08:19
this is how to load a video via buffering Credits : Google Developrs at Medium :https://medium.com/google-developers/use-video-loops-with-interactive-canvas-dc7503e95c6a
<!doctype html>
<head>
<title> Canvas Draw </title>
</head>
<body>
<video id="can_video"></video>
</body>
<script>
/**
@jerinisready
jerinisready / django_settings.py
Last active January 22, 2020 07:00
Sample Django Settings.py
import os
_isenvsetas = lambda key, default=False: str(os.environ.get(key, ...)).upper() == str(default).upper()
AUTH_PASSWORD_VALIDATORS = [
{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', },
{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', },
{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', },
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', },
@jerinisready
jerinisready / smoothWheel.js
Created December 30, 2019 11:42
SmoothWheel Javascript. Reference : https://codepen.io/xtianmiller/pen/oGEWQj
(function($){
var self=this,
container,
running=!1,
currentY=0,
targetY=0,
oldY=0,
maxScrollTop=0,
minScrollTop,
direction,
<!DOCTYPE html>
<html>
<title> Jerinisready | Custom Template | Inspired From W3Schools </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<style>
body,h1,h2{font-family: "Raleway", sans-serif}body, html {height: 100%}
.bgimg {min-height: 100%;background-image: url("https://www.w3schools.com/w3images/wedding_couple.jpg");background-position: center;background-size:cover;}