Skip to content

Instantly share code, notes, and snippets.

View goutomroy's full-sized avatar

Goutom Roy goutomroy

View GitHub Profile
@prudnikov
prudnikov / atomic_viewsets.py
Created December 17, 2019 09:55
Django Rest Framework Atomic ViewSet and Mixin.
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):
@goutomroy
goutomroy / Step By Step Virtualenv, Django, Postgres, NGINX, Gunicorn, HTTPS on DigitalOcean This is every step, in detail, to create a Django App with Postgres, NGINX, Gunicorn, and HTTPS on Digital Ocean. The only thing I don't go over is how to create a droplet and manage the domain.
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
@bradtraversy
bradtraversy / pipenv_cheat_sheet.md
Last active May 27, 2024 14:28
Pipenv cheat sheet for common commands

Pipenv Cheat Sheet

Install pipenv

pip3 install pipenv

Activate

pipenv shell
@diegorribeiro
diegorribeiro / canberra-get.sh
Created October 24, 2018 21:26
Failed to load module "canberra-gtk-module" in Ubuntu 18.04 [64-bit system]
sudo apt install libcanberra-gtk-module
@rluts
rluts / token_auth.py
Last active October 13, 2023 20:56
Token authorization middleware for Django Channels 2
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
"""
@wodCZ
wodCZ / Dockerfile
Created February 4, 2018 14:38
django, postgres, redis, celery, nginx, uwsgi docker setup
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/
@appeltel
appeltel / pubsub.py
Last active May 5, 2024 09:40
asyncio pubsub example
import asyncio
import random
class Hub():
def __init__(self):
self.subscriptions = set()
def publish(self, message):
@goutomroy
goutomroy / EndlessRecyclerOnScrollListener.java
Created March 24, 2017 22:57 — forked from ssinss/EndlessRecyclerOnScrollListener.java
Endless RecyclerView OnScrollListener
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;
@davemerwin
davemerwin / Step By Step Virtualenv, Django, Postgres, NGINX, Gunicorn, HTTPS on DigitalOcean
Last active March 5, 2024 01:50
This is every step, in detail, to create a Django App with Postgres, NGINX, Gunicorn, and HTTPS on Digital Ocean. The only thing I don't go over is how to create a droplet and manage the domain.
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
@Prototype-X
Prototype-X / Install_pgAdmin4_with_python3_on_Ubuntu 16.04.md
Last active January 30, 2022 23:24
Install pgAdmin4 v2.0 with python3 on Ubuntu 16.04 DESKTOP mode

Install pgAdmin4 v2.0 with python3 on Ubuntu 16.04 DESKTOP mode

  1. Get Python Wheel pgAdmin4

     wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.0/pip/pgadmin4-2.0-py2.py3-none-any.whl
    
  2. Install pip3

     sudo apt install python3-pip