Paul Ross - Here be Dragons - Writing Safe C Extensions - PyCon 2016
https://www.youtube.com/watch?v=Yq__HtUIH5Y
/r/Python
https://redd.it/7e2ei9
https://www.youtube.com/watch?v=Yq__HtUIH5Y
/r/Python
https://redd.it/7e2ei9
YouTube
Paul Ross - Here be Dragons - Writing Safe C Extensions - PyCon 2016
Speaker: Paul Ross
Writing Python Extensions can be daunting. This talk de-mystifies what you need to know to write reliable and blazingly fast Pythonic C code.
Slides can be found at: https://speakerdeck.com/pycon2016 and https://github.com/PyCon/2016…
Writing Python Extensions can be daunting. This talk de-mystifies what you need to know to write reliable and blazingly fast Pythonic C code.
Slides can be found at: https://speakerdeck.com/pycon2016 and https://github.com/PyCon/2016…
If I write & complete a Django web application can I then write a REST API for it?
I am completely new to Django & web development in general and I was wondering about it. Can I create my app first and when it is complete write an API on top of it? Or should I account for the API while I am developing the app?
Thank you in advance.
/r/django
https://redd.it/7e1r6x
I am completely new to Django & web development in general and I was wondering about it. Can I create my app first and when it is complete write an API on top of it? Or should I account for the API while I am developing the app?
Thank you in advance.
/r/django
https://redd.it/7e1r6x
reddit
If I write & complete a Django web application can I... • r/django
I am completely new to Django & web development in general and I was wondering about it. Can I create my app first and when it is complete write...
uploading files to amazon s3
Can anyone give me a walkthrough of cors and policy setup on s3?
I've followed the default tutorials for settings up the AWS settings such as access key, bucket name, with boto and storages.
Collectstatic works fine but whenever logged in to a user account to say upload a profile image it says that the bucket is read-only a 500 error is hit.
My forms work fine everything is fine on local. Just an AWS issue moving to production.
Ideally, only users from the website would be able to upload images. SO, not allowing open access.
/r/django
https://redd.it/7e5vlw
Can anyone give me a walkthrough of cors and policy setup on s3?
I've followed the default tutorials for settings up the AWS settings such as access key, bucket name, with boto and storages.
Collectstatic works fine but whenever logged in to a user account to say upload a profile image it says that the bucket is read-only a 500 error is hit.
My forms work fine everything is fine on local. Just an AWS issue moving to production.
Ideally, only users from the website would be able to upload images. SO, not allowing open access.
/r/django
https://redd.it/7e5vlw
reddit
uploading files to amazon s3 • r/django
Can anyone give me a walkthrough of cors and policy setup on s3? I've followed the default tutorials for settings up the AWS settings such as...
How do I customize a user registration form so it only requires email and password fields?
I'm following this [tutorial](https://simpleisbetterthancomplex.com/tutorial/2017/02/18/how-to-create-user-sign-up-view.html) on making simple registration forms in Django. I'd like to make a user registration form that requires only two fields: "Email" and "Password." No second password field, just one.
So far, My `views.py` looks like this:
def register(request, template="register.html", redirect='/'):
if request.method=="POST":
form= RegisterForm(request.POST)
if form.is_valid():
form.save()
email= form.cleaned_data.get("email")
raw_password= form.cleaned_data.get("password1")
user= authenticate(email=email, password=raw_password)
login(request, user)
return redirect('/')
else:
form= RegisterForm()
return render(request, template, {"form": form})
`forms.py` has this class in it:
class RegisterForm(UserCreationForm):
email= forms.EmailField(label=_("Email"), max_length=254)
class Meta:
model= User
fields= ("email",)
`register.html` looks simple:
{% extends "base.html" %}
{% block main %}
<h2>Register</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Register</button>
</form>
{% endblock main %}
In `urls.py`, I have this line in `urlpatterns`: `url("^register/$", views.register, name="register"),`.
But my registration forms looks like this, with an Email field and two Password fields: http://i.imgur.com/b359A5Z.png. And if I fill out all three fields and hit "Register," I get this error: `UNIQUE constraint failed: auth_user.username`.
Any idea why I'm getting this error? And how can I make sure my form only has two fields: Email and Password?
/r/django
https://redd.it/7e5rxp
I'm following this [tutorial](https://simpleisbetterthancomplex.com/tutorial/2017/02/18/how-to-create-user-sign-up-view.html) on making simple registration forms in Django. I'd like to make a user registration form that requires only two fields: "Email" and "Password." No second password field, just one.
So far, My `views.py` looks like this:
def register(request, template="register.html", redirect='/'):
if request.method=="POST":
form= RegisterForm(request.POST)
if form.is_valid():
form.save()
email= form.cleaned_data.get("email")
raw_password= form.cleaned_data.get("password1")
user= authenticate(email=email, password=raw_password)
login(request, user)
return redirect('/')
else:
form= RegisterForm()
return render(request, template, {"form": form})
`forms.py` has this class in it:
class RegisterForm(UserCreationForm):
email= forms.EmailField(label=_("Email"), max_length=254)
class Meta:
model= User
fields= ("email",)
`register.html` looks simple:
{% extends "base.html" %}
{% block main %}
<h2>Register</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Register</button>
</form>
{% endblock main %}
In `urls.py`, I have this line in `urlpatterns`: `url("^register/$", views.register, name="register"),`.
But my registration forms looks like this, with an Email field and two Password fields: http://i.imgur.com/b359A5Z.png. And if I fill out all three fields and hit "Register," I get this error: `UNIQUE constraint failed: auth_user.username`.
Any idea why I'm getting this error? And how can I make sure my form only has two fields: Email and Password?
/r/django
https://redd.it/7e5rxp
Simple is Better Than Complex
How to Create User Sign Up View
In this tutorial I will cover a few strategies to create Django user sign up/registration. Usually I implement it fromscratch. You will see it’s very straightforward.
How do I edge detect a live video with Canny edge detection?
I'm using python, and I'm kinda new as well.
Does anyone have a method for OpenCV live video feed edge detection?
Thanks
/r/Python
https://redd.it/7e5glv
I'm using python, and I'm kinda new as well.
Does anyone have a method for OpenCV live video feed edge detection?
Thanks
/r/Python
https://redd.it/7e5glv
reddit
How do I edge detect a live video with Canny edge... • r/Python
I'm using python, and I'm kinda new as well. Does anyone have a method for OpenCV live video feed edge detection? Thanks
[D] Machine Learning - WAYR (What Are You Reading) - Week 36
This is a place to share machine learning research papers, journals, and articles that you're reading this week. If it relates to what you're researching, by all means elaborate and give us your insight, otherwise it could just be an interesting paper you've read.
Please try to provide some insight from your understanding and please don't post things which are present in wiki.
Preferably you should link the arxiv page (not the PDF, you can easily access the PDF from the summary page but not the other way around) or any other pertinent links.
Previous weeks :
|1-10|11-20|21-30|31-40|
|----|-----|-----|-----|
|[Week 1](https://www.reddit.com/r/MachineLearning/comments/4qyjiq/machine_learning_wayr_what_are_you_reading_week_1/)|[Week 11](https://www.reddit.com/r/MachineLearning/comments/57xw56/discussion_machine_learning_wayr_what_are_you/)|[Week 21](https://www.reddit.com/r/MachineLearning/comments/60ildf/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 31](https://www.reddit.com/r/MachineLearning/comments/6s0k1u/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 2](https://www.reddit.com/r/MachineLearning/comments/4s2xqm/machine_learning_wayr_what_are_you_reading_week_2/)|[Week 12](https://www.reddit.com/r/MachineLearning/comments/5acb1t/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 22](https://www.reddit.com/r/MachineLearning/comments/64jwde/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 32](https://www.reddit.com/r/MachineLearning/comments/72ab5y/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 3](https://www.reddit.com/r/MachineLearning/comments/4t7mqm/machine_learning_wayr_what_are_you_reading_week_3/)|[Week 13](https://www.reddit.com/r/MachineLearning/comments/5cwfb6/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 23](https://www.reddit.com/r/MachineLearning/comments/674331/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 33](https://www.reddit.com/r/MachineLearning/comments/75405d/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 4](https://www.reddit.com/r/MachineLearning/comments/4ub2kw/machine_learning_wayr_what_are_you_reading_week_4/)|[Week 14](https://www.reddit.com/r/MachineLearning/comments/5fc5mh/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 24](https://www.reddit.com/r/MachineLearning/comments/68hhhb/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 34](https://www.reddit.com/r/MachineLearning/comments/782js9/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 5](https://www.reddit.com/r/MachineLearning/comments/4xomf7/machine_learning_wayr_what_are_you_reading_week_5/)|[Week 15](https://www.reddit.com/r/MachineLearning/comments/5hy4ur/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 25](https://www.reddit.com/r/MachineLearning/comments/69teiz/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 35](https://www.reddit.com/r/MachineLearning/comments/7b0av0/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 6](https://www.reddit.com/r/MachineLearning/comments/4zcyvk/machine_learning_wayr_what_are_you_reading_week_6/)|[Week 16](https://www.reddit.com/r/MachineLearning/comments/5kd6vd/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 26](https://www.reddit.com/r/MachineLearning/comments/6d7nb1/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 7](https://www.reddit.com/r/MachineLearning/comments/52t6mo/machine_learning_wayr_what_are_you_reading_week_7/)|[Week 17](https://www.reddit.com/r/MachineLearning/comments/5ob7dx/discussion_machine_learning_wayr_what_are_you/)|[Week 27](https://www.reddit.com/r/MachineLearning/comments/6gngwc/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 8](https://www.reddit.com/r/MachineLearning/comments/53heol/machine_learning_wayr_what_are_you_reading_week_8/)|[Week 18](https://www.reddit.com/r/MachineLearning/comments/5r14yd/discussion_machine_learning_wayr_what_are_you/)|[Week 28](https://www.reddit.com/r/MachineLearning/comments/6jgdva/d_machine_lear
This is a place to share machine learning research papers, journals, and articles that you're reading this week. If it relates to what you're researching, by all means elaborate and give us your insight, otherwise it could just be an interesting paper you've read.
Please try to provide some insight from your understanding and please don't post things which are present in wiki.
Preferably you should link the arxiv page (not the PDF, you can easily access the PDF from the summary page but not the other way around) or any other pertinent links.
Previous weeks :
|1-10|11-20|21-30|31-40|
|----|-----|-----|-----|
|[Week 1](https://www.reddit.com/r/MachineLearning/comments/4qyjiq/machine_learning_wayr_what_are_you_reading_week_1/)|[Week 11](https://www.reddit.com/r/MachineLearning/comments/57xw56/discussion_machine_learning_wayr_what_are_you/)|[Week 21](https://www.reddit.com/r/MachineLearning/comments/60ildf/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 31](https://www.reddit.com/r/MachineLearning/comments/6s0k1u/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 2](https://www.reddit.com/r/MachineLearning/comments/4s2xqm/machine_learning_wayr_what_are_you_reading_week_2/)|[Week 12](https://www.reddit.com/r/MachineLearning/comments/5acb1t/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 22](https://www.reddit.com/r/MachineLearning/comments/64jwde/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 32](https://www.reddit.com/r/MachineLearning/comments/72ab5y/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 3](https://www.reddit.com/r/MachineLearning/comments/4t7mqm/machine_learning_wayr_what_are_you_reading_week_3/)|[Week 13](https://www.reddit.com/r/MachineLearning/comments/5cwfb6/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 23](https://www.reddit.com/r/MachineLearning/comments/674331/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 33](https://www.reddit.com/r/MachineLearning/comments/75405d/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 4](https://www.reddit.com/r/MachineLearning/comments/4ub2kw/machine_learning_wayr_what_are_you_reading_week_4/)|[Week 14](https://www.reddit.com/r/MachineLearning/comments/5fc5mh/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 24](https://www.reddit.com/r/MachineLearning/comments/68hhhb/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 34](https://www.reddit.com/r/MachineLearning/comments/782js9/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 5](https://www.reddit.com/r/MachineLearning/comments/4xomf7/machine_learning_wayr_what_are_you_reading_week_5/)|[Week 15](https://www.reddit.com/r/MachineLearning/comments/5hy4ur/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 25](https://www.reddit.com/r/MachineLearning/comments/69teiz/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 35](https://www.reddit.com/r/MachineLearning/comments/7b0av0/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 6](https://www.reddit.com/r/MachineLearning/comments/4zcyvk/machine_learning_wayr_what_are_you_reading_week_6/)|[Week 16](https://www.reddit.com/r/MachineLearning/comments/5kd6vd/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 26](https://www.reddit.com/r/MachineLearning/comments/6d7nb1/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 7](https://www.reddit.com/r/MachineLearning/comments/52t6mo/machine_learning_wayr_what_are_you_reading_week_7/)|[Week 17](https://www.reddit.com/r/MachineLearning/comments/5ob7dx/discussion_machine_learning_wayr_what_are_you/)|[Week 27](https://www.reddit.com/r/MachineLearning/comments/6gngwc/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 8](https://www.reddit.com/r/MachineLearning/comments/53heol/machine_learning_wayr_what_are_you_reading_week_8/)|[Week 18](https://www.reddit.com/r/MachineLearning/comments/5r14yd/discussion_machine_learning_wayr_what_are_you/)|[Week 28](https://www.reddit.com/r/MachineLearning/comments/6jgdva/d_machine_lear
Reddit
From the MachineLearning community on Reddit
Explore this post and more from the MachineLearning community
ning_wayr_what_are_you_reading_week/)||
|[Week 9](https://www.reddit.com/r/MachineLearning/comments/54kvsu/machine_learning_wayr_what_are_you_reading_week_9/)|[Week 19](https://www.reddit.com/r/MachineLearning/comments/5tt9cz/discussion_machine_learning_wayr_what_are_you/)|[Week 29](https://www.reddit.com/r/MachineLearning/comments/6m9l1v/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 10](https://www.reddit.com/r/MachineLearning/comments/56s2oa/discussion_machine_learning_wayr_what_are_you/)|[Week 20](https://www.reddit.com/r/MachineLearning/comments/5wh2wb/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 30](https://www.reddit.com/r/MachineLearning/comments/6p3ha7/d_machine_learning_wayr_what_are_you_reading_week/)||
Most upvoted papers two weeks ago:
/u/Schmogel: http://hi.cs.waseda.ac.jp/~iizuka/projects/completion/en/
/u/hypertiger1: [Machine Learning for Trading](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3015609)
/u/OctThe16th: https://arxiv.org/abs/1710.02298
Besides that, there are no rules, have fun.
/r/MachineLearning
https://redd.it/7e3fx6
|[Week 9](https://www.reddit.com/r/MachineLearning/comments/54kvsu/machine_learning_wayr_what_are_you_reading_week_9/)|[Week 19](https://www.reddit.com/r/MachineLearning/comments/5tt9cz/discussion_machine_learning_wayr_what_are_you/)|[Week 29](https://www.reddit.com/r/MachineLearning/comments/6m9l1v/d_machine_learning_wayr_what_are_you_reading_week/)||
|[Week 10](https://www.reddit.com/r/MachineLearning/comments/56s2oa/discussion_machine_learning_wayr_what_are_you/)|[Week 20](https://www.reddit.com/r/MachineLearning/comments/5wh2wb/d_machine_learning_wayr_what_are_you_reading_week/)|[Week 30](https://www.reddit.com/r/MachineLearning/comments/6p3ha7/d_machine_learning_wayr_what_are_you_reading_week/)||
Most upvoted papers two weeks ago:
/u/Schmogel: http://hi.cs.waseda.ac.jp/~iizuka/projects/completion/en/
/u/hypertiger1: [Machine Learning for Trading](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3015609)
/u/OctThe16th: https://arxiv.org/abs/1710.02298
Besides that, there are no rules, have fun.
/r/MachineLearning
https://redd.it/7e3fx6
reddit
Machine Learning - WAYR (What Are You Reading) - Week 9
This is a place to share machine learning research papers, journals, and articles that you're reading this week. If it relates to what you're...
[AF] New to Flask. Best ways to deploy to EC2?
I'm pretty new to Flask overall. I recently converted a basic site of mine to use (basic) Flask. I was curious about the best/easiest ways to deploy a Flask app to EC2? I've heard Docker is an option, but I'm not exactly sure how it would work since I'm not super familiar with Docker. I've also heard that virtualenvs are a good (but not very simple?) method as well.
Anyways, any help is appreciated! Thanks!
**EDIT: Thanks for all of the suggestions everyone! I'm testing out AWS CodeStar right now. If that doesn't work I'll try Zappa or ELB!**
/r/flask
https://redd.it/7cpnrg
I'm pretty new to Flask overall. I recently converted a basic site of mine to use (basic) Flask. I was curious about the best/easiest ways to deploy a Flask app to EC2? I've heard Docker is an option, but I'm not exactly sure how it would work since I'm not super familiar with Docker. I've also heard that virtualenvs are a good (but not very simple?) method as well.
Anyways, any help is appreciated! Thanks!
**EDIT: Thanks for all of the suggestions everyone! I'm testing out AWS CodeStar right now. If that doesn't work I'll try Zappa or ELB!**
/r/flask
https://redd.it/7cpnrg
reddit
[AF] New to Flask. Best ways to deploy to EC2? • r/flask
I'm pretty new to Flask overall. I recently converted a basic site of mine to use (basic) Flask. I was curious about the best/easiest ways to...
Using custom bootstrap instead of Django templates
I have created a web app using Django, and while I find the default Admin backend useful, its a headache to customize in certain cases. I want to develop a dashboard like interface and do away with Django's Admin templates. I want to end up with something like [this](https://adminlte.io/themes/AdminLTE/index2.html) I have a REST API in place using DjangoRestFramework, but I don't understand how this could work well with plain html pages. I still want Django WSGI to "serve" my pages through Apache. What's the best way to go with this?
/r/django
https://redd.it/7e1tk3
I have created a web app using Django, and while I find the default Admin backend useful, its a headache to customize in certain cases. I want to develop a dashboard like interface and do away with Django's Admin templates. I want to end up with something like [this](https://adminlte.io/themes/AdminLTE/index2.html) I have a REST API in place using DjangoRestFramework, but I don't understand how this could work well with plain html pages. I still want Django WSGI to "serve" my pages through Apache. What's the best way to go with this?
/r/django
https://redd.it/7e1tk3
reddit
Using custom bootstrap instead of Django templates • r/django
I have created a web app using Django, and while I find the default Admin backend useful, its a headache to customize in certain cases. I want to...
Python code is running too slow, do I need to find a way to allocate more memory to python process?
I have python code that can extract a zip file (tar.gz) . If I use the code, it takes a really long time (~1.5 hour) but if I unzip it directly using 7zip it takes less than 5 minutes, so I am guessing there is something impeding the processing power of python.
I am trying to run this code https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/udacity/1_notmnist.ipynb
for convenience, here a version of the code that doesn't require numpy, scripy, etc. EDIT. The formatting is messed up. In meanwhile just look at the stack over flow implementation.
https://stackoverflow.com/questions/47392697/python-code-is-running-too-slow-do-i-need-to-find-a-way-to-allocate-more-memory
> url = 'https://commondatastorage.googleapis.com/books1000/'
> last_percent_reported = None
> data_root = '.' # Change me to store data elsewhere
>
>
> def download_progress_hook(count, blockSize, totalSize):
> """A hook to report the progress of a download. This is mostly intended for users with
> slow internet connections. Reports every 5% change in download progress.
> """
> global last_percent_reported
> percent = int(count * blockSize * 100 / totalSize)
>
> if last_percent_reported != percent:
> if percent % 5 == 0:
> sys.stdout.write("%s%%" % percent)
> sys.stdout.flush()
> else:
> sys.stdout.write(".")
> sys.stdout.flush()
>
> last_percent_reported = percent
>
>
> def maybe_download(filename, expected_bytes, force=False):
> """Download a file if not present, and make sure it's the right size."""
> dest_filename = os.path.join(data_root, filename)
> if force or not os.path.exists(dest_filename):
> print('Attempting to download:', filename)
> filename, _ = urlretrieve(url + filename, dest_filename, reporthook=download_progress_hook)
> print('\nDownload Complete!')
> statinfo = os.stat(dest_filename)
> if statinfo.st_size == expected_bytes:
> print('Found and verified', dest_filename)
> else:
> raise Exception(
> 'Failed to verify ' + dest_filename + '. Can you get to it with a browser?')
> return dest_filename
>
>
> train_filename = maybe_download('notMNIST_large.tar.gz', 247336696)
> test_filename = maybe_download('notMNIST_small.tar.gz', 8458043)
>
> num_classes = 10
>
> def maybe_extract(filename, force=False):
> root = os.path.splitext(os.path.splitext(filename)[0])[0] # remove .tar.gz
> if os.path.isdir(root) and not force:
> # You may override by setting force=True.
> print('%s already present - Skipping extraction of %s.' % (root, filename))
> else:
> print('Extracting data for %s. This may take a while. Please wait.' % root)
> tar = tarfile.open(filename)
> sys.stdout.flush()
> tar.extractall(data_root)
> tar.close()
> data_folders = [
> os.path.join(root, d) for d in sorted(os.listdir(root))
> if os.path.isdir(os.path.join(root, d))]
> if len(data_folders) != num_classes:
> raise Exception(
> 'Expected %d folders, one per class. Found %d instead.' % (
> num_classes, len(data_folders)))
> print(data_folders)
> return data_folders
>
> train_folders = maybe_extract(train_filename)
> test_folders = maybe_extract(test_filename)
I am using 64-bit 3.6.3 python on a 64-bit windows 10 laptop, with 12 gigs of RAM.
/r/Python
https://redd.it/7e8nni
I have python code that can extract a zip file (tar.gz) . If I use the code, it takes a really long time (~1.5 hour) but if I unzip it directly using 7zip it takes less than 5 minutes, so I am guessing there is something impeding the processing power of python.
I am trying to run this code https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/udacity/1_notmnist.ipynb
for convenience, here a version of the code that doesn't require numpy, scripy, etc. EDIT. The formatting is messed up. In meanwhile just look at the stack over flow implementation.
https://stackoverflow.com/questions/47392697/python-code-is-running-too-slow-do-i-need-to-find-a-way-to-allocate-more-memory
> url = 'https://commondatastorage.googleapis.com/books1000/'
> last_percent_reported = None
> data_root = '.' # Change me to store data elsewhere
>
>
> def download_progress_hook(count, blockSize, totalSize):
> """A hook to report the progress of a download. This is mostly intended for users with
> slow internet connections. Reports every 5% change in download progress.
> """
> global last_percent_reported
> percent = int(count * blockSize * 100 / totalSize)
>
> if last_percent_reported != percent:
> if percent % 5 == 0:
> sys.stdout.write("%s%%" % percent)
> sys.stdout.flush()
> else:
> sys.stdout.write(".")
> sys.stdout.flush()
>
> last_percent_reported = percent
>
>
> def maybe_download(filename, expected_bytes, force=False):
> """Download a file if not present, and make sure it's the right size."""
> dest_filename = os.path.join(data_root, filename)
> if force or not os.path.exists(dest_filename):
> print('Attempting to download:', filename)
> filename, _ = urlretrieve(url + filename, dest_filename, reporthook=download_progress_hook)
> print('\nDownload Complete!')
> statinfo = os.stat(dest_filename)
> if statinfo.st_size == expected_bytes:
> print('Found and verified', dest_filename)
> else:
> raise Exception(
> 'Failed to verify ' + dest_filename + '. Can you get to it with a browser?')
> return dest_filename
>
>
> train_filename = maybe_download('notMNIST_large.tar.gz', 247336696)
> test_filename = maybe_download('notMNIST_small.tar.gz', 8458043)
>
> num_classes = 10
>
> def maybe_extract(filename, force=False):
> root = os.path.splitext(os.path.splitext(filename)[0])[0] # remove .tar.gz
> if os.path.isdir(root) and not force:
> # You may override by setting force=True.
> print('%s already present - Skipping extraction of %s.' % (root, filename))
> else:
> print('Extracting data for %s. This may take a while. Please wait.' % root)
> tar = tarfile.open(filename)
> sys.stdout.flush()
> tar.extractall(data_root)
> tar.close()
> data_folders = [
> os.path.join(root, d) for d in sorted(os.listdir(root))
> if os.path.isdir(os.path.join(root, d))]
> if len(data_folders) != num_classes:
> raise Exception(
> 'Expected %d folders, one per class. Found %d instead.' % (
> num_classes, len(data_folders)))
> print(data_folders)
> return data_folders
>
> train_folders = maybe_extract(train_filename)
> test_folders = maybe_extract(test_filename)
I am using 64-bit 3.6.3 python on a 64-bit windows 10 laptop, with 12 gigs of RAM.
/r/Python
https://redd.it/7e8nni
Taskmap: A python framework for managing task dependencies and executing coroutines across multiple cores
https://github.com/n-s-f/taskmap
/r/Python
https://redd.it/7eag9s
https://github.com/n-s-f/taskmap
/r/Python
https://redd.it/7eag9s
GitHub
n-s-f/taskmap
taskmap - Python dependency graph for parallel and/or async execution
Python 3.6:Drawing LINEGRAPHS and Saving it as a PDF!
https://youtu.be/PdbLVbzoXYI
/r/pystats
https://redd.it/7ebo5u
https://youtu.be/PdbLVbzoXYI
/r/pystats
https://redd.it/7ebo5u
YouTube
Python 3.6: Drawing LINEGRAPHS and Saving it as a PDF!
Welcome to AnalystRising!!! This episode will be looking at DRAWING LINEGRAPHS in Python. This is a step towards building incredible simulations and models t...
If I built almost exactly the same site using pure Django vs DRF + VueJS, what would be the performance differences ?
Say I have an online shop that gets about 1000 hits per day.
One version uses Django for the templating, one uses Vue with Django-Rest-Framework for everything under the hood.
What would be the performance differences ? What is the cost of templating with Django? Would the gap be significant enough to warrant changing between one or the other ? Or is the impact minimal, leaving the decision be based on other factors like UX ?
/r/django
https://redd.it/7ebqq4
Say I have an online shop that gets about 1000 hits per day.
One version uses Django for the templating, one uses Vue with Django-Rest-Framework for everything under the hood.
What would be the performance differences ? What is the cost of templating with Django? Would the gap be significant enough to warrant changing between one or the other ? Or is the impact minimal, leaving the decision be based on other factors like UX ?
/r/django
https://redd.it/7ebqq4
reddit
If I built almost exactly the same site using pure... • r/django
Say I have an online shop that gets about 1000 hits per day. One version uses Django for the templating, one uses Vue with Django-Rest-Framework...
website review
I just made this website using django 1.8. I want to get some reviews and suggestions??
www.frontboard.ml
/r/djangolearning
https://redd.it/7ebqvh
I just made this website using django 1.8. I want to get some reviews and suggestions??
www.frontboard.ml
/r/djangolearning
https://redd.it/7ebqvh
reddit
website review • r/djangolearning
I just made this website using django 1.8. I want to get some reviews and suggestions?? www.frontboard.ml
How to save JSON API response in database?
Hi, I am new to django and am currently trying to connect to third-party JSON API, retrieve information and save it into the database. I am able to retrieve the data from views.py but I want to run a API query every 1 minute and save updated results into the database. Can anyone help me with it?
/r/django
https://redd.it/7e0olm
Hi, I am new to django and am currently trying to connect to third-party JSON API, retrieve information and save it into the database. I am able to retrieve the data from views.py but I want to run a API query every 1 minute and save updated results into the database. Can anyone help me with it?
/r/django
https://redd.it/7e0olm
reddit
How to save JSON API response in database? • r/django
Hi, I am new to django and am currently trying to connect to third-party JSON API, retrieve information and save it into the database. I am able...
Complete scrapy tutorial : get data from reddit, amazon, pexel, steam, airbnb
https://tanpham.org/
/r/Python
https://redd.it/7ebcd9
https://tanpham.org/
/r/Python
https://redd.it/7ebcd9
reddit
Complete scrapy tutorial : get data from reddit,... • r/Python
4 points and 0 comments so far on reddit
Deploying a Flask app into Docker Swarm (xpost /r/python)
[Link first because this is what everyone wants](https://github.com/justanr/flaskbb-swarm)
I recently set up a docker swarm in my home lab and I realized that just putting tooling (traefik, portainer, registry, etc) on it was silly. So I decided to document how I went about deploying a non-trivial application: [FlaskBB](https://github.com/sh4nks/flaskbb) -- which disclosure I'm a maintainer on. I'm also defining "non-trivial" as has multiple moving parts that work together in interesting ways (for some definition of interesting) -- in this case, there is the actual application container, a celery container, redis, a postgres database and finally [an nginx container](https://i.imgflip.com/1z9w62.jpg).
The entrypoint is Traefik running as a Swarm service, which then hands off traffic to the Nginx container which decides to serve either static content or pass to the uWSGI container (in the future, I plan on using frontend rules to partition this on the Traefik layer rather than the nginx layer). Docker networks are used to partition which services are allowed to talk to each other. Secrets and Configs are used to separate configuration logic from the code running in containers.
The nuts and bolts are specific to FlaskBB but hopefully can provide a template for usage with other applications. I tried to be thorough without delving down rabbit holes too much, but let me know if I missed something or should've been clearer some where. :)
/r/flask
https://redd.it/7cmwpz
[Link first because this is what everyone wants](https://github.com/justanr/flaskbb-swarm)
I recently set up a docker swarm in my home lab and I realized that just putting tooling (traefik, portainer, registry, etc) on it was silly. So I decided to document how I went about deploying a non-trivial application: [FlaskBB](https://github.com/sh4nks/flaskbb) -- which disclosure I'm a maintainer on. I'm also defining "non-trivial" as has multiple moving parts that work together in interesting ways (for some definition of interesting) -- in this case, there is the actual application container, a celery container, redis, a postgres database and finally [an nginx container](https://i.imgflip.com/1z9w62.jpg).
The entrypoint is Traefik running as a Swarm service, which then hands off traffic to the Nginx container which decides to serve either static content or pass to the uWSGI container (in the future, I plan on using frontend rules to partition this on the Traefik layer rather than the nginx layer). Docker networks are used to partition which services are allowed to talk to each other. Secrets and Configs are used to separate configuration logic from the code running in containers.
The nuts and bolts are specific to FlaskBB but hopefully can provide a template for usage with other applications. I tried to be thorough without delving down rabbit holes too much, but let me know if I missed something or should've been clearer some where. :)
/r/flask
https://redd.it/7cmwpz
GitHub
justanr/flaskbb-swarm
flaskbb-swarm - Set up FlaskBB in a Docker Swarm
Automatically downloading PDF using Django running code on multiple ports (X-post from /r/djangolearning)
When a user uploads a PDF, it is modified using ReportLab and the modified PDF is automatically downloaded. Below is my code for processing the files and returning them.
def process_report(request):
# Handle file upload
if request.method == 'POST':
report_file = request.FILES.pop('file')[0]
merged_pdf, namefinal = pdfAnalyzingFunction(report_file)
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="{}"'.format(namefinal)
response.write(merged_pdf.getvalue())
return response
else:
return HttpResponseBadRequest('Must be Post')
I am using Django to render and return content. The above code worked and was able to download files automatically when I just had some simple HTML on a localhost:8000 port. However, after building a frontend on a different port, localhost:3000, I was able to successfully run and generate a modified PDF but it no longer downloaded automatically (with the PDF modifying code running on the localhost:8000 port still).
On my localhost:3000 port network tab I can see the uploaded file, and am wondering why it is not downloading.
Request URL: http://localhost:8000/process_report
Request Method : POST
Satus Code: 200 OK
Host: localhost:8000
Origin: http://localhost:3000
Referer: http://localhost:3000/
Unclear as to why it appears my PDF is rendering, but not automatically downloading now. Is there something I need to know about generating a response object on one port and attempting to download it automatically on a separate port?
/r/django
https://redd.it/7ees5t
When a user uploads a PDF, it is modified using ReportLab and the modified PDF is automatically downloaded. Below is my code for processing the files and returning them.
def process_report(request):
# Handle file upload
if request.method == 'POST':
report_file = request.FILES.pop('file')[0]
merged_pdf, namefinal = pdfAnalyzingFunction(report_file)
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="{}"'.format(namefinal)
response.write(merged_pdf.getvalue())
return response
else:
return HttpResponseBadRequest('Must be Post')
I am using Django to render and return content. The above code worked and was able to download files automatically when I just had some simple HTML on a localhost:8000 port. However, after building a frontend on a different port, localhost:3000, I was able to successfully run and generate a modified PDF but it no longer downloaded automatically (with the PDF modifying code running on the localhost:8000 port still).
On my localhost:3000 port network tab I can see the uploaded file, and am wondering why it is not downloading.
Request URL: http://localhost:8000/process_report
Request Method : POST
Satus Code: 200 OK
Host: localhost:8000
Origin: http://localhost:3000
Referer: http://localhost:3000/
Unclear as to why it appears my PDF is rendering, but not automatically downloading now. Is there something I need to know about generating a response object on one port and attempting to download it automatically on a separate port?
/r/django
https://redd.it/7ees5t
reddit
Automatically downloading PDF using Django running code... • r/django
When a user uploads a PDF, it is modified using ReportLab and the modified PDF is automatically downloaded. Below is my code for processing the...