memory management – Python script which sends telegram message if Raspberry Pi’s temperature crosses 60 C

I need to know if there is any way I can optimize my code so that it does not use 0.6% of my total memory – which is approx. 22.4MB. This is a really small script that runs for as long as the raspberry pi is ON. 22.4MB for this basic, simple, light code is too much. If less or no optimization is there, then please let me know how is 22.4MB justified.

I am pasting the htop screenshot and my full script.htop

from gpiozero import CPUTemperature
from time import sleep, time
from requests import post

class TemperatureBot:
    def __init__(self):
        self.lastAlertSent = -1
        self.chatId = "123"
        self.botToken= "123"
        self.temperatureThreshold = 60
        self.alertInterval = 300
        alertResp = self.sendAlertToUser(f"Initializing temperature bot for 123 - " 
                                         f"your pi")
        if alertResp is not True:
            print("Could not initialize bot for 123. Try later.")

    def sendAlertToUser(self, alertMsg):
            r = post(url,timeout=20)
            if(r.status_code >=400):
                print("Error sending alert. Here's the response: ", r.text)
                return False
            return True
        except Exception as e:
            raise e

    def temperaturePolling(self):
                currentTemp = CPUTemperature().temperature
                if(currentTemp > self.temperatureThreshold):
                    if(time() - self.lastAlertSent > self.alertInterval):
                        alertResp = self.sendAlertToUser(f"Temperature Danger: "
                                             f"{currentTemp}°C. "
                                             f"Please cool your Stan "
                                             f"or it will burn!!")
                        if alertResp == True:
                            self.lastAlertSent = time()
                            print("Could not send alert message.")
        except KeyboardInterrupt:

if __name__ == "__main__":

Apologies if I have missed something, this is my first ever post on stackexchange.

apache2 – Apache Caching disbaled when client sends If-Modified-Since header

I’m trying to get Apache to cache the results from running an expensive PHP script (it accesses a third party server which has rate limiting) but it seems if the client sends an If-Modified-Since header the cache is bypassed.

CacheEnable disk /script.php
CacheLock on
CacheLockMaxAge 60
CacheIgnoreHeaders Set-Cookie
# prevent client explicitly requesting un-cached content
CacheIgnoreCacheControl on
CacheDetailHeader on

The php script sets the following headers in it’s response:

  • Last-Modified set to the current time, e.g. Sun, 20 Jun 2021 11:30:20 GMT
  • Expires set to the current time plus 60 seconds, e.g. Sun, 20 Jun 2021 11:31:20 GMT

If I issue the following request:

GET /script.php
Connection: close

Then the caching works correctly and the php script is only run once a minute with other requests being served from the cache.

However issuing the following request:

GET /script.php
Connection: close
If-Modified-Since: Sun, 20 Jun 2021 11:30:30 GMT

Runs the php script every time with:

X-Cache-Detail: "cache miss: attempting entity save" from

in the response.

I’m using Apache 2.4.29 on Ubuntu 18.04.

sharepoint online – Flow Sends Email to Member and Supervisor Only

While I was waiting I went to the ‘MemberList’ and created an ‘NotificationEmails’ column that has the email addresses to which each notifications that meets the condition should be sent.

The content of the ‘NotificationEmails’ column looks like this: joe.noboby@emailcom, (the employee and the supervisor).

How do I incorporate the content (both email addresses) of the ‘NotificationEmails’ column from the ‘MemberList’ (for which I already have a Get items created in the flow), into the Send email of the flow so that ALL persons who have an email in the ‘NotificationEmails’ column of the ‘MemberList’ for the individual whose document will expire gets an email?

workflow – Flow Sends Email to Specific Persons

I have a Flow that scans a List for four ‘Titles’; and, where the ‘DueDate’ equals 30 days send an email.

Everthing works. For test purposes I manually entered my email addressed into the ‘Send and email’ “To” field.

For the test there were three Members that meet the condition of ‘Title’ and ‘DueDate’. When the Flow runs I get one Expiration email per person.

There is a MemberList (contains Member and Member supervisor Name and Email Address) and a MemberCertQualList (this is the List the Flow is currently acting on).

How do I update the Flow to ONLY email the Member to whom the expiring document belongs and his/her supervisor?

Flow that Sends Email – SharePoint Stack Exchange

I need a flow that sends and email whenever a threshold is reached.

I have a List (List1). On List1 are columns ‘CQTitle’ and ‘DaysRemaining’.

I have created a recurring Flow (Compliance Flow).

There are 1300 items on the list. The flow should only act upon those items with a ‘CQTitle’ that matches the string in the Condition, and only upon those whose Due Date is equal to ’30’.

Will the below do what I desire? And, if I need a email for ’60 Days’ and ’90 Days’ is it more appropriate to create three flows (one for each notification), or can each be addressed in this one flow?

Task: Once per day;
Get items from List1 (items to get: CQTitle and DaysRemaining);
Compare CQTitle to predetermined titles (based on string in Condition)
Determine if DaysRemaining equals ’30’ (based on sting in Condition)
if true send email,
if false do nothing

Compliance Flow Construction –
Recurrence: 1 Day
Get items: List1
Apply to each: Value
Condition: List1/CQTitles is qual to string(‘”Driver”,”Conductor”,”Brakeman”‘)
Condition: List1/DaysRemaining is equal to string(‘”30″‘)
If yes: Send an email
If no:

parallelism – What is the best architecture/implementation for a TCP Client which sends in parallel every seconds 100 messages?

I am currently trying to find out the correct solution for this architecture problem of a service which is running in a Kubernetes environment using a Spring Boot application:

I need to implement a client which sends in a time range of 10 hours messages via TCP to a server.
The message interval is every second.
There are in parallel 100-1000 messages to be sent to the server.

The last requirement is what makes me thinking about the best architecture or implementation.
I thought that threading is the best way, but if I want to send at exactly every second a message this could be painful.

Do you maybe have some resources or also faced this problem?

python – Bot : Sends with the loverate between 2 persons

I’m creating a Discord Bot and i made a !love command which is testing the love rate between 2 persons or entities.

Example : !love Peignoir Emma

Result: The loverate between Peignoir and Emma is x%

Here’s the code :

@bot.command(name="love", aliases=("l"))
async def love(ctx, Personne1, Personne2):
    if != 763352957579690018:
        printIt = 1
        wordBanList = ('@everyone', '@here', '<@&763489250162507809>','<@&777564025432965121>','<@&822200827347075132>',
        LoveRate = str(random.randrange(0, 100))
        for y in range(len(wordBanList)):
            if(Personne1 == wordBanList(y) or Personne2 == wordBanList(y)):
                printIt = 0

        if(printIt == 0):
            await ctx.send("Tu t'es pris pour qui ?")
            if debug == True:
                print("(DEBUG) !love : Someone tried to use a banned word !")
            await ctx.send("L'amour entre **"+Personne1+"** et **"+Personne2+"** est de **"+LoveRate+"%** <:flushed:830502924479758356>")
            if debug == True:
                print("(DEBUG) !love : The love rate ("+LoveRate+"%) between "+Personne1+" and "+Personne2+" has been printed in channel ID "+str(
        botChannel = discord.utils.get(ctx.guild.channels, id=768194273970880533)
        messageBot = await ctx.send("Va faire cette commande dans "+botChannel.mention+" ou je te soulève <:rage:831149184895811614>")
        await asyncio.sleep(5)
        await ctx.message.delete()
        await messageBot.delete()

I’m pretty sure this code is optimizable, but i don’t know how, can somebody help me 🙂 ?

nginx – is the erratic behaviour and the following related? entering “www.mydomain” instead of “mydomain” sends me to my other site under same IP

The purpose of this question is to mention two things that I cant understand. I want to ask if they are related, in order to know if I should contact the domain vendor or not.

I currently have one IP and I’m using Nginx to serve two sites:

Erratic behaviour:
Almost a week has passed since I set up the latter with the following configuration
(GoDaddy conf., translated from Spanish). Nevertheless, sometimes entering “” in Chrome directs me to (the company that sold me the domain).

Another problem:
Entering (instead of directs me to; I dont understand if that is an Nginx directive, a matter of one domain having been set up before the other, something related to the mentioned domain vendor, or another thing.

I know I should contact the vendor about the erratic behaviour, but dont know if the second item (“another problem”) should be mentioned too.

GoDaddy conf

Type    Name    Value   TTL Actions
A   @  1 hora  Modify
A   @   Parked  600 seconds Modify
CNAME   www @   1 hour  Modify
CNAME   _domainconnect 1 hour  Modify
NS  @  1 hour  
NS  @  1 hour  
SOA @   Main server name:   1 hour

Nginx configuration file.

server {
    root /usr/share/nginx/html;
    location / { try_files $uri @app; }
    location @app {
        include uwsgi_params;
        uwsgi_pass flask:5000;
        uwsgi_read_timeout 180;

server {
    root /app-tictactoe;

ios – What information does Apple collect when an iPad sends “advanced” log data?

Apple support contacted me regarding an issue I had with an iPad. They requested diagnostic data which I agreed to (in the Privacy -> Analytics). Then right after the diagnostic data was sent, another window popped up that requested more “advanced” logs and in the description it said it would contain, among other things, my email addresses, file paths, etc. The process took a while and a message warned that the iPad may become slow during this process. At the end it compressed the data and uploaded it to Apple. I couldn’t see what was being uploaded but judging from the time it took, I think it was tens of megabytes (maybe 50~80MB after compression).

Unfortunately I did not take a screenshot thinking I would be able to find this topic online on Apple’s web site. But I can’t see any document that describes what data is exactly collected or for how long it is retained. Does Apple describe this “advanced” data collection anywhere?