Here's my project to explore stress control through controlled breathing using Python, BLE, and the Polar H10 Heart Rate monitor
Hey r/Python,
I've been exploring the data available from the widely available Polar H10 heart rate monitor. The Bleak package provides a simple way to connect to the device, and stream heart rate, acceleration, and ECG data.
In this project I looked into the relationship between breathing rate and heart rate variability, a common indicator of physiological stress response.
Github repo: https://github.com/kbre93/dont-hold-your-breath
/r/Python
https://redd.it/12mi0ij
Hey r/Python,
I've been exploring the data available from the widely available Polar H10 heart rate monitor. The Bleak package provides a simple way to connect to the device, and stream heart rate, acceleration, and ECG data.
In this project I looked into the relationship between breathing rate and heart rate variability, a common indicator of physiological stress response.
Github repo: https://github.com/kbre93/dont-hold-your-breath
/r/Python
https://redd.it/12mi0ij
GitHub
GitHub - kieranabrennan/dont-hold-your-breath: Breathing analysis with Polar H10 Heart Rate Monitor
Breathing analysis with Polar H10 Heart Rate Monitor - kieranabrennan/dont-hold-your-breath
What is the best way to store marketplace commissions and payouts in a database after each purchase?
The basic idea is that the marketplace takes payments on behalf of the businesses and every 2 weeks the platform sends the money to the business while keeping 5% as commission.
Each time a user purchases a product we create a new Purchase object:
class Purchase(models.Model):
created = models.DateTimeField(auto_now_add=True)
user = models.ForeignKey(User)
product = models.ForeignKey(Product)
quantity = models.IntegerField(null=True, blank=True)
price = models.DecimalField(max_digits=10, decimal_places=2)
total_price = models.DecimalField(max_digits=10, decimal_places=2)
​
Apart from this, we need to store commissions and payouts information in our database. I was thinking of creating 3 models:
* PlatformComission (gets created each time a purchase happens, and stores the amount that we earned on that purchase)
* BusinessEarning (gets created each time a purchase happens, and stores the amount we need to pay the business)
* Payout (gets created every 2 weeks when the payout is sent, gets linked to all the Business Earnings during those 2 weeks with a many to many
/r/django
https://redd.it/12msfa6
The basic idea is that the marketplace takes payments on behalf of the businesses and every 2 weeks the platform sends the money to the business while keeping 5% as commission.
Each time a user purchases a product we create a new Purchase object:
class Purchase(models.Model):
created = models.DateTimeField(auto_now_add=True)
user = models.ForeignKey(User)
product = models.ForeignKey(Product)
quantity = models.IntegerField(null=True, blank=True)
price = models.DecimalField(max_digits=10, decimal_places=2)
total_price = models.DecimalField(max_digits=10, decimal_places=2)
​
Apart from this, we need to store commissions and payouts information in our database. I was thinking of creating 3 models:
* PlatformComission (gets created each time a purchase happens, and stores the amount that we earned on that purchase)
* BusinessEarning (gets created each time a purchase happens, and stores the amount we need to pay the business)
* Payout (gets created every 2 weeks when the payout is sent, gets linked to all the Business Earnings during those 2 weeks with a many to many
/r/django
https://redd.it/12msfa6
Reddit
r/django on Reddit: What is the best way to store marketplace commissions and payouts in a database after each purchase?
Posted by u/adrenaline681 - No votes and no comments
Choose Your Weapon: Survival Strategies for Depressed AI Academics
https://arxiv.org/abs/2304.06035
/r/MachineLearning
https://redd.it/12lxavs
https://arxiv.org/abs/2304.06035
/r/MachineLearning
https://redd.it/12lxavs
Reddit
r/MachineLearning on Reddit: Choose Your Weapon: Survival Strategies for Depressed AI Academics
Posted by u/togelius - No votes and 16 comments
[R] Bert and XLNet: 85% Neurons Redundant, 92% Removable for Downstream Tasks
https://aclanthology.org/2020.emnlp-main.398.pdf
/r/MachineLearning
https://redd.it/12ms3wo
https://aclanthology.org/2020.emnlp-main.398.pdf
/r/MachineLearning
https://redd.it/12ms3wo
New search package in python
Searchlix
My first python package on PyPI
I want to try how I can develop a python package and upload it, and the result was: Searchlix
It is a simple and powerful package which helps with searching for patterns, emails, phone numbers and words in texts and websites! (Web scraping)
Some of the features:
-Patterns search in text (KMP algorithm)
-Word search in text
-Search for page name in website
-Find emails in text / Email validation
-Find emails in a website page
-Find a phone number in text / Phone number validation
-Find a phone number in a website page
And I will provide further features and examples in the future
I would be thankful if any one who tried it could show us how he used it (case study) and if there are any further suggestions
https://pypi.org/project/searchlix/
/r/Python
https://redd.it/12mw0dc
Searchlix
My first python package on PyPI
I want to try how I can develop a python package and upload it, and the result was: Searchlix
It is a simple and powerful package which helps with searching for patterns, emails, phone numbers and words in texts and websites! (Web scraping)
Some of the features:
-Patterns search in text (KMP algorithm)
-Word search in text
-Search for page name in website
-Find emails in text / Email validation
-Find emails in a website page
-Find a phone number in text / Phone number validation
-Find a phone number in a website page
And I will provide further features and examples in the future
I would be thankful if any one who tried it could show us how he used it (case study) and if there are any further suggestions
https://pypi.org/project/searchlix/
/r/Python
https://redd.it/12mw0dc
PyPI
searchlix
A package for extract data from websites and text
Mastering SOLID Principles in Python: A Guide to Scalable Code
The Single Responsibility Principle (SRP) is a fundamental SOLID principle that states that a class should have only one reason to change.
/r/Python
https://redd.it/12mxuoi
The Single Responsibility Principle (SRP) is a fundamental SOLID principle that states that a class should have only one reason to change.
/r/Python
https://redd.it/12mxuoi
Reddit
r/Python on Reddit: Mastering SOLID Principles in Python: A Guide to Scalable Code
Posted by u/Olatunde32 - No votes and 2 comments
Basic question on what this syntax comes from: is this python code I am not familiar with; is it django -- Just not sure what to even call it so i can look up info on it.
/r/django
https://redd.it/12n1r76
/r/django
https://redd.it/12n1r76
Is having a single app standard in Django realm ?
hi there,
i started this new job as a Django backend developer. we have around 20 models. what i want to do is split them into couple apps along with their respective views etc. but my team mate argued that what i do is not right and all Django projects use a single app to manage everything.
is this correct ? what is the right way of doing this. a single app with 20 models in a models.py file seems hard to read/reach for me.
should i create separate apps or should i create multiple folders in a single app.
how do you structure your projects ?
/r/django
https://redd.it/12mwx7e
hi there,
i started this new job as a Django backend developer. we have around 20 models. what i want to do is split them into couple apps along with their respective views etc. but my team mate argued that what i do is not right and all Django projects use a single app to manage everything.
is this correct ? what is the right way of doing this. a single app with 20 models in a models.py file seems hard to read/reach for me.
should i create separate apps or should i create multiple folders in a single app.
how do you structure your projects ?
/r/django
https://redd.it/12mwx7e
Reddit
r/django on Reddit: Is having a single app standard in Django realm ?
Posted by u/everlastingflower - 4 votes and 7 comments
I discovered that the fastest way to create a Pandas DataFrame from a CSV file is to actually use Polars
https://medium.com/@finndersen/the-fastest-way-to-read-a-csv-file-in-pandas-2-0-532c1f978201
/r/Python
https://redd.it/12n0wfk
https://medium.com/@finndersen/the-fastest-way-to-read-a-csv-file-in-pandas-2-0-532c1f978201
/r/Python
https://redd.it/12n0wfk
Medium
The fastest way to read a CSV file in Pandas 2.0
It turns out that the fastest way to create a Pandas DataFrame from a CSV file is to use an entirely different library.
Django + Nextjs overkill?
I have built Django websites in the past as well as DRF + React. I know that the cool kids nowadays use Nextjs. It does indeed have a lot of good stuff but I feel kindda lost whether is a nice idea to combine the two frameworks and just use Nextjs as the frontend. I have read some posts mentioning that you will find a lot of problems down the road (CORS related, etc).
The reason to stick with DRF as backend is that I'm way more better developer and more used to python while I just know a couple of things in the Javascript world.
Any experience stories, guidance would be much appreaciated.
/r/django
https://redd.it/12neaj8
I have built Django websites in the past as well as DRF + React. I know that the cool kids nowadays use Nextjs. It does indeed have a lot of good stuff but I feel kindda lost whether is a nice idea to combine the two frameworks and just use Nextjs as the frontend. I have read some posts mentioning that you will find a lot of problems down the road (CORS related, etc).
The reason to stick with DRF as backend is that I'm way more better developer and more used to python while I just know a couple of things in the Javascript world.
Any experience stories, guidance would be much appreaciated.
/r/django
https://redd.it/12neaj8
Reddit
r/django on Reddit: Django + Nextjs overkill?
Posted by u/Scellillo - No votes and no comments
Sunday Daily Thread: 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/12nnqs3
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/12nnqs3
Reddit
r/Python on Reddit: Sunday Daily Thread: What's everyone working on this week?
Posted by u/Im__Joseph - 1 vote and 2 comments
Pip 23.1 Released - Massive improvement to backtracking
Pip 23.1 was just released a few hours ago. You can check the release announcements here and the change log here.
I would like to highlight the significant improvement in backtracking that is part of the requirement resolver process in Pip. This process involves Pip finding a set of packages that meet your requirements and whose requirements themselves don't conflict.
For example, let's say you require packages A and B. First, the latest versions of A and B are downloaded and Pip checks their requirements, let's say Pip finds that A depends on C==2 and B depends on C==1. These two latest versions of A and B are not compatible, so Pip will try to find an older version of A and/or B where they have compatible dependencies. C in this case is called a transitive dependency because it's a dependency of a dependency.
Prior to Pip 20.3, the default process for Pip would allow conflicting requirements to install if they were transitive dependencies where the last one specified would be the one installed. This was not satisfactory for a lot of projects that had larger set of requirements because it meant package versions that did not work together could be installed
/r/Python
https://redd.it/12n5lai
Pip 23.1 was just released a few hours ago. You can check the release announcements here and the change log here.
I would like to highlight the significant improvement in backtracking that is part of the requirement resolver process in Pip. This process involves Pip finding a set of packages that meet your requirements and whose requirements themselves don't conflict.
For example, let's say you require packages A and B. First, the latest versions of A and B are downloaded and Pip checks their requirements, let's say Pip finds that A depends on C==2 and B depends on C==1. These two latest versions of A and B are not compatible, so Pip will try to find an older version of A and/or B where they have compatible dependencies. C in this case is called a transitive dependency because it's a dependency of a dependency.
Prior to Pip 20.3, the default process for Pip would allow conflicting requirements to install if they were transitive dependencies where the last one specified would be the one installed. This was not satisfactory for a lot of projects that had larger set of requirements because it meant package versions that did not work together could be installed
/r/Python
https://redd.it/12n5lai
Discussions on Python.org
Announcement: pip 23.1 release!
On behalf of the PyPA, I am pleased to announce that the pip team has just released pip 23.1. This is the second release of pip for the year 2023. You can read more about our versioning, deprecation policy, and release process here. Highlights Further…
what is th best practices to implement Stripe payments in a flask app
/r/flask
https://redd.it/12mszdr
/r/flask
https://redd.it/12mszdr
Reddit
r/flask on Reddit: what is th best practices to implement Stripe payments in a flask app
Posted by u/Proud_Pianist_8715 - 15 votes and 1 comment
Google announces the list of 574 Python packages in its new "Assured Open Source Software" service
https://cloud.google.com/assured-open-source-software/docs/supported-packages#python
/r/Python
https://redd.it/12nxsop
https://cloud.google.com/assured-open-source-software/docs/supported-packages#python
/r/Python
https://redd.it/12nxsop
Google Cloud
List of supported Java and Python packages for the Assured Open Source Software free tier | Google Cloud
problem with psycopg
so i am working on some django from a book and trying to do a project. it was working good but when i had to use docker-compose down and docker-compose up -build -d command again so changes would commit now it has some errors.
​
it says psycopg is not intalled but it was working good and i made sure it is installed so i dont understand what can be the problem here. maybe the error is about database, which i changed in the settings but why id this error occuring now?
here is my database settings
https://preview.redd.it/wc365183hvta1.png?width=680&format=png&auto=webp&v=enabled&s=a3d83cc453f13da03d3e452f7da9696f5e587e21
maybe someone had a similar experience and can help me, i would appreciate.
by the way when i run docker-compose up -d --build command it gives me this error
​
https://preview.redd.it/39lvncvthvta1.png?width=1219&format=png&auto=webp&v=enabled&s=74807ec07c2ea82a5a238293a4f10a840c127568
​
thanks for helping
/r/djangolearning
https://redd.it/12m1vq8
so i am working on some django from a book and trying to do a project. it was working good but when i had to use docker-compose down and docker-compose up -build -d command again so changes would commit now it has some errors.
​
it says psycopg is not intalled but it was working good and i made sure it is installed so i dont understand what can be the problem here. maybe the error is about database, which i changed in the settings but why id this error occuring now?
here is my database settings
https://preview.redd.it/wc365183hvta1.png?width=680&format=png&auto=webp&v=enabled&s=a3d83cc453f13da03d3e452f7da9696f5e587e21
maybe someone had a similar experience and can help me, i would appreciate.
by the way when i run docker-compose up -d --build command it gives me this error
​
https://preview.redd.it/39lvncvthvta1.png?width=1219&format=png&auto=webp&v=enabled&s=74807ec07c2ea82a5a238293a4f10a840c127568
​
thanks for helping
/r/djangolearning
https://redd.it/12m1vq8
Flask changing src and PATHS
I've used Flask(__name__, template_folder="mijn_project/templates") for some reason all my PATHS don't work. app.py is stored in / and my project is stored in /mijn_project/. none of my templates can find the images location or bootstrap, css, js etc. but when I run my HTML template it show the CSS, images, lib without errors. what's going wrong? PS. the structure is not my idea, my teacher demands this. and I tried every PATH ../static, /static/, ../../static but nothing works. and its a local test
/r/flask
https://redd.it/12n3w4m
I've used Flask(__name__, template_folder="mijn_project/templates") for some reason all my PATHS don't work. app.py is stored in / and my project is stored in /mijn_project/. none of my templates can find the images location or bootstrap, css, js etc. but when I run my HTML template it show the CSS, images, lib without errors. what's going wrong? PS. the structure is not my idea, my teacher demands this. and I tried every PATH ../static, /static/, ../../static but nothing works. and its a local test
/r/flask
https://redd.it/12n3w4m
How do I get current values from the database in a dropdown form
Hi,
TL:DR: I want to pass the values of a database model into the options in a dropdown menu.
I am building a application with different card types. Each card type has a different color. To keep track of the users preferences I created a database model where for each user I keep track of their color (and also Icon and label).
Basically the user can say:- legend_1 is yellow, I call it "ambition" and I want a thumb up icon.- Legend_2 is blue etc etc
here is the model:
models.py
# Create your models here.
class CardPreferences(models.Model):
<!--Some other stuff not related to question -->
legendlabel1 = models.CharField(blank=False, maxlength=40, default='legend1')
legendhexcolor1 = models.CharField(blank=False, maxlength=6, default='78E7BF')
legendicon1 = models.CharField(blank=False, maxlength=40, default='thumbs-up-solid.svg')
legendlabel2 = models.CharField(blank=False, maxlength=40, default='legend2')
legendhexcolor2 = models.CharField(blank=False, maxlength=6, default='51c1ff')
legendicon2 = models.CharField(blank=False, maxlength=40, default='thumbs-up-solid.svg')
/r/djangolearning
https://redd.it/12o8jow
Hi,
TL:DR: I want to pass the values of a database model into the options in a dropdown menu.
I am building a application with different card types. Each card type has a different color. To keep track of the users preferences I created a database model where for each user I keep track of their color (and also Icon and label).
Basically the user can say:- legend_1 is yellow, I call it "ambition" and I want a thumb up icon.- Legend_2 is blue etc etc
here is the model:
models.py
# Create your models here.
class CardPreferences(models.Model):
<!--Some other stuff not related to question -->
legendlabel1 = models.CharField(blank=False, maxlength=40, default='legend1')
legendhexcolor1 = models.CharField(blank=False, maxlength=6, default='78E7BF')
legendicon1 = models.CharField(blank=False, maxlength=40, default='thumbs-up-solid.svg')
legendlabel2 = models.CharField(blank=False, maxlength=40, default='legend2')
legendhexcolor2 = models.CharField(blank=False, maxlength=6, default='51c1ff')
legendicon2 = models.CharField(blank=False, maxlength=40, default='thumbs-up-solid.svg')
/r/djangolearning
https://redd.it/12o8jow
Reddit
r/djangolearning on Reddit: How do I get current values from the database in a dropdown form
Posted by u/Human-Possession135 - 1 vote and no comments
Database on Local Machine - Still Pulling Heroku Postgres Database
Recently my main computer rig died and I moved onto a new computer.
I am trying to get my local development mode back up and running but am running into trouble, amateur programmer at best, doing this as a fun hobby.
Anyways, in the process of trying to get the website back up and running, I forgot to set my local environment variable of "DEVELOPMENT_MODE" to "True" and ran "python manage.py collectstatic" and "python manage.py runserver" and my local machine points to the postgres database that I have on with Heroku.
I thought this should be a pretty easy fix and change "DEVELOPMENT_MODE" to "True", but the local database is still referencing the postgres database. Any ideas on how to get django to point the the local sqlite3 database?
Code in reference, settings.py:
if DEVELOPMENTMODE is True:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASEDIR, "db.sqlite3"),
/r/djangolearning
https://redd.it/12kb0gg
Recently my main computer rig died and I moved onto a new computer.
I am trying to get my local development mode back up and running but am running into trouble, amateur programmer at best, doing this as a fun hobby.
Anyways, in the process of trying to get the website back up and running, I forgot to set my local environment variable of "DEVELOPMENT_MODE" to "True" and ran "python manage.py collectstatic" and "python manage.py runserver" and my local machine points to the postgres database that I have on with Heroku.
I thought this should be a pretty easy fix and change "DEVELOPMENT_MODE" to "True", but the local database is still referencing the postgres database. Any ideas on how to get django to point the the local sqlite3 database?
Code in reference, settings.py:
if DEVELOPMENTMODE is True:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASEDIR, "db.sqlite3"),
/r/djangolearning
https://redd.it/12kb0gg
Flask Sessions not working with blueprints
I am using flask sessions, i recently changed my code structure to be blueprint based, it has broken sessions. Whevenver i try to access sessions inside a blueprint, it is giving me
This is the code from the main application:
Can anybody tell me what is causing this?
/r/flask
https://redd.it/12oexr1
I am using flask sessions, i recently changed my code structure to be blueprint based, it has broken sessions. Whevenver i try to access sessions inside a blueprint, it is giving me
RuntimeError: The session is unavailable because no secret key was set. Set the secret_key on the application to something unique and secret.
This is the code from the main application:
app = Flask(__name__)
app.register_blueprint(authModule, url_prefix='/auth', cookie_path='/')
app.secret_key = environ.get('secret_key')
app.config['SESSION_COOKIE_PATH'] = '/'
Can anybody tell me what is causing this?
/r/flask
https://redd.it/12oexr1
Reddit
r/flask on Reddit: Flask Sessions not working with blueprints
Posted by u/ivanrj7j - No votes and 1 comment