Scaling Python/Flask Microservice with Kubernetes
http://blog.apcelent.com/scaling-python-microservices-kubernetes.html
/r/flask
https://redd.it/6aqt21
http://blog.apcelent.com/scaling-python-microservices-kubernetes.html
/r/flask
https://redd.it/6aqt21
reddit
Scaling Python/Flask Microservice with Kubernetes • r/flask
1 points and 0 comments so far on reddit
Getting started with PyGObject
https://pygobject.readthedocs.io/en/latest/getting_started.html
/r/Python
https://redd.it/6aq936
https://pygobject.readthedocs.io/en/latest/getting_started.html
/r/Python
https://redd.it/6aq936
nbviewer does not see notebook in Github repository?
Hi Guys. Does anyone know why nbviewer would not be able to see a notebook I uploaded to one of my Github repositories? If I go to the repository, I can see the notebook and view its contents, but nbviewer will not recognize that it's there. Has anyone else experienced this?
/r/IPython
https://redd.it/6asfa6
Hi Guys. Does anyone know why nbviewer would not be able to see a notebook I uploaded to one of my Github repositories? If I go to the repository, I can see the notebook and view its contents, but nbviewer will not recognize that it's there. Has anyone else experienced this?
/r/IPython
https://redd.it/6asfa6
reddit
nbviewer does not see notebook in Github repository? • r/IPython
Hi Guys. Does anyone know why nbviewer would not be able to see a notebook I uploaded to one of my Github repositories? If I go to the repository,...
Invalid syntax when invoking package name?
I'm learning to use ipython qtconsole with scipy tools to practice graphing differential equations. I wrote a short script to set up the environment to work in. [Here is the script](https://pastebin.com/uhGRYycE).
When I use it in qtconsole, it gives me this error:
File "/Users/me/DiffEq/deenv.py", line 9
%matplotlib inline
^
SyntaxError: invalid syntax
However, when I just type "%matplotlib inline" into the console, it gives me no such error.
Why is this?
/r/IPython
https://redd.it/6b0vlw
I'm learning to use ipython qtconsole with scipy tools to practice graphing differential equations. I wrote a short script to set up the environment to work in. [Here is the script](https://pastebin.com/uhGRYycE).
When I use it in qtconsole, it gives me this error:
File "/Users/me/DiffEq/deenv.py", line 9
%matplotlib inline
^
SyntaxError: invalid syntax
However, when I just type "%matplotlib inline" into the console, it gives me no such error.
Why is this?
/r/IPython
https://redd.it/6b0vlw
Pastebin
from sympy import init_printing # Latex printing to screen import matplotlib. - Pastebin.com
How do I remove the In [ ] Out [ ] in a Jupyter notebook?
When coding in a Jupyter notebook, is it possible to disable showing the In [ ], Out [ ] next to each code cell? If not, is it possible to do when rendering the notebook using NBViewer? I'd like my notebooks to look a little nicer without the In [ ], Out [ ] sticking out next to every cell, so I'd like to get rid of these things. Thanks!
/r/IPython
https://redd.it/6ascqz
When coding in a Jupyter notebook, is it possible to disable showing the In [ ], Out [ ] next to each code cell? If not, is it possible to do when rendering the notebook using NBViewer? I'd like my notebooks to look a little nicer without the In [ ], Out [ ] sticking out next to every cell, so I'd like to get rid of these things. Thanks!
/r/IPython
https://redd.it/6ascqz
reddit
How do I remove the In [ ] Out [ ] in a Jupyter notebook? • r/IPython
When coding in a Jupyter notebook, is it possible to disable showing the In [ ], Out [ ] next to each code cell? If not, is it possible to do when...
Checkbox in the admin that changes search_fields in real time
I would like to have a checkbox/toggle/etc under the search_fields box. When the checkbox is/isn't checked, it will change the get_search_results() function. I'd prefer for this to be done using JavaScript (no JQuery if possible!) so that the search results still change after the "Search" button is pressed, but without the page needing to reload.
Please let me know of any insights you might have. Thank you!
/r/django
https://redd.it/6b0mvh
I would like to have a checkbox/toggle/etc under the search_fields box. When the checkbox is/isn't checked, it will change the get_search_results() function. I'd prefer for this to be done using JavaScript (no JQuery if possible!) so that the search results still change after the "Search" button is pressed, but without the page needing to reload.
Please let me know of any insights you might have. Thank you!
/r/django
https://redd.it/6b0mvh
reddit
Checkbox in the admin that changes search_fields in... • r/django
I would like to have a checkbox/toggle/etc under the search_fields box. When the checkbox is/isn't checked, it will change the...
How many people are around? Monitor wifi signals to count the number of cellphones around you
https://github.com/schollz/howmanypeoplearearound
/r/Python
https://redd.it/6aytne
https://github.com/schollz/howmanypeoplearearound
/r/Python
https://redd.it/6aytne
GitHub
GitHub - schollz/howmanypeoplearearound: Count the number of people around you by monitoring wifi signals :satellite:
Count the number of people around you :family_man_man_boy: by monitoring wifi signals :satellite: - GitHub - schollz/howmanypeoplearearound: Count the number of people around you by monitoring wifi...
Example API to query Google Places, Yelp and FourSquare at the same time, with Bayesian Rankings
https://github.com/octohedron/TouristFriend
/r/flask
https://redd.it/6az5ee
https://github.com/octohedron/TouristFriend
/r/flask
https://redd.it/6az5ee
GitHub
octohedron/TouristFriend
🌆 TouristFriend API lets you query Google Places, Yelp and FourSquare at the same time, with bayesian rankings!
Django limit the choices of a many to many relationship
https://stackoverflow.com/questions/43960840/django-limit-the-choices-of-a-many-to-many-relationship
/r/django
https://redd.it/6b2ooy
https://stackoverflow.com/questions/43960840/django-limit-the-choices-of-a-many-to-many-relationship
/r/django
https://redd.it/6b2ooy
Stackoverflow
Django limit the choices of a many to many relationship
I know the title says the question has been asked before but the situation is different.
I have something called Agent:
class Agent(models.Model):
user = models.ForeignKey(settings.AUTH_USER_...
I have something called Agent:
class Agent(models.Model):
user = models.ForeignKey(settings.AUTH_USER_...
Django REST framework 3.6.3 now released.
http://www.django-rest-framework.org/topics/release-notes/#363
/r/django
https://redd.it/6asat4
http://www.django-rest-framework.org/topics/release-notes/#363
/r/django
https://redd.it/6asat4
sanitizing code for an exec command
I have a script that runs code provided by the user via an exec command. I know this can be considered a security hazard. As a precaution, before compiling I look for the term "import" anywhere in the code and if I find it the code is rejected. When code is executed, it's only given access to the builtins and a specific locals dictionary of functions and classes that it is meant to be able to interact with. The program is running on a remote server so the user cannot see any output to stdout.
Can anyone tell me if/how this is still unsafe? Is there something I'm not considering that would allow a user to run malicious code?
Thanks for any input.
/r/Python
https://redd.it/6b3zzy
I have a script that runs code provided by the user via an exec command. I know this can be considered a security hazard. As a precaution, before compiling I look for the term "import" anywhere in the code and if I find it the code is rejected. When code is executed, it's only given access to the builtins and a specific locals dictionary of functions and classes that it is meant to be able to interact with. The program is running on a remote server so the user cannot see any output to stdout.
Can anyone tell me if/how this is still unsafe? Is there something I'm not considering that would allow a user to run malicious code?
Thanks for any input.
/r/Python
https://redd.it/6b3zzy
reddit
sanitizing code for an exec command • r/Python
I have a script that runs code provided by the user via an exec command. I know this can be considered a security hazard. As a precaution,...
Help with
class Place(models.Model):
address = models.CharField()
class Restaurant(Place):
unique_to_restaurant = models.CharField()
competitors = models.ManyToManyField(Place)
class Stadium(Place):
unique_to_stadium = models.TextField()
class Favorites(models.Model):
description = models.TextField()
favorites = models.ManyToManyField(Place)
I'm not great with databases and this is really giving me headaches. What is the best way to do this database? This is the gist of what I have currently, which functionally does exactly what I need. However the amount of queries are out of control. The children of Place share a lot of the same fields as Place but have some unique ones. I need to query place and favorites often. Favorites must be able to access the children of Place and the children of Place sometimes access the children of Place as well. Generic Foreign keys don't work (I don't think?) because the instance will be used more than once, so I would need to clone an instance. If anybody could help me out that would be absolutely amazing.
Edit: Sorry about the title! I was worried so much about the formatting of the code that I forgot to complete it and now I'm stuck with it :(
/r/django
https://redd.it/6b4cbe
class Place(models.Model):
address = models.CharField()
class Restaurant(Place):
unique_to_restaurant = models.CharField()
competitors = models.ManyToManyField(Place)
class Stadium(Place):
unique_to_stadium = models.TextField()
class Favorites(models.Model):
description = models.TextField()
favorites = models.ManyToManyField(Place)
I'm not great with databases and this is really giving me headaches. What is the best way to do this database? This is the gist of what I have currently, which functionally does exactly what I need. However the amount of queries are out of control. The children of Place share a lot of the same fields as Place but have some unique ones. I need to query place and favorites often. Favorites must be able to access the children of Place and the children of Place sometimes access the children of Place as well. Generic Foreign keys don't work (I don't think?) because the instance will be used more than once, so I would need to clone an instance. If anybody could help me out that would be absolutely amazing.
Edit: Sorry about the title! I was worried so much about the formatting of the code that I forgot to complete it and now I'm stuck with it :(
/r/django
https://redd.it/6b4cbe
reddit
Help with • r/django
class Place(models.Model): address = models.CharField() class Restaurant(Place): unique_to_restaurant = models.CharField() ...
Need help with making a Python Numpy function for calculating distance of line in grid cells
So the situation is basically that there is a unit square (with corners (0,0),(1,0),(0,1) and (1,1)) which is made up by n*n (so n-squared) square 'grid cells'.
I need to define a function F(n,a,b) that takes as input 2 points a and b in the square, for example a=[0.3,0.4] and b=[0.6,0.8], and n (the amount of grid cells per side), and that function should give me (in very good approximation) the total distance that a straight line between those points covers in each grid cell.
So it should return an ordered list of n*n length, each element of the list representing the distance that the straight line covers in that grid cell. The order should be so that the top left grid cell is the 0th element (first element) and then the grid cell to the right of it should be the second element, so row by row.
EXAMPLE:
Suppose we take the very simple and trivial situation n=2, so 4 grid cells, and the coordinates [0,0] and [1,1].
Then the function F(2,[0,0],[1,1]) should return [0, sqrt(2)/2, sqrt(2)/2, 0] (as a numpy array preferably, and of course sqrt(2)/2 as a numerical approximation).
The function should be reasonably well optimised for like 100*100 grid cells and should be very fast (<0.5 sec)
I really hope anyone can help me with this because I've been struggling with the problem for like 10 hours or more already.
/r/Python
https://redd.it/6b4cd2
So the situation is basically that there is a unit square (with corners (0,0),(1,0),(0,1) and (1,1)) which is made up by n*n (so n-squared) square 'grid cells'.
I need to define a function F(n,a,b) that takes as input 2 points a and b in the square, for example a=[0.3,0.4] and b=[0.6,0.8], and n (the amount of grid cells per side), and that function should give me (in very good approximation) the total distance that a straight line between those points covers in each grid cell.
So it should return an ordered list of n*n length, each element of the list representing the distance that the straight line covers in that grid cell. The order should be so that the top left grid cell is the 0th element (first element) and then the grid cell to the right of it should be the second element, so row by row.
EXAMPLE:
Suppose we take the very simple and trivial situation n=2, so 4 grid cells, and the coordinates [0,0] and [1,1].
Then the function F(2,[0,0],[1,1]) should return [0, sqrt(2)/2, sqrt(2)/2, 0] (as a numpy array preferably, and of course sqrt(2)/2 as a numerical approximation).
The function should be reasonably well optimised for like 100*100 grid cells and should be very fast (<0.5 sec)
I really hope anyone can help me with this because I've been struggling with the problem for like 10 hours or more already.
/r/Python
https://redd.it/6b4cd2
reddit
Need help with making a Python Numpy function for... • r/Python
So the situation is basically that there is a unit square (with corners (0,0),(1,0),(0,1) and (1,1)) which is made up by n*n (so n-squared) square...
Can anybody think of a way to do this with less variables?
def approxPi( error ):
num = 4
denom = 1
curr = num/denom
prev = 0
while abs(curr-prev)>error:
num *= -1
denom += 2
prev = curr
curr += num/denom
return curr
/r/Python
https://redd.it/6b56tn
def approxPi( error ):
num = 4
denom = 1
curr = num/denom
prev = 0
while abs(curr-prev)>error:
num *= -1
denom += 2
prev = curr
curr += num/denom
return curr
/r/Python
https://redd.it/6b56tn
reddit
Can anybody think of a way to do this with less variables? • r/Python
def approxPi( error ): num = 4 denom = 1 curr = num/denom prev = 0 while abs(curr-prev)>error: ...
[D] /r/MachineLearning should do an unconference
Reject, Accept or In Submission? Why not post your paper here?
This field is moving too fast to wait 6 months to see the great research that's happening (and that's assuming the review process isn't noisy).
/r/MachineLearning has already been an unofficial mini-conference for the papers submitted here. I find the best discussion happens when the authors show up to answer questions and address comments. It seems like this is happening mostly by coincidence. Someone will post a paper they like and the authors will happen to notice and engage in the discussion.
It stands to reason that if this happens so often by chance, there's enough critical mass of users here to create something more official. Let's get authors posting their work and discussing it on /r/MachineLearning, sort of like a virtual poster session.
/r/MachineLearning
https://redd.it/6ay2ac
Reject, Accept or In Submission? Why not post your paper here?
This field is moving too fast to wait 6 months to see the great research that's happening (and that's assuming the review process isn't noisy).
/r/MachineLearning has already been an unofficial mini-conference for the papers submitted here. I find the best discussion happens when the authors show up to answer questions and address comments. It seems like this is happening mostly by coincidence. Someone will post a paper they like and the authors will happen to notice and engage in the discussion.
It stands to reason that if this happens so often by chance, there's enough critical mass of users here to create something more official. Let's get authors posting their work and discussing it on /r/MachineLearning, sort of like a virtual poster session.
/r/MachineLearning
https://redd.it/6ay2ac
reddit
[D] /r/MachineLearning should do an unconference • r/MachineLearning
Reject, Accept or In Submission? Why not post your paper here? This field is moving too fast to wait 6 months to see the great research that's...
Ordering of Fields using WTForms-Alchemy and Flask-Bootstrap quickform
I'm trying to use `WTForms-Alchemy` and the `Flask-Bootstrap` quickform. I am adding some fields and a submit button as described in the [WTForms-Alchemy Docs](https://wtforms-alchemy.readthedocs.io/en/latest/column_conversion.html#adding-overriding-fields) to the form created with `WTForms-Alchemy`.
Unfortunately the quickform function then renders the added fields before the automatically added by `WTForms-Alchemy` resulting the submit button to be in the middle of the form instead of the end.
Is there some fix to influence this ordering?
/r/flask
https://redd.it/6b5clt
I'm trying to use `WTForms-Alchemy` and the `Flask-Bootstrap` quickform. I am adding some fields and a submit button as described in the [WTForms-Alchemy Docs](https://wtforms-alchemy.readthedocs.io/en/latest/column_conversion.html#adding-overriding-fields) to the form created with `WTForms-Alchemy`.
Unfortunately the quickform function then renders the added fields before the automatically added by `WTForms-Alchemy` resulting the submit button to be in the middle of the form instead of the end.
Is there some fix to influence this ordering?
/r/flask
https://redd.it/6b5clt
I made a style-checking script in python for an introductory programming class and would love feedback!
https://github.com/IllyaStarikov
/r/Python
https://redd.it/6b6bmo
https://github.com/IllyaStarikov
/r/Python
https://redd.it/6b6bmo
GitHub
IllyaStarikov (Illya Starikov)
IllyaStarikov has 12 repositories available. Follow their code on GitHub.
dealing with blanket try/excepts
I'm jumping on a new codebase that where the previous developer was aggressively solving problems by try/excepting throughout every code path. I'm slowly removing these but there're hundreds if not thousands of try/except/pass.
One thing I'd like to do to help me out as I go is to actually get these excepts to at least log. ideally I'd love it if I could define a python logging object that is logged to with a traceback every time an exception is raised *anywhere*. this needs to be automatic, as I dont want to manually go through it all right now.
any ideas?
/r/Python
https://redd.it/6b77cl
I'm jumping on a new codebase that where the previous developer was aggressively solving problems by try/excepting throughout every code path. I'm slowly removing these but there're hundreds if not thousands of try/except/pass.
One thing I'd like to do to help me out as I go is to actually get these excepts to at least log. ideally I'd love it if I could define a python logging object that is logged to with a traceback every time an exception is raised *anywhere*. this needs to be automatic, as I dont want to manually go through it all right now.
any ideas?
/r/Python
https://redd.it/6b77cl
reddit
dealing with blanket try/excepts • r/Python
I'm jumping on a new codebase that where the previous developer was aggressively solving problems by try/excepting throughout every code path. I'm...
Need help dynamically creating buttons with different images and commands for each button.
Okay, I'll jump right into it. I need to dynamically create buttons that have different images and commands. I'm making a loot logging program for an MMO. You select an NPC from a list and the buttons populate with images associated with the loot the NPC can drop. When clicked, they add the text name (name of item dropped) to a list which is displayed in a label.
I have these buttons working properly (image changes when NPC changes, text added to list/label changes as well). But, I don't want to create these buttons statically for two reasons.
1. Different NPC's have different amounts of items they can drop so I want the number of buttons to depend on the length of the loot table.
2. I don't want my code to include dozens of manually written buttons, it seems sloppy and inefficient.
I have tried this code below
def create_loot_buttons():
global lootImages
buttons = len(currentDropTable)
for i in range(0, buttons):
itemPhoto.config(file="ItemSprites/" + itemIDs[currentDropTable[i]] + ".png")
lootImages.append(itemPhoto)
button = Button(dropTableButtons, image = lootImages[i])
button.pack()
Basically all of the buttons have the same image. I thought if I stored images in a list (see lootImages[]), it would save them to an index and I could create the buttons referencing the index number in this list, but it doesn't work).
If you need more info about my program, let me know. This is my first Python project, so the solution may be easy or staring me in the face but I've worked on it for awhile and searched to no avail.
Thank you.
/r/Python
https://redd.it/6b7aak
Okay, I'll jump right into it. I need to dynamically create buttons that have different images and commands. I'm making a loot logging program for an MMO. You select an NPC from a list and the buttons populate with images associated with the loot the NPC can drop. When clicked, they add the text name (name of item dropped) to a list which is displayed in a label.
I have these buttons working properly (image changes when NPC changes, text added to list/label changes as well). But, I don't want to create these buttons statically for two reasons.
1. Different NPC's have different amounts of items they can drop so I want the number of buttons to depend on the length of the loot table.
2. I don't want my code to include dozens of manually written buttons, it seems sloppy and inefficient.
I have tried this code below
def create_loot_buttons():
global lootImages
buttons = len(currentDropTable)
for i in range(0, buttons):
itemPhoto.config(file="ItemSprites/" + itemIDs[currentDropTable[i]] + ".png")
lootImages.append(itemPhoto)
button = Button(dropTableButtons, image = lootImages[i])
button.pack()
Basically all of the buttons have the same image. I thought if I stored images in a list (see lootImages[]), it would save them to an index and I could create the buttons referencing the index number in this list, but it doesn't work).
If you need more info about my program, let me know. This is my first Python project, so the solution may be easy or staring me in the face but I've worked on it for awhile and searched to no avail.
Thank you.
/r/Python
https://redd.it/6b7aak
reddit
Need help dynamically creating buttons with different... • r/Python
Okay, I'll jump right into it. I need to dynamically create buttons that have different images and commands. I'm making a loot logging program for...