Skip to content

Instantly share code, notes, and snippets.

View Yogendra0Sharma's full-sized avatar
🎯
Focusing

Yogendra Sharma Yogendra0Sharma

🎯
Focusing
View GitHub Profile
from django import forms
from django.contrib.auth.models import User
class UserProfileForm(forms.ModelForm):
class Meta:
model = User
fields = ['first_name', 'last_name', 'email']
@Yogendra0Sharma
Yogendra0Sharma / Install.md
Created February 21, 2017 06:15 — forked from genomics-geek/Install.md
Deploying django application with gunicorn nginx mysql

Step One: Update Packages

sudo apt-get update
sudo apt-get upgrade

Step Two: Install and Create Virtualenv

sudo apt-get install python-virtualenv
sudo virtualenv /opt/myenv
@Yogendra0Sharma
Yogendra0Sharma / jenikns_ci_on_osx.md
Created February 21, 2017 06:15 — forked from genomics-geek/jenikns_ci_on_osx.md
Setup Jenkins CI on OSX.

Jenkins CI on OSX

Instructions on how to setup a secured Jenkins CI on a Mac.

Download & Install dependencies

All of these operations are done with your admin user.

Developer tools

Install the command line developer tools.

I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):

Detailed Instructions

For setting up Jenkins to build GitHub projects. This assumes some ability to manage Jenkins, use the command line, set up a utility LDAP account, etc. Please share or improve this Gist as needed.

Install Jenkins Plugins

@Yogendra0Sharma
Yogendra0Sharma / README.md
Created February 21, 2017 06:15 — forked from genomics-geek/README.md
SMTP with Mailgun
smtp_host = smtp.mailgun.org
smtp_starttls = False
smtp_ssl = True
smtp_user = USERNAME
smtp_port = 465
smtp_password = PASSWORD
smtp_mail_from = EMAIL
@Yogendra0Sharma
Yogendra0Sharma / README.md
Created February 21, 2017 06:15 — forked from genomics-geek/README.md
Setting up a pypi package

Setting up a python package

This will include:

  1. Travis CI integration
  2. Codecov integration
  3. run tests using pytest and tox

Step 1. Cookiecutter

Django Weekend Learning

You can override the runserver command (or other management commands and make your own. Django 1.8 doesn't use optparse anymore but I rather like it's parser. This is a quick extension of the runserver command to set an env variable which will disable reCAPTCHA fields.

someapp/profile/management/commands/runserver.py:

from django.contrib.staticfiles.management.commands import runserver
import os
@Yogendra0Sharma
Yogendra0Sharma / README.md
Created February 21, 2017 06:13 — forked from nsomaru/README.md
Django Invitations & All-Auth: Invitation Accepted Only on Account Creation

django-invitations & django-allauth: Invitation Accepted Only on Account Creation

The Problem

As per this django-invitations issue, django-invitations considers an invite "accepted" if the invite link is clicked. This is problematic for two reasons (or more):

  1. Automatic mail crawlers which visit links checking for malware etc., and verifying that you're not a spammer
  2. A user which clicks a link to "check out" an invite, but doesn't necessarily want to sign up right now

Something to consider is that this solution assumes you're using django-allauth as it uses the EmailAddress model of that package.

import datetime
import itertools
# it generates dates in 30 minutes intervals
date_generator = (datetime.datetime.today() - datetime.timedelta(minutes=i) for i in itertools.count(0, 30))
# it gets 24h of data
dates = itertools.islice(date_generator, 24 * 2)
# convert generator data in list
@Yogendra0Sharma
Yogendra0Sharma / OrderedDict.py
Created February 20, 2017 04:39 — forked from andreisoriga/OrderedDict.py
Data Structures and Algorithms
# Keeping Dictionaries in Order
from collections import OrderedDict
d = OrderedDict()
d['foo'] = 1
d['bar'] = 2
d['spam'] = 3
d['grok'] = 4
# Outputs "foo 1", "bar 2", "spam 3", "grok 4"