Skip to content

Instantly share code, notes, and snippets.

View theparadoxer02's full-sized avatar

Abhimanyu Gupta theparadoxer02

View GitHub Profile
@theparadoxer02
theparadoxer02 / extract.py
Created April 9, 2019 10:13 — forked from tyndyll/extract.py
Parsing Maildir Mail Stored on Disk with Python
def unicode_it(data):
# Take a string of data and convert it to unicode
try:
return unicode(data, errors="replace").strip()
except TypeError as E:
return u""
def extract(msg, msg_obj, attachments):
if msg.is_multipart():
for part in msg.get_payload():
@theparadoxer02
theparadoxer02 / Add user to Group
Created June 5, 2018 20:37
Add Permission to Group user using Django shell
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
from users.models import User
new_group, created = Group.objects.get_or_create(name ='new_group')
# Code to add permission to group ???
ct = ContentType.objects.get_for_model(User)
# Now what - Say I want to add 'Can go Haridwar' permission to level0?
permission = Permission.objects.create(codename ='can_go_haridwar', name ='Can go to Haridwar', content_type = ct)
from django.contrib.auth.models import AbstractUser
from django.utils import timezone
from django.db import models
class User(AbstractUser):
"""Define the extra fields related to User here"""
first_name = models.CharField(_('First Name of User'), blank = True, max_length = 20)
last_name = models.CharField(_('Last Name of User'), blank = True, max_length = 20)
# - - - Some more User fields according to your need s
@theparadoxer02
theparadoxer02 / Dockerfile
Created June 5, 2018 17:54
Dockerfile for a basic Django Project
# Base Image
FROM python:3.5-alpine
# Initialize
RUN mkdir -p /data/web
COPY . /data/web/
RUN mkdir -p mydjango/static/admin
# Setup
RUN apk update
#!/user/bin/python
def custom_generator(x):
for i in range(10):
if i == 5:
return
else:
yield i
=============================
**http://kickass.to/infiniteskills-learning-jquery-mobile-working-files-t7967156.html
**http://kickass.to/lynda-bootstrap-3-advanced-web-development-2013-eng-t8167587.html
**http://kickass.to/lynda-css-advanced-typographic-techniques-t7928210.html
**http://kickass.to/lynda-html5-projects-interactive-charts-2013-eng-t8167670.html
**http://kickass.to/vtc-html5-css3-responsive-web-design-course-t7922533.html
*http://kickass.to/10gen-m101js-mongodb-for-node-js-developers-2013-eng-t8165205.html
*http://kickass.to/cbt-nuggets-amazon-web-services-aws-foundations-t7839734.html