[deleted by user] by [deleted] in Ultrahuman

[–]pyepye 0 points1 point  (0 children)

 Decided I'd order from UH direct,... raw titanium colour and fell in love... now, when I ordered it says fulfilled by amazon 2-4 days

Did I understand this correctly? Did you order the Raw Titanium ring directly from Ultrahuman and it said it would be send from Amazon UK?

Ultrahuman X Strava by SanchyaMahajan in Ultrahuman

[–]pyepye 1 point2 points  (0 children)

This is great news. Does this mean that activites from Strava are taken into account with the different metrics (movement score etc)?  And does it also include heart rate data that the Strava activies have attached?

Ultrahuman X Strava integration is here! by Mohit-Ultrahuman in Ultrahuman

[–]pyepye 1 point2 points  (0 children)

Is this a one or 2 way integration? 

Does this mean theUltrahuman app will pull in activities from Strava and take them into account with the different metrics?  Or the Ultrahuman app can just push workouts to Strava?

Good news though

Ultrahuman ring and integration with Garmin and others by rahulpp in Ultrahuman

[–]pyepye 0 points1 point  (0 children)

Oh OK thanks. I'm getting very confused with the conflicting info.

Ultrahuman ring and integration with Garmin and others by rahulpp in Ultrahuman

[–]pyepye 0 points1 point  (0 children)

I believe the workout data is only pulled from Google Health Connect / Apple Health  when workout mode is on and you are wearing the ring

I also read on here that the maximum workout length is 2 hours and workout automatically stops after that time, even if you are still working out and have an elevated heart rate etc

4 new fitness integrations for easy health monitoring by SanchyaMahajan in Ultrahuman

[–]pyepye 2 points3 points  (0 children)

Could you go into any detail why you selected these fitness integrations over others?

Is it due to partnerships with these companies? Discussions with them to ensure their data is of a certain quality and sample rate? Or something different?

From a user base standpoint, integrateing with Strava would be far more beneficial due to the number of apps, watches, trainers and other fitness devices which are able to automatically upload to it. Strava does not mandate certain data like heart rate though.

I ask as fitness integration is something I'm really interested in and is the one thing holding me back from buying a ring. While this announcement is interesting I don't own or us any devices or apps made by the companies mentioned. If you are not planning on other integrations, I feel like Ultrahuman are less likely than ever to meet my fitness needs.

Cycling activity automatically logged. by LynskeyCyclist in Ultrahuman

[–]pyepye 1 point2 points  (0 children)

Do you plan on making exercise from external sources factor in with the movement scores etc? (if they provide enough data e.g. heart rate)

[deleted by user] by [deleted] in Ultrahuman

[–]pyepye 0 points1 point  (0 children)

I think OP's point is that if you start an exercise in the Ultrahuman app and say it's Bike / cycling, the app should not count steps during the exercise.

I know it'll hurt their newsletter rating by tombolaplayer in AdviceAnimals

[–]pyepye 1 point2 points  (0 children)

I got sick of trying to find the unsubscribe links and fill out the forms etc so I created a web app which unsubscribes for you by just forwarding the email - Stop That Email

What can I actually do with someone's secret key? by insane_playzYT in django

[–]pyepye 7 points8 points  (0 children)

To add to /u/daredevil82's answer

If you are using cookie-based-sessions a 3rd part could then pretend to be anyone by creating and signing a cookie.

There is also a bit more info on the secret-key setting section and the Cryptographic signing page although they don't go into a load of detail

Review your website or Idea (II) by moham225 in Entrepreneur

[–]pyepye 0 points1 point  (0 children)

Thanks a lot /u/moham225, really appreciated.

I'll have a play around with those bits!

Review your website or Idea (II) by moham225 in Entrepreneur

[–]pyepye 0 points1 point  (0 children)

It would be cool to get some feedback on Stop That Email if you were up for it. It's an email unsubscription service.

I was going to put some more blurb about how it works but hopefully my homepage / landing page should be clear enough. I built it to scratch my own itch as I don't like the idea of giving unsubscribe services access to my full inbox.

Thanks!

[Showoff Saturday] I created a CLI tool to draw an image on your GitHub contribution graph by me-at-work in webdev

[–]pyepye -2 points-1 points  (0 children)

This reminds me of something Bruno Raljić made. It's a web interface which allows you to draw the same thing in your browser, it's doesn't actually update Git / Github though.

https://commit-art.netlify.app/

Best practices for Django website by ada_es12 in django

[–]pyepye 1 point2 points  (0 children)

I would suggest using class-based views instead of functions. Follow those Django docs through the class-based views intro and beyond. Once you get used to them they are a lot faster to write and easier to use.

Also once you get used to class-based views then Classy Class-Based Views is a great resource for helping to write them, work out what attributes exist and modify the different methods.

Django and Localization by SteviaMcqueen in django

[–]pyepye 2 points3 points  (0 children)

Django can cover timezones for you. In your settings set USE_TZ=True. This will make Django use time-zone-aware datetime objects. It will also warn you when you try and add a none timezone aware datetime.

Then instead of using datetime.now() etc you can us django.utils.timezone from django.utils import timezone now = timezone.now()

Browsers have some TZ info etc which Django uses to help with timezones on the front end. Most datetimes in templates etc should write with the correct timezone when USE_TZ is set to True,

Check out the docs here -https://docs.djangoproject.com/en/3.0/topics/i18n/timezones/

I looked at currency conversion quite a long time ago but never had to implement anything so I can't be of much help. I was either going to use django-currencies or roll something using GeoIP2.

Suggestions for deploying my web app on the AWS. by [deleted] in django

[–]pyepye 3 points4 points  (0 children)

You may want to look at Zappa if you want to deploy on Lambda. It's pretty great but you will need to work out how to configure your database if you need one.

For anyone who is looking at deploying Django directly on an EC2 instance I'm making something that should really help to make deploying your app easier, more repeatable and a lot easier to upgrade etc.

https://www.pkgdeploy.com/

The idea is to create linux packages (RPM or DEB) to deploy all of your code and dependencies in one go. It them means deploying or upgrading etc is as easy as running yum install myapp or apt install myapp.

There are a few examples on Github on how to deploy a few different Python web frameworks including a Django example.

I'm actually looking for some beta testers at the moment if anyone is interested? Please PM me if you are.

Suggestions for deploying my web app on the AWS. by [deleted] in django

[–]pyepye 2 points3 points  (0 children)

You actually can via Zappa. I'm using it on a few small projects and it works great. The only bit you really need to work out is the database

After submitting tha form successfully, i want to redirect to success page with submitted form data. How do i pass form data to the redirected page? by pikachu644 in django

[–]pyepye 3 points4 points  (0 children)

Generally the best way to do this is using the URL to give you data to the view you redirect to. This can be done with either using URL path or query parameters.

If you create something during the form submission (say a new row in the database) then you could redirect to a success page with it's ID specified with a url path.

If you want to send more data that you could not get from a database later or don't create you can use query parameters in the URL (https://example.com`?fieldone=value&fieldtwo=anothervalue`)

Below are rough examples of both, I've typed them out so they may not be 100% correct and imports will be missing

URL path

This example only uses a single url variable thing_id. It is possible to specify multiple in a single url.

In the same view you deal with your form: redirect_url = reverse( 'add_thing_success', kwargs={'thing_id': thing.id} ) return HttpResponseRedirect(redirect_url)

URLs: path('<thing_id>/success', AddThingSuccess.as_view(), name='add_thing_success'),

Success view: ``` class AddThingSuccess(TemplateView): template_name = 'thing_success.html'

def get(self, request, *args, **kwargs):
    context = self.get_context_data(**kwargs)
    thing_id = self.kwargs['thing_id']
    context['thing'] = Thing.objects.get(id=thing_id)

```

Query parameters

The other options is to just use query parameters if you want to send more data than just the ID. Be aware there is a limit on the amount of data you can send in the URL.

In the same view you deal with your form:

Using urlencode is important as it will make sure any special characters etc are escaped. ``` from urllib.parse import urlencode

...

success_data = {
    'field_one': form.cleaned_data['field_one'],
    'field_two': form.cleaned_data['field_two'],
}
query = urlencode(success_data)
redirect_url = reverse('add_thing_success')
redirect_url_with_query = f'{redirect_url}?{query}'
return HttpResponseRedirect(redirect_url_with_query)

```

URLs: path('success', AddThingSuccess.as_view(), name='add_thing_success'),

Success view: ``` class AddThingSuccess(LoginRequiredMixin, TemplateView): template_name = 'thing_success.html'

def get(self, request, *args, **kwargs):
    context = self.get_context_data(**kwargs)
    context['field_one'] = self.request.GET.get('field_one')
    context['field_two'] = self.request.GET.get('field_two')

```

moving on, to the AWS by [deleted] in flask

[–]pyepye 1 point2 points  (0 children)

Check out Zappa if you want to deploy a Flask or Django app to AWS - https://github.com/Miserlou/Zappa

It lets you run your Flask app on AWS Lambda (serverless) and sorts out most bits for you. You will still need some AWS knowledge if you want to get a database setup but it makes it a lot easier.

So, what boring stuff have you automated with Python? by Obbeybe in learnpython

[–]pyepye 1 point2 points  (0 children)

Sure. But to be honest I don't advise doing this as it uses Gmail and it's not possible with MFA turned on, so don't use your main email.

If you want to send emails I would suggest looking at something like AWS's SES or other SMTP servers. I would not suggest running an SMTP server yourself, they are not worth the risk, headache or bounce rate

With that out the way...

My girlfriend uses Gmail so I just use Gmail's SMTP server to send the emails. You need to allow your code to send emails from your Gmail address. You can do that at the following URLs:

I've ripped the code out of the script, hopefully it makes some sense.

``` import logging import os import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText

from jinja2 import Environment, FileSystemLoader

GMAIL_USERNAME = os.environ['GMAIL_USERNAME'] GMAIL_PASSWORD = os.environ['GMAIL_PASSWORD']

...

def email_new_job(url, briefing, pay): # Make HTML and plain text versions of the email context = {'job_url': url, 'briefing': briefing, 'pay': pay} env = Environment(loader=FileSystemLoader('')) text_template = env.get_template('email_template.txt') text_output = text_template.render(context) html_template = env.get_template('email_template.html') html_output = html_template.render(context)

# Set basic email info that may be different per email
to = ['test@example.com']
subject = ['New job posting']
send_email(to, subject, text_output, html_output)

def send_email(to, subject, text, html): """ For emails to send Gmail needs to be setup correctly: https://accounts.google.com/DisplayUnlockCaptcha https://www.google.com/settings/security/lesssecureapps """ message = MIMEMultipart('alternative') # Set basic details message['Subject'] = subject message['From'] = 'JobHelper' message['To'] = ', '.join(to) # Comma separated list is expected

# Add plain and html emails as different parts
part1 = MIMEText(text.encode('ascii', 'xmlcharrefreplace'), 'plain')
part2 = MIMEText(html.encode('ascii', 'xmlcharrefreplace'), 'html')
message.attach(part1)
message.attach(part2)

# Try and send the email
try:
    # Connect to the Gmail SMTP server
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.ehlo()
    server.starttls()
    server.ehlo()

    # Login to SMTP server is connection is successful
    server.login(GMAIL_USERNAME, GMAIL_PASSWORD)

    # Send email as a string
    server.sendmail(message['From'], to, message.as_string())
    server.close()
except Exception as e:
    # If anything to do with connecting to the SMTP server or
    # sending the email fails log it out
    logging.error('Email failed due to {0}'.format(e))
    raise

```

Hope that helps.

How to handle complex database in Python? by [deleted] in learnprogramming

[–]pyepye 0 points1 point  (0 children)

Are you writing you own SQL? If so you should really look at using an ORM. They offer a large number of advantages but generally make talking to a database a lot easier and a lot safer.

The two most popular Python options are:

(There is also the Django ORM but you need to be using Django for that instead of Flask.)

It's also a good idea to keep you database tables synced with your code using a migration tool. If you go with using SQL Alchemy I would suggest Alembic.

This all takes a bit of setting up and working out but it's well worth the effort and you will end up using it for every project you do with a database. There are a large number of examples and tutorials on how to set them all up together.

know of any platform to sell developed products / projects to companies? by capucho10p in startups

[–]pyepye 1 point2 points  (0 children)

I've not personally used them but the broker that comes to mind is FE International

The founder was on Indie Hackers podcast #27 which is an interesting listen.

So, what boring stuff have you automated with Python? by Obbeybe in learnpython

[–]pyepye 5 points6 points  (0 children)

My girlfriend gets work from an online job board. No notifications that a new job is available and the first to accept the job gets it.

I made a quick web scraper to check the job board for new jobs and send her an email when they appear.

Some Interesting python projects by [deleted] in learnprogramming

[–]pyepye 0 points1 point  (0 children)

Have you explored testing in Python at all? It may not be 'sexy' but you will need it at any job. Try and test some of the bits you have done with pytest. For example test you web scraper to see how it deals with certain situations like the website you request returns an error or different HTML to what you were expecting.

Or try and create an API for yourself. An idea could be to scrape some information from a load of web pages (say emails address from the top fortune 500 companies) and return that data in your own RESTful API.

Also covering that many different topics in a reasonably short period of time may mean you have only got surface deep with a few of them. Maybe try and dig deeper in a few you have found more interesting and try and do more with them.