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 / image_upload_live_preview.html
Last active December 4, 2018 11:47
you can preview the images selected to upload in the page itself before upload.
<html>
<head></head>
<body>
<style>
#banner-image-holder{
background-image: url(''); /* can load with a default image */
background-repeat: no-repeat;
background-position: center;
background-size: 100% auto;
box-shadow: inset 0 0 15px 0px black;
@jerinisready
jerinisready / ancestor-selector.js
Created November 29, 2018 12:17 — forked from tomhodgins/ancestor-selector.js
Download ZIP to view and edit, or preview index.html online at: http://staticresource.com/helpers
// Ancestor Selector
function ancestor(selector, ancestor, rule) {
let styles = ''
let count = 0
Array.from(document.querySelectorAll(ancestor))
.filter(tag => tag.querySelector(selector))
.forEach(tag => {
@jerinisready
jerinisready / borderless_textarea.css
Last active November 29, 2018 11:55
Css Snippet to have a Medium / Linkedin like, TextArea which is borderless, paddingless, title like, word break automatically to new line, overflow managed!
textarea {
overflow-wrap: break-word;
-webkit-appearance: textarea;
border: none;
-webkit-rtl-ordering: logical;
-webkit-user-select: text;
-webkit-box-orient: vertical;
background: transparent none repeat scroll 0 0 !important;
z-index: auto;
resize: vertical;
@jerinisready
jerinisready / banner_image.css
Created November 26, 2018 07:14
Set banner image with 100% widht and specific height. it automatically position to center of image so that, images of any size will be fit in same general size.
.card__banner_image {
background: url('/image/file.jpg') center / cover;
width: 100%;
height: 160px;
}
.card__banner_text{vertical-align: middle;}
/**
@jerinisready
jerinisready / through_relationships.py
Created November 14, 2018 04:44 — forked from jhgaylor/through_relationships.py
Example of using a through model in Django and filtering by a value on the custom through model.
class A(models.Model):
things = models.ManyToManyField("B", through=ThroughModel)
class B(models.Model):
text = models.TextField()
class ThroughModel(models.Model):
a = models.ForeignKey(A)
b = models.ForeignKey(B)
extra = models.BooleanField()
@jerinisready
jerinisready / ImageParserMixin.py
Created November 12, 2018 09:36
ImageParser Class is used to parse an image from external url and save it to Django model field
from django.db import models
from django.db.models.base import ModelBase
from .image_url_to_file import image_url_to_file
class ImageParserMixin(object):
"""
ImageParser Class is used to parse an image from external url and save it to model field
@jerinisready
jerinisready / py3.6.sh
Created October 13, 2018 11:19
Install Python 3.6
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar xvf Python-3.6.3.tgz
cd Python-3.6.3
./configure --enable-optimizations
make -j8
@jerinisready
jerinisready / blog_references.py
Created October 13, 2018 07:55
Python References
# Subdomains
https://wellfire.co/learn/multi-tennancy-in-django-using-subdomains/
# Django Mini CMS
https://wellfire.co/learn/snippet-editing-with-django-addendum/
# Enhance an image / give an Outlay
https://wellfire.co/learn/python-image-enhancements/
@jerinisready
jerinisready / django_form_display.html
Created September 21, 2018 12:31
django form display html
<form method="post">
{% csrf_token %}
{% for field in form %}
{% if field.name == 'mobile_alternative' %}<hr />{% endif %}
<div class="form-group m-form__group row">
<label class="col-xl-3 col-lg-3 col-form-label">
{{ field.label }}{% if field.field.required %}<span style="color:#8b0000">*</span> {% endif %}:
</label>
<div class="col-xl-9 col-lg-9">
{{ field }}
@jerinisready
jerinisready / django_timeslot_validator.py
Last active March 12, 2019 05:45
Suppose, if a user needs to subscribe a feature from start_date 'A' to end_date 'B', This Django model form's 'clean' method validates allocating the feature over a particular time slot. This methods also ensures these dates donot conflict with any other active subscriptions
# from common.models import SubscriptionPlan
def clean(self):
"""
* Suppose, if a user needs to subscribe a feature from start_date 'A' to end_date 'B'
* This Django model form's 'clean' method validates allocating the feature over a particular time slot.
* This methods also ensures these dates donot conflict with any other active subscriptions.
*
* form input must contain dates 'start_date' and 'end_date'
* Django Model (here: `SubscriptionPlan`) with equivalent fields for `activation_date` and `expiry_date`