How can I dynamically change the file extension in a relative link from IPYNB to HTML when downloading a notebook as HTML?
I currently have a line inside a notebook (File1.ipynb):
[File 2](File2.ipynb)
When downloading both the files as HTML, this link is hard-coded, and hence when I click on the link in the generated *File1.html*, it can't find the file, because it refers to ipynb and not to html.
I could try:
* using sed to replace all occurrences of ipynb with html
* hard-coding html inside the notebook, which will prevent me from using the links when I'm editing the notebook.
But, is there an alternative?
Is there, perhaps, a way to specify two links inside the notebook such that if the browser fails to find the first one, it'll try the second? I tried searching for such a method. I couldn't find it.
/r/IPython
https://redd.it/8ct3ia
I currently have a line inside a notebook (File1.ipynb):
[File 2](File2.ipynb)
When downloading both the files as HTML, this link is hard-coded, and hence when I click on the link in the generated *File1.html*, it can't find the file, because it refers to ipynb and not to html.
I could try:
* using sed to replace all occurrences of ipynb with html
* hard-coding html inside the notebook, which will prevent me from using the links when I'm editing the notebook.
But, is there an alternative?
Is there, perhaps, a way to specify two links inside the notebook such that if the browser fails to find the first one, it'll try the second? I tried searching for such a method. I couldn't find it.
/r/IPython
https://redd.it/8ct3ia
reddit
How can I dynamically change the file extension in a... • r/IPython
I currently have a line inside a notebook (File1.ipynb): [File 2](File2.ipynb) When downloading both the files as HTML, this link is...
jQuery/AJAX get Request format?
I've got a post request working pretty well
$.post('/discount', {
time_left: distance / 60000,
ban_id: id
})
So say for example, with my get request, all I want to do is actually grab some data from Python Flask, namely in my /discount route I have a variable named d_code which is my discount code. All I simply want to do is grab this variable and in the function of the GET request, I want to change the innerHTML of a paragraph just to show the discount code.
Fairly simple, but I don't really understand how to do the get request correctly.
Bonus: Do you think a flask app with gunicorn can handle 10k-100k users a day? Hosted on Heroku.
/r/flask
https://redd.it/8crflf
I've got a post request working pretty well
$.post('/discount', {
time_left: distance / 60000,
ban_id: id
})
So say for example, with my get request, all I want to do is actually grab some data from Python Flask, namely in my /discount route I have a variable named d_code which is my discount code. All I simply want to do is grab this variable and in the function of the GET request, I want to change the innerHTML of a paragraph just to show the discount code.
Fairly simple, but I don't really understand how to do the get request correctly.
Bonus: Do you think a flask app with gunicorn can handle 10k-100k users a day? Hosted on Heroku.
/r/flask
https://redd.it/8crflf
reddit
jQuery/AJAX get Request format? • r/flask
I've got a post request working pretty well $.post('/discount', { time_left: distance / 60000, ban_id: id }) So say for example,...
Sending Email For Errors In Django - Stack Expressions
https://www.stackexpressions.com/sending-email-for-errors-django/
/r/djangolearning
https://redd.it/8cunbq
https://www.stackexpressions.com/sending-email-for-errors-django/
/r/djangolearning
https://redd.it/8cunbq
Stack Expressions
Sending Email For Errors In Django - Stack Expressions
Email notification is better for critical errors happening in our application. Because, we cannot open the application logs in the middle of the night. Django has a built in feature for sending emails in Django apps. AdminEmailHandler is meant to do the job…
[N] TensorFlow 1.8.0 Release Candidate Announced
https://github.com/tensorflow/tensorflow/releases/tag/v1.8.0-rc0
/r/MachineLearning
https://redd.it/8cq4gj
https://github.com/tensorflow/tensorflow/releases/tag/v1.8.0-rc0
/r/MachineLearning
https://redd.it/8cq4gj
GitHub
tensorflow/tensorflow
An Open Source Machine Learning Framework for Everyone - tensorflow/tensorflow
[AF] Delete table in Flask, using flask-sqlalchemy?
So, I want to delete a table in my database, this being a table called Comments as I know it will only make for a terribly scaled flask app. do I just delete the code for the model in models.py and make a migration?
Here is my models.py if anyone is interested:
https://github.com/ModoUnreal/dopenet/blob/master/app/models.py
/r/flask
https://redd.it/8conl9
So, I want to delete a table in my database, this being a table called Comments as I know it will only make for a terribly scaled flask app. do I just delete the code for the model in models.py and make a migration?
Here is my models.py if anyone is interested:
https://github.com/ModoUnreal/dopenet/blob/master/app/models.py
/r/flask
https://redd.it/8conl9
GitHub
ModoUnreal/dopenet
dopenet - The ideal template to make websites in 2018!!!! (I'm kidding of course)
What's the difference between Statsmodel's Poisson and GLM with Poisson family?
For Statsmodels (imported as sm), I do not know what the difference is between
sm.Poisson(Y,X)
vs
sm.GLM(Y,X,family=sm.families.Poisson())
Also, another oddity is that with the former I have to use fit_regularize but with the latter, if I try to fit_regularize, I will get None when I try to get a summary.
/r/pystats
https://redd.it/8crlvg
For Statsmodels (imported as sm), I do not know what the difference is between
sm.Poisson(Y,X)
vs
sm.GLM(Y,X,family=sm.families.Poisson())
Also, another oddity is that with the former I have to use fit_regularize but with the latter, if I try to fit_regularize, I will get None when I try to get a summary.
/r/pystats
https://redd.it/8crlvg
reddit
What's the difference between Statsmodel's Poisson and GLM with...
For Statsmodels (imported as sm), I do not know what the difference is...
Updating fields in another model with custom save
Hello,
I have a few models with custom save definitions. I am looking to update a field in one model when I save another model based on a date comparison between the two. Unfortunately, I can't get this to work. I was wondering if someone could check out my code and see what I'm doing wrong.
models.py
class Person(models.Model):
first_name = models.CharField(max_length=250)
relation_name = models.CharField(max_length=250, blank=True)
last_name = models.CharField(max_length=250)
village = models.ForeignKey(Village)
earliest_case = models.ForeignKey('Case', null=True, blank=True, related_name='person_to_earliest_case+')
latest_case = models.ForeignKey('Case', null=True, blank=True, related_name='person_to_latest_case+')
def save(self, *args, **kwargs):
try:
earliest_litigation = Case.objects.filter(litigants__person=self).order_by('session__date')[0]
except:
earliest_litigation = None
try:
earliest_pledge = Case.objects.filter(litigants__pledges__giver=self).order_by('receiver__case__session__date')[0]
except:
earliest_pledge = None
if earliest_litigation and earliest_pledge:
if earliest_litigation.session.date > earliest_pledge.session.date:
self.earliest_case = earliest_litigation
elif earliest_pledge.receiver.session.date > earliest_litigation.session.date:
self.earliest_case = earliest_pledge
elif earliest_litigation:
self.earliest_case = earliest_litigation
elif earliest_pledge:
self.earliest_case = earliest_pledge
else:
self.earliest_case = None
try:
latest_litigation = Case.objects.filter(litigants__person=self).order_by('-session__date')[0]
except:
latest_litigation = None
try:
latest_pledge = Case.objects.filter(litigants__pledges__giver=self).order_by('-receiver__case__session__date')[0]
except:
latest_pledge = None
if latest_litigation and latest_pledge:
if latest_litigation.session.date > latest_pledge.session.date:
self.latest_case = latest_litigation
elif latest_pledge.session.date > latest_litigation.session.date:
self.latest_case = latest_pledge
elif latest_litigation:
self.latest_case = latest_litigation
elif latest_pledge:
self.latest_case = latest_pledge
else:
self.latest_case = None
super(Person, self).save(*args, **kwargs)
class Litigant(models.Model):
person = models.ForeignKey(Person, on_delete=models.CASCADE, related_name='cases')
case = models.ForeignKey(Case, on_delete=models.CASCADE, related_name='litigants')
role = models.ForeignKey(Role, related_name='litigant_role')
def save(self, *args, **kwargs):
super(Litigant, self).save(*args, **kwargs)
person = Person.objects.get(pk=self.person)
earliest_litigation = person.earliest_case
latest_litigation = person.latest_case
if earliest_litigation:
if self.case.session.date < earliest_litigation.session.date:
person.earliest_case = self.case
person.save(update_fields=['earliest_case'])
if latest_litigation:
if self.case.session.date > latest_litigation.session.date:
person.latest_case = self.case
person.save(update_fields=['latest_case'])
else:
person.earliest_case = self.case
person.latest_case = self.case
person.save(update_fields=['earliest_case', 'latest_case'])
When I save a `Person` model instance it updates the `earliest` and `last` case references just fine. However, when I add them as a `Litigant` it doesn't up
Hello,
I have a few models with custom save definitions. I am looking to update a field in one model when I save another model based on a date comparison between the two. Unfortunately, I can't get this to work. I was wondering if someone could check out my code and see what I'm doing wrong.
models.py
class Person(models.Model):
first_name = models.CharField(max_length=250)
relation_name = models.CharField(max_length=250, blank=True)
last_name = models.CharField(max_length=250)
village = models.ForeignKey(Village)
earliest_case = models.ForeignKey('Case', null=True, blank=True, related_name='person_to_earliest_case+')
latest_case = models.ForeignKey('Case', null=True, blank=True, related_name='person_to_latest_case+')
def save(self, *args, **kwargs):
try:
earliest_litigation = Case.objects.filter(litigants__person=self).order_by('session__date')[0]
except:
earliest_litigation = None
try:
earliest_pledge = Case.objects.filter(litigants__pledges__giver=self).order_by('receiver__case__session__date')[0]
except:
earliest_pledge = None
if earliest_litigation and earliest_pledge:
if earliest_litigation.session.date > earliest_pledge.session.date:
self.earliest_case = earliest_litigation
elif earliest_pledge.receiver.session.date > earliest_litigation.session.date:
self.earliest_case = earliest_pledge
elif earliest_litigation:
self.earliest_case = earliest_litigation
elif earliest_pledge:
self.earliest_case = earliest_pledge
else:
self.earliest_case = None
try:
latest_litigation = Case.objects.filter(litigants__person=self).order_by('-session__date')[0]
except:
latest_litigation = None
try:
latest_pledge = Case.objects.filter(litigants__pledges__giver=self).order_by('-receiver__case__session__date')[0]
except:
latest_pledge = None
if latest_litigation and latest_pledge:
if latest_litigation.session.date > latest_pledge.session.date:
self.latest_case = latest_litigation
elif latest_pledge.session.date > latest_litigation.session.date:
self.latest_case = latest_pledge
elif latest_litigation:
self.latest_case = latest_litigation
elif latest_pledge:
self.latest_case = latest_pledge
else:
self.latest_case = None
super(Person, self).save(*args, **kwargs)
class Litigant(models.Model):
person = models.ForeignKey(Person, on_delete=models.CASCADE, related_name='cases')
case = models.ForeignKey(Case, on_delete=models.CASCADE, related_name='litigants')
role = models.ForeignKey(Role, related_name='litigant_role')
def save(self, *args, **kwargs):
super(Litigant, self).save(*args, **kwargs)
person = Person.objects.get(pk=self.person)
earliest_litigation = person.earliest_case
latest_litigation = person.latest_case
if earliest_litigation:
if self.case.session.date < earliest_litigation.session.date:
person.earliest_case = self.case
person.save(update_fields=['earliest_case'])
if latest_litigation:
if self.case.session.date > latest_litigation.session.date:
person.latest_case = self.case
person.save(update_fields=['latest_case'])
else:
person.earliest_case = self.case
person.latest_case = self.case
person.save(update_fields=['earliest_case', 'latest_case'])
When I save a `Person` model instance it updates the `earliest` and `last` case references just fine. However, when I add them as a `Litigant` it doesn't up
date their `earliest` or `last` case references as I was hoping the custom save method in `Litigant` model would do.
Am I missing something obvious here?
Thanks in advance for any help!
/r/django
https://redd.it/8cslex
Am I missing something obvious here?
Thanks in advance for any help!
/r/django
https://redd.it/8cslex
reddit
Updating fields in another model with custom save • r/django
Hello, I have a few models with custom save definitions. I am looking to update a field in one model when I save another model based on a date...
Jupyter Lab RKernel doesn't start. [Troubleshooting]
Hi, I am new to jupyter and also jupyter lab.
Installed it and it seems to work fine until i try to start the RKernel.
This is the error output from commandline.
the icu package is installed and the libicui18n.so file is located in /usr/lib/libicui18n.so
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/johannes/R/x86_64-pc-linux-gnu-library/3.4/stringi/libs/stringi.so':
libicui18n.so.60: cannot open shared object file: No such file or directory
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
In the console I start and work with R normally.
Python Kernel works fine.
I am using Arch Linux...
Is this a known beginner issue?
/r/IPython
https://redd.it/8cwby7
Hi, I am new to jupyter and also jupyter lab.
Installed it and it seems to work fine until i try to start the RKernel.
This is the error output from commandline.
the icu package is installed and the libicui18n.so file is located in /usr/lib/libicui18n.so
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/johannes/R/x86_64-pc-linux-gnu-library/3.4/stringi/libs/stringi.so':
libicui18n.so.60: cannot open shared object file: No such file or directory
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
In the console I start and work with R normally.
Python Kernel works fine.
I am using Arch Linux...
Is this a known beginner issue?
/r/IPython
https://redd.it/8cwby7
reddit
Jupyter Lab RKernel doesn't start. [Troubleshooting] • r/IPython
Hi, I am new to jupyter and also jupyter lab. Installed it and it seems to work fine until i try to start the RKernel. This is the error output...
What's everyone working on this week?
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/8cwslw
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/8cwslw
reddit
What's everyone working on this week? • r/Python
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your...
I made a command-line tool that instantly fetches Stack Overflow results when you get a compiler error
https://github.com/shobrook/rebound
/r/Python
https://redd.it/8cwq72
https://github.com/shobrook/rebound
/r/Python
https://redd.it/8cwq72
GitHub
GitHub - shobrook/rebound: Instant Stack Overflow results whenever an exception is thrown
Instant Stack Overflow results whenever an exception is thrown - shobrook/rebound
Migrating our API Gateway from Flask to Django
https://tech.gadventures.com/migrating-our-api-gateway-from-flask-to-django-88a585c4df1a
/r/django
https://redd.it/8cxvlq
https://tech.gadventures.com/migrating-our-api-gateway-from-flask-to-django-88a585c4df1a
/r/django
https://redd.it/8cxvlq
Medium
Migrating our API Gateway from Flask to Django
At G Adventures, we’ve been building a publicly accessible API for the past three years. We’ve been pushing hard to make the G Adventures…
Jupyter and Scala
On jupyter website there is information about support for Scala. Has any of you used such a kernel?
/r/IPython
https://redd.it/8cutic
On jupyter website there is information about support for Scala. Has any of you used such a kernel?
/r/IPython
https://redd.it/8cutic
reddit
Jupyter and Scala • r/IPython
On jupyter website there is information about support for Scala. Has any of you used such a kernel?
[Project] Working with StarCraft II AIs on Google's free Google Colab Environment
https://medium.com/@n0mad/how-i-trained-starcraft-2-ais-using-googles-free-gpus-44bc635b0418
/r/MachineLearning
https://redd.it/8cwhe2
https://medium.com/@n0mad/how-i-trained-starcraft-2-ais-using-googles-free-gpus-44bc635b0418
/r/MachineLearning
https://redd.it/8cwhe2
Medium
How I trained StarCraft 2 AIs using Google’s free GPUs
How to train StarCraft 2 bots with free GPUs, plus, a long debugging story……
Django Celery: Run automated Task once for each item in database
Working on a school project that requires sending an email to each person that created a page once per day, but needs to do it for each page and I'm just not sure where I need to go from here.
From Tasks.py
from celery.task.schedules import crontab
from celery.decorators import periodic_task
from .Listing import Listing
from celery.utils.log import get_task_logger
from datetime import datetime
logger = get_task_logger(__name__)
@periodic_task(run_every=(crontab(hour="10", minute="10")))
def run_daily_emails():
Listing.daily_hit_count()
From Listing.py
def daily_hit_count(self):
send_mail('Daily Hit Count!', get_templet('templates/realestate/HitCountEmail.html').render(
Context({
'MLSNumber': self.MLSNumber,
'dailyHitCount': self.dailyHitCount,
'totalHitCount': self.totalHitCount
})
), 'AutoPoshPlace@gmail.com', [self.listing_agent.email],
fail_silently=False)
self.dailyHitCount = 0
I need this to iterate through for every listing in the database, but I'm not sure how to do that.
/r/django
https://redd.it/8cx7y2
Working on a school project that requires sending an email to each person that created a page once per day, but needs to do it for each page and I'm just not sure where I need to go from here.
From Tasks.py
from celery.task.schedules import crontab
from celery.decorators import periodic_task
from .Listing import Listing
from celery.utils.log import get_task_logger
from datetime import datetime
logger = get_task_logger(__name__)
@periodic_task(run_every=(crontab(hour="10", minute="10")))
def run_daily_emails():
Listing.daily_hit_count()
From Listing.py
def daily_hit_count(self):
send_mail('Daily Hit Count!', get_templet('templates/realestate/HitCountEmail.html').render(
Context({
'MLSNumber': self.MLSNumber,
'dailyHitCount': self.dailyHitCount,
'totalHitCount': self.totalHitCount
})
), 'AutoPoshPlace@gmail.com', [self.listing_agent.email],
fail_silently=False)
self.dailyHitCount = 0
I need this to iterate through for every listing in the database, but I'm not sure how to do that.
/r/django
https://redd.it/8cx7y2
reddit
Django Celery: Run automated Task once for each item in... • r/django
Working on a school project that requires sending an email to each person that created a page once per day, but needs to do it for each page and...
Django Admin Page Routing to Different Urls
Hi,
Whenever I try to connect to my admin page on my local computer at localhost:8000/admin it tries to re-route me to a different page localhost:8000/admin/profile_html. My urlpatterns are as follows:
main_app:
urlpatterns = [
path('farms/', include('farms.urls', namespace='farms')),
path('admin/', admin.site.urls),
]
farm_app:
app_name = 'farms'
urlpatterns = [
path('', views.index, name='index'),
path('about/', views.about, name='about'),
path('form/', views.profile_form, name='profile_form'),
path('profile/', views.profile, name='profile'),
# Registration Urls
path('login/', views.login, name='login'),
path('signup/', views.signup, name='signup'),
]
Would anyone know why Django tries to do this? Thanks!
/r/django
https://redd.it/8d0557
Hi,
Whenever I try to connect to my admin page on my local computer at localhost:8000/admin it tries to re-route me to a different page localhost:8000/admin/profile_html. My urlpatterns are as follows:
main_app:
urlpatterns = [
path('farms/', include('farms.urls', namespace='farms')),
path('admin/', admin.site.urls),
]
farm_app:
app_name = 'farms'
urlpatterns = [
path('', views.index, name='index'),
path('about/', views.about, name='about'),
path('form/', views.profile_form, name='profile_form'),
path('profile/', views.profile, name='profile'),
# Registration Urls
path('login/', views.login, name='login'),
path('signup/', views.signup, name='signup'),
]
Would anyone know why Django tries to do this? Thanks!
/r/django
https://redd.it/8d0557
reddit
Django Admin Page Routing to Different Urls • r/django
Hi, Whenever I try to connect to my admin page on my local computer at localhost:8000/admin it tries to re-route me to a different page...
Jupyter Notebooks Can't Fix the Scientific Paper
https://www.oliversherouse.com/2018/04/17/notebooks_arent_papers.html
/r/pystats
https://redd.it/8czxm1
https://www.oliversherouse.com/2018/04/17/notebooks_arent_papers.html
/r/pystats
https://redd.it/8czxm1
Oliversherouse
Jupyter Notebooks Can't Fix the Scientific Paper
Oliver Sherouse writes on Data, Python, and Culture
Plotly for effective data visualization
https://datascience693264219.wordpress.com/2018/03/29/the-journey-begins/
/r/Python
https://redd.it/8cvref
https://datascience693264219.wordpress.com/2018/03/29/the-journey-begins/
/r/Python
https://redd.it/8cvref
Wordpress
Plotly for effective data visualization
Author: Ruthger Righart Blogs: Web: Plotly is well-known for its aesthetically appeasing visualizations and user interaction. This Plotly guide is unlike other guides. Excellent introductory guides…