Boilerplate code for setting up Nginx + Gunicorn + Flask + Letsencrypt SSL certs using docker-compose
Though it might be of interest.
I wrote a boilerplate code template to easy back up a webapp on Flask fw.
Include Nginx / Gunicorn / Flask and Letsencrypt SSL Certificates configs.
Tested on Ubuntu 16.04 and 18.04. Steps detailed in README.
[https://github.com/smallwat3r/docker-nginx-gunicorn-flask-letsencrypt](https://github.com/smallwat3r/docker-nginx-gunicorn-flask-letsencrypt)
/r/flask
https://redd.it/ar2v2h
Though it might be of interest.
I wrote a boilerplate code template to easy back up a webapp on Flask fw.
Include Nginx / Gunicorn / Flask and Letsencrypt SSL Certificates configs.
Tested on Ubuntu 16.04 and 18.04. Steps detailed in README.
[https://github.com/smallwat3r/docker-nginx-gunicorn-flask-letsencrypt](https://github.com/smallwat3r/docker-nginx-gunicorn-flask-letsencrypt)
/r/flask
https://redd.it/ar2v2h
GitHub
GitHub - smallwat3r/docker-nginx-gunicorn-flask-letsencrypt: Boilerplate for running Nginx + Gunicorn + Flask + Let's Encrypt (https)…
Boilerplate for running Nginx + Gunicorn + Flask + Let's Encrypt (https) with auto renewals on Docker. - smallwat3r/docker-nginx-gunicorn-flask-letsencrypt
Model and zero or many ForeignKey Models - CRUD
I've got basic CRUD working with the GCBVs for a single model.
Now I want to add the foreignKey model (0 or many "children").
I can see how to "manually" do this by extending TemplateView and override the get\_query and get\_context\_data.
I'm wondering if there is a way to do this more "auto-magically" with some existing GCBVs? My google searches for things like "django display model and foreignkey model on same view" don't turn up useful results. Is there a way of combining the two models/modelForms?
​
Thanks
/r/django
https://redd.it/ar63xh
I've got basic CRUD working with the GCBVs for a single model.
Now I want to add the foreignKey model (0 or many "children").
I can see how to "manually" do this by extending TemplateView and override the get\_query and get\_context\_data.
I'm wondering if there is a way to do this more "auto-magically" with some existing GCBVs? My google searches for things like "django display model and foreignkey model on same view" don't turn up useful results. Is there a way of combining the two models/modelForms?
​
Thanks
/r/django
https://redd.it/ar63xh
reddit
r/django - Model and zero or many ForeignKey Models - CRUD
1 vote and 0 comments so far on Reddit
[D] How do we avoid SOTA-hacking?
The OpenAI blog post reports that they achieve "state-of-the-art performance on many language modeling benchmarks", but they compare a model pretrained on additional data to models trained only on the provided dataset. Reporting this as beating the SOTA on these datasets doesn't make sense. As mentioned on Twitter, the results they state as the existing SOTA can be beaten trivially:
[https://twitter.com/BFelbo/status/1096310277312634882](https://twitter.com/BFelbo/status/1096310277312634882)
[https://twitter.com/seb\_ruder/status/1096335334969933829](https://twitter.com/seb_ruder/status/1096335334969933829)
Claiming SOTA results in this way makes it harder to publish papers focused on sample-efficiency and to compare results across papers. The OpenAI blog post / paper is just the latest of many papers claiming SOTA results with a comparison that doesn't make sense. How do we as a community avoid this kind of SOTA-hacking?
/r/MachineLearning
https://redd.it/ar3tc2
The OpenAI blog post reports that they achieve "state-of-the-art performance on many language modeling benchmarks", but they compare a model pretrained on additional data to models trained only on the provided dataset. Reporting this as beating the SOTA on these datasets doesn't make sense. As mentioned on Twitter, the results they state as the existing SOTA can be beaten trivially:
[https://twitter.com/BFelbo/status/1096310277312634882](https://twitter.com/BFelbo/status/1096310277312634882)
[https://twitter.com/seb\_ruder/status/1096335334969933829](https://twitter.com/seb_ruder/status/1096335334969933829)
Claiming SOTA results in this way makes it harder to publish papers focused on sample-efficiency and to compare results across papers. The OpenAI blog post / paper is just the latest of many papers claiming SOTA results with a comparison that doesn't make sense. How do we as a community avoid this kind of SOTA-hacking?
/r/MachineLearning
https://redd.it/ar3tc2
Twitter
Bjarke
@OpenAI I don’t think the phrase SOTA makes sense in this context as you’re doing an apples to oranges comparison. For instance, it’s trivial to beat what you report as the previous SOTA for PTB if you can use any pretraining dataset.
Flask/uwsgi app and Docker
Recently decided to get into Docker and see what it was all about. For anyone who has done this, do you recommend separate containers for nginx proxy and uwsgi/flask app, or no?
Or if anyone has an example of their setup, that'd be great. Just trying to see how I'd structure an API with db, flask/uwsgi/nginx, and nginx on the frontend for whatever js I'm running.
/r/flask
https://redd.it/ar4dsi
Recently decided to get into Docker and see what it was all about. For anyone who has done this, do you recommend separate containers for nginx proxy and uwsgi/flask app, or no?
Or if anyone has an example of their setup, that'd be great. Just trying to see how I'd structure an API with db, flask/uwsgi/nginx, and nginx on the frontend for whatever js I'm running.
/r/flask
https://redd.it/ar4dsi
reddit
r/flask - Flask/uwsgi app and Docker
4 votes and 1 comment so far on Reddit
New Multi-Task Deep Neural Network for Natural Language Understanding published by Microsoft
https://arxiv.org/pdf/1901.11504.pdf
/r/MachineLearning
https://redd.it/ar5l77
https://arxiv.org/pdf/1901.11504.pdf
/r/MachineLearning
https://redd.it/ar5l77
reddit
r/MachineLearning - New Multi-Task Deep Neural Network for Natural Language Understanding published by Microsoft
12 votes and 5 comments so far on Reddit
Embedding Entire Python GUIs in Webpages with Repl.it and PySimpleGUI
PySimpleGUI has taken the leap from the desktop and into the browser. And it can run without having Python installed on the computer.
# The PySimpleGUIWeb Port
First, the PySimpleGUI SDK has added a new port, PySimpleGUIWeb. This port enables PySimpleGUI code to run in a web browser. When you run your PySimpleGUIWeb based Python program, a browser window is opened and you interact with your GUI through the browser window.
The familiar PySimpleGUI code structure, look and feel remains the same. The difference is that you're interacting through a web browser rather than a tkinter, WxPython or Qt window. The only difference in the PySimpleGUI code is the import statement at the top.
This simple program
import PySimpleGUI as sg
print('starting up...') # Seems to help repl.it
layout = [[sg.Text('My one-shot window.')],
[sg.InputText()],
[sg.Submit(), sg.Cancel()]]
window = sg.Window('Window Title').Layout(layout)
/r/Python
https://redd.it/ar3x3b
PySimpleGUI has taken the leap from the desktop and into the browser. And it can run without having Python installed on the computer.
# The PySimpleGUIWeb Port
First, the PySimpleGUI SDK has added a new port, PySimpleGUIWeb. This port enables PySimpleGUI code to run in a web browser. When you run your PySimpleGUIWeb based Python program, a browser window is opened and you interact with your GUI through the browser window.
The familiar PySimpleGUI code structure, look and feel remains the same. The difference is that you're interacting through a web browser rather than a tkinter, WxPython or Qt window. The only difference in the PySimpleGUI code is the import statement at the top.
This simple program
import PySimpleGUI as sg
print('starting up...') # Seems to help repl.it
layout = [[sg.Text('My one-shot window.')],
[sg.InputText()],
[sg.Submit(), sg.Cancel()]]
window = sg.Window('Window Title').Layout(layout)
/r/Python
https://redd.it/ar3x3b
reddit
r/Python - Embedding Entire Python GUIs in Webpages with Repl.it and PySimpleGUI
11 votes and 3 comments so far on Reddit
This tutorial is for people who want to start learning python or have confusion regarding Python. This tutorial has a series of videos explaining python and its implementation.
https://www.youtube.com/playlist?list=PLVHgQku8Z935Qq0h3SZpSOwSrUMx1y3c9
/r/IPython
https://redd.it/aqxvaq
https://www.youtube.com/playlist?list=PLVHgQku8Z935Qq0h3SZpSOwSrUMx1y3c9
/r/IPython
https://redd.it/aqxvaq
YouTube
Python Programming Tutorials - YouTube
Trying to get timezone working in a model
I've set up a model with timestamp fields, using
from django.utils import timezone
Then as part of the model
created_at = models.DateTimeField('Created', editable=False)
last_active = models.DateTimeField('Last activity')
The save process is overridden to update these fields as appropriate.
if not self.created_at:
self.created_at = timezone.now()
self.last_active = timezone.now()
When I run my unit test, which basically only creates a record and checks the values, I get errors with
RuntimeWarning: DateTimeField <model>.created_at received a naive datetime (2019-02-16 18:18:58.692009)
while time zone support is active.
RuntimeWarning)
'USE_TZ' is set to True in settings.py.
Now I get that the error is telling me that the values don't include timezone offsets, but my question is why, when I am using the timezone functionality from django.utils? I thought that was built in there?
Any suggestions?
/r/django
https://redd.it/arauah
I've set up a model with timestamp fields, using
from django.utils import timezone
Then as part of the model
created_at = models.DateTimeField('Created', editable=False)
last_active = models.DateTimeField('Last activity')
The save process is overridden to update these fields as appropriate.
if not self.created_at:
self.created_at = timezone.now()
self.last_active = timezone.now()
When I run my unit test, which basically only creates a record and checks the values, I get errors with
RuntimeWarning: DateTimeField <model>.created_at received a naive datetime (2019-02-16 18:18:58.692009)
while time zone support is active.
RuntimeWarning)
'USE_TZ' is set to True in settings.py.
Now I get that the error is telling me that the values don't include timezone offsets, but my question is why, when I am using the timezone functionality from django.utils? I thought that was built in there?
Any suggestions?
/r/django
https://redd.it/arauah
reddit
r/django - Trying to get timezone working in a model
1 vote and 0 comments so far on Reddit
Need help for Django polls(Beginner)
I can't seem to make a poll server.Hope the information helps
1.The first error i received
ImportError: cannot import name 'views' from '\_\_main\_\_' (C:\\Users\\thapa\\AppData\\Local\\Programs\\Python\\Python37-32\\mysite\\polls\\[urls.py](https://urls.py))
2. 2nd error in mysite.urls.py
ModuleNotFoundError: No module named 'polls'
https://i.redd.it/ak94g6qqzxg21.png
​
​
/r/django
https://redd.it/ar9c6w
I can't seem to make a poll server.Hope the information helps
1.The first error i received
ImportError: cannot import name 'views' from '\_\_main\_\_' (C:\\Users\\thapa\\AppData\\Local\\Programs\\Python\\Python37-32\\mysite\\polls\\[urls.py](https://urls.py))
2. 2nd error in mysite.urls.py
ModuleNotFoundError: No module named 'polls'
https://i.redd.it/ak94g6qqzxg21.png
​
​
/r/django
https://redd.it/ar9c6w
This media is not supported in your browser
VIEW IN TELEGRAM
A line follower robot my classmade and i made with python for our minor project. Turned out working great :D
/r/Python
https://redd.it/ar9s51
/r/Python
https://redd.it/ar9s51
UFC MMA Predictor (70.4% accuracy)
Hi everyone,
I would like to share with you all a project which I have been working on this week. It's called the **UFC MMA Predictor.** It is a web app I developed to help predict upcoming UFC fights. The web app can be accessed at [https://ufcmmapredictor.herokuapp.com/](https://ufcmmapredictor.herokuapp.com/)
​
Some features of this web app:
* 70.4% accurate
* Fighters and fights data scraped daily
* Model trained up from UFC 159 to most recent fight card (more than 2,000 fights)
* Predictors used to predict outcomes:
* Decimal odds spread (different of favourite minus underdog)
* Strikes landed per minute
* Strikes absorbed per minute
* Striking defense
* Striking volume
* Take down defense
* Submission attempts per minute
* Takedown accuracy
​
GitHub link: [https://github.com/jasonchanhku/UFC-MMA-Predictor](https://github.com/jasonchanhku/UFC-MMA-Predictor)
​
**Demo**
​
[Correctly predicted this one despite GSP being the underdog!](https://i.redd.it/nxm2i56nmxg21.png)
/r/Python
https://redd.it/ar8rwt
Hi everyone,
I would like to share with you all a project which I have been working on this week. It's called the **UFC MMA Predictor.** It is a web app I developed to help predict upcoming UFC fights. The web app can be accessed at [https://ufcmmapredictor.herokuapp.com/](https://ufcmmapredictor.herokuapp.com/)
​
Some features of this web app:
* 70.4% accurate
* Fighters and fights data scraped daily
* Model trained up from UFC 159 to most recent fight card (more than 2,000 fights)
* Predictors used to predict outcomes:
* Decimal odds spread (different of favourite minus underdog)
* Strikes landed per minute
* Strikes absorbed per minute
* Striking defense
* Striking volume
* Take down defense
* Submission attempts per minute
* Takedown accuracy
​
GitHub link: [https://github.com/jasonchanhku/UFC-MMA-Predictor](https://github.com/jasonchanhku/UFC-MMA-Predictor)
​
**Demo**
​
[Correctly predicted this one despite GSP being the underdog!](https://i.redd.it/nxm2i56nmxg21.png)
/r/Python
https://redd.it/ar8rwt
GitHub
GitHub - jasonchanhku/UFC-MMA-Predictor: A web application built on dash to predict winners of a UFC fight
A web application built on dash to predict winners of a UFC fight - jasonchanhku/UFC-MMA-Predictor
DigitalOcean's Django One-Click Application: setting up virtualenv for python2 and python3.
I just recently started fiddling with DigitalOcean's one click Django app, after setting it up from scratch before. It's really convenient but its fatal flaw for me was the fact that it used Python 2.7 and did not use a virtualenv. So I set about trying to see what it would take, in the simplest way possible, have it use a Python 3 virtualenv. Here's the sequence that I used (as of February, 2019):
from the root login:
sudo usermod -a -G sudo django
su django
cd ~/django_project
pip freeze >> requirements.txt
virtualenv venv
sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0
sudo apt install libicu-dev
I found that the version of PyGObject installed in the One Click container was no longer supported by pip, so I edited requirements.txt and removed the version requirement. I did the same for pycairo and PyICU, though these may still be supported by pip.
vi requirements.txt
change the following to remove version requirements:
pycairo
pygobject
/r/djangolearning
https://redd.it/ard4wb
I just recently started fiddling with DigitalOcean's one click Django app, after setting it up from scratch before. It's really convenient but its fatal flaw for me was the fact that it used Python 2.7 and did not use a virtualenv. So I set about trying to see what it would take, in the simplest way possible, have it use a Python 3 virtualenv. Here's the sequence that I used (as of February, 2019):
from the root login:
sudo usermod -a -G sudo django
su django
cd ~/django_project
pip freeze >> requirements.txt
virtualenv venv
sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0
sudo apt install libicu-dev
I found that the version of PyGObject installed in the One Click container was no longer supported by pip, so I edited requirements.txt and removed the version requirement. I did the same for pycairo and PyICU, though these may still be supported by pip.
vi requirements.txt
change the following to remove version requirements:
pycairo
pygobject
/r/djangolearning
https://redd.it/ard4wb
reddit
r/djangolearning - DigitalOcean's Django One-Click Application: setting up virtualenv for python2 and python3.
1 vote and 0 comments so far on Reddit
Is this a good way to apply a decorator to all routes in a blueprint?
All routes in my application that being with `/api/admin` are protected by checking if the authentication token contains the `ADMIN` role in it.
So instead of applying a decorator before each function in the blueprint (called `admin_api`, I have this at the top instead.
My custom decorator is called `is_admin` which does the check of the JWT. ~~For some reason I also have to specify `jwt_required` (using flast_jwt_simple package).~~ Edit: I put it in the `is_admin` method and it works.
@admin_api.before_request
@is_admin
def check_if_admin():
pass
Is this the right way to go about it? Seems kinda hackish.
/r/flask
https://redd.it/araty2
All routes in my application that being with `/api/admin` are protected by checking if the authentication token contains the `ADMIN` role in it.
So instead of applying a decorator before each function in the blueprint (called `admin_api`, I have this at the top instead.
My custom decorator is called `is_admin` which does the check of the JWT. ~~For some reason I also have to specify `jwt_required` (using flast_jwt_simple package).~~ Edit: I put it in the `is_admin` method and it works.
@admin_api.before_request
@is_admin
def check_if_admin():
pass
Is this the right way to go about it? Seems kinda hackish.
/r/flask
https://redd.it/araty2
reddit
r/flask - Is this a good way to apply a decorator to all routes in a blueprint?
5 votes and 4 comments so far on Reddit
Steps to become a professional django developer
I have just completed a django tutorial and built a cloud music player website. I have also implemented it's api. What are the next steps i should take in order to be a professional django developer. I am open to contributing to open source , if that helps me in learning best practises and more about web developement. Thanks !
/r/django
https://redd.it/are5ir
I have just completed a django tutorial and built a cloud music player website. I have also implemented it's api. What are the next steps i should take in order to be a professional django developer. I am open to contributing to open source , if that helps me in learning best practises and more about web developement. Thanks !
/r/django
https://redd.it/are5ir
reddit
r/django - Steps to become a professional django developer
11 votes and 4 comments so far on Reddit
[P] Simple Tensorflow collection of easy-to-use codes
​
[by taki0112 \(Junho Kim\)](https://i.redd.it/6ihziuz4g1h21.png)
Hello.
I made a cookbook for easy use of the tensorflow code. (e.g. conv with spectral norm, partial conv, pixel shuffle, several normalizaion function, tf-datasetAPI, etc.)
Just copy & paste!
​
In now, this repo contains general architectures and functions that are useful for the GAN.
I will continue to add useful things to other areas.
Also, it's not here, but if there are things you use often, please add them!
Your pull requests and issues are always welcome.
And write what you want to implement on the issue. I'll implement it.
​
github : [https://github.com/taki0112/Tensorflow-Cookbook](https://github.com/taki0112/Tensorflow-Cookbook)
​
Also, I am going to add code for tf-Eager mode !
Thank you.
/r/MachineLearning
https://redd.it/arg0vm
​
[by taki0112 \(Junho Kim\)](https://i.redd.it/6ihziuz4g1h21.png)
Hello.
I made a cookbook for easy use of the tensorflow code. (e.g. conv with spectral norm, partial conv, pixel shuffle, several normalizaion function, tf-datasetAPI, etc.)
Just copy & paste!
​
In now, this repo contains general architectures and functions that are useful for the GAN.
I will continue to add useful things to other areas.
Also, it's not here, but if there are things you use often, please add them!
Your pull requests and issues are always welcome.
And write what you want to implement on the issue. I'll implement it.
​
github : [https://github.com/taki0112/Tensorflow-Cookbook](https://github.com/taki0112/Tensorflow-Cookbook)
​
Also, I am going to add code for tf-Eager mode !
Thank you.
/r/MachineLearning
https://redd.it/arg0vm
Jupyter Notebooks Development Manifesto
https://blog.kovalevskyi.com/jupyter-notebooks-development-manifesto-88a1ddb24581
/r/JupyterNotebooks
https://redd.it/arhywu
https://blog.kovalevskyi.com/jupyter-notebooks-development-manifesto-88a1ddb24581
/r/JupyterNotebooks
https://redd.it/arhywu
Deep Learning as I See It
Jupyter Notebooks Development Manifesto
Jupyter Notebook is a relatively young tool, it does not yet have best engineering practices. Maybe it is time to change this.
Does someone knows the real maximum size of pickle ?
Hello everyone,
I'm getting data for my deep learning project, since the AI will have to process all the data i left aside the database option.
Righ now have a list of objects which weight about 500Mo and contains 7M objects, every 10K objects i store it as a pickle file and it still works fine.
However i'm concerned that theres is some kind of limit to pickle and since i'm going have 300M to 400M objects i don't want my dataset to get corrupted at half the process.
Does anyone knows pickle real limits ?
/r/Python
https://redd.it/ari3na
Hello everyone,
I'm getting data for my deep learning project, since the AI will have to process all the data i left aside the database option.
Righ now have a list of objects which weight about 500Mo and contains 7M objects, every 10K objects i store it as a pickle file and it still works fine.
However i'm concerned that theres is some kind of limit to pickle and since i'm going have 300M to 400M objects i don't want my dataset to get corrupted at half the process.
Does anyone knows pickle real limits ?
/r/Python
https://redd.it/ari3na
reddit
r/Python - Does someone knows the real maximum size of pickle ?
3 votes and 1 comment so far on Reddit
Any good projects need some part time help?
Going to part time work for a few months anyone working on something interesting that needs another dev? I have experience with most stacks out there.
/r/Python
https://redd.it/argmin
Going to part time work for a few months anyone working on something interesting that needs another dev? I have experience with most stacks out there.
/r/Python
https://redd.it/argmin
reddit
r/Python - Any good projects need some part time help?
3 votes and 1 comment so far on Reddit
How to Connect a Customized Checkbox to a Form/Model?
I have this BooleanField in my forms.py, and I'm trying to change the checkbox in the template into a toggle button (the slider switch type). I tried to do
<label class="switch">
<input type="checkbox">
<span class="slider round">{ p_form.email_visible }</span>
</label>
as per the instructions found at [w3schools](https://www.w3schools.com/howto/howto_css_switch.asp) and putting the template variable inside the span tag, but that dog wont hunt, which I kinda expected.
I've had a look at widgets in the official docs, but I'm confused whether that's the right path, as there's no information that directly addresses what I'm trying to do.
Browsing _The Land of Milk and Honey_ I found a few results that looked like they had something to do with my question, but as per usual, I don't get those posts, and it also only adds to the confusion, I'm afraid.
The slider shows up just fine in the template, but no change is made to the model as I hit it and then click my little submit button.
So, without further adieu: How do I connect the form (and the model, I guess...) to
/r/django
https://redd.it/arjhwy
I have this BooleanField in my forms.py, and I'm trying to change the checkbox in the template into a toggle button (the slider switch type). I tried to do
<label class="switch">
<input type="checkbox">
<span class="slider round">{ p_form.email_visible }</span>
</label>
as per the instructions found at [w3schools](https://www.w3schools.com/howto/howto_css_switch.asp) and putting the template variable inside the span tag, but that dog wont hunt, which I kinda expected.
I've had a look at widgets in the official docs, but I'm confused whether that's the right path, as there's no information that directly addresses what I'm trying to do.
Browsing _The Land of Milk and Honey_ I found a few results that looked like they had something to do with my question, but as per usual, I don't get those posts, and it also only adds to the confusion, I'm afraid.
The slider shows up just fine in the template, but no change is made to the model as I hit it and then click my little submit button.
So, without further adieu: How do I connect the form (and the model, I guess...) to
/r/django
https://redd.it/arjhwy
W3Schools
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.