pip3 install pipenv
pipenv shell
from django.db import transaction | |
from rest_framework import mixins | |
from rest_framework.viewsets import GenericViewSet | |
__all__ = ['AtomicCreateModelMixin', 'AtomicUpdateModelMixin', 'AtomicDestroyModelMixin', | |
'AtomicModelViewSetMixin', 'AtomicModelViewSet'] | |
class AtomicCreateModelMixin(mixins.CreateModelMixin): |
Reference: | |
Django/Postgres/Nginx/Gunicorn in Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04 | |
Encryption: https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04 | |
Where you see "user", "myproject" and "myprojectuser" replace that with what is relevent to what you are working on. | |
User Setup | |
$ ssh root@SERVER_IP_ADDRESS | |
Complete login process |
sudo apt install libcanberra-gtk-module |
from channels.auth import AuthMiddlewareStack | |
from rest_framework.authtoken.models import Token | |
from django.contrib.auth.models import AnonymousUser | |
from django.db import close_old_connections | |
class TokenAuthMiddleware: | |
""" | |
Token authorization middleware for Django Channels 2 | |
""" |
FROM python:latest | |
ADD requirements.txt /requirements.txt | |
RUN python3.6 -m venv /venv \ | |
&& /venv/bin/pip install -U pip \ | |
&& LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "/venv/bin/pip install --no-cache-dir -r /requirements.txt" | |
ENV PYTHONUNBUFFERED 1 | |
# Copy your application code to the container (make sure you create a .dockerignore file if any large files or directories should be excluded) | |
RUN mkdir /code/ |
import asyncio | |
import random | |
class Hub(): | |
def __init__(self): | |
self.subscriptions = set() | |
def publish(self, message): |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener { | |
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName(); | |
private int previousTotal = 0; // The total number of items in the dataset after the last load | |
private boolean loading = true; // True if we are still waiting for the last set of data to load. | |
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more. | |
int firstVisibleItem, visibleItemCount, totalItemCount; |
Reference: | |
Django/Postgres/Nginx/Gunicorn in Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04 | |
Encryption: https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04 | |
Where you see "user", "myproject" and "myprojectuser" replace that with what is relevent to what you are working on. | |
User Setup | |
$ ssh root@SERVER_IP_ADDRESS | |
Complete login process |