For convenience, humans developed cat food and dog food.
With these simple foods, cats and dogs could live healthly lives.
But why isn’t there “Human Kibble” - a food with enougth nutrition and energy to fully satisfy all people?
Is it because humans cannot endure a single taste?
After some searching, I found it: the Energy Bar.
Creepy humans!

About 10 years ago, I was working as a coder in an office building.
One day, I packed a meal for lunch at a restaurant and carried it back to my building.
At the front door, a security guard stopped me: “Execuse me, sir. Delivery personnel should use the side door, please.”
I stammered: “I … I work here!”

In coding, you often need to run tasks on a schedule or at fixed intervals, such as:

  • Every 10 minutes
  • Everyday at 10:30 AM
  • Every Wednesday at 1:15 PM

While it’s possible to implement the functionality youself, reinventing the wheel is unnecssary.
Let me introduce the Python schedule module.

Install:

pip install schedule

Code Sample:

import schedule
import time

def job():
print("I'm working...")

schedule.every(10).minutes.do(job)
schedule.every().hour.do(job)
schedule.every().day.at("10:30").do(job)
schedule.every().monday.do(job)
schedule.every().wednesday.at("13:15").do(job)

while True:
schedule.run_pending()
time.sleep(1)

It is natural and straightforward.
I love it.

When trying to delete rows using an SQLAlchemy subquery, such as deleting all rows in Employee table where the age of associated Person is below 18, you might write code like this:

sl = DBSession.query(Person.id).filter(Person.age < 18).subquery()
DBSession.query(Employee).filter(Employee.person_id.in_(sl)).delete()

And after running it, you will got the following error:

sqlalchemy.exc.InvalidRequestError: Could not evaluate current criteria in Python:
"Cannot evaluate Select". Specify 'fetch' or False for the synchronize_session execution option.

The reason for this error is that SQLAlchemy cannot synchronize objects in a single loop when both SELECT and DELETE operations are involved.
To resolve it, you need to disable synchronization by adding the synchronize_session=False parameter:

sl = DBSession.query(Person.id).filter(Person.age < 18).subquery()
DBSession.query(Employee).filter(Employee.person_id.in_(sl)).delete(synchronize_session=False)

The issue’s StackOverflow Link

  • Thousands years ago, humans began planting poppy, and discovered that drinking its juice could create a feeling of happiness.
  • Refined poppy juice is called opium and was widely used to reduce pain and suppress coughs.
  • In the 16th century, people began smoking optium, it spread to China and eventually led to the First Opium War.
  • In the early 19th century, Scientists refined opium into morphine. During America Civil War, morphine was widely used as a painkiller, but many soldiers developed morphine addiction after the war.
  • In 1897, Bayer, a German pharmaceutical company, synthesized diacetylmorphine and named it Herorin, meaning ‘Hero’.
  • In 1912, the ‘International Opium Convention’ was signed in The Hague, This marked the beginning of global efforts to regulate opium,morphine, and heroin as drugs.

Have you ever been annoyed by pairing socks after washing them?
As a lazy coder, my solution is: All my socks are black - you can pair any two of them!

A:Why are the carbon-based lifeforms so excited?
B:They are celebrating their planet’s orbit around the star.(I have reported this many times.)

A:Why now? I mean, the planet is completing a circle every moment, isn’t it?
B:The starting point was chosen a bit hastily… Maybe they think this particular circle is special.

A:Is it?
B:No, it’s just one of its 4,548,991,314 ordinary circles.

A:I told you - they are not intelligent beings.

When I became a web app developer, I was confused by CORS(Cross-Origin Resource Sharing).
You get a CORS error when trying to access a server API from a web browser.

This error is not caused by the server blocking the request.
Instead,the server sends a CORS header, and the web browser blocks it if the server doesn’t allow cross-domain access.
However, if you access the same server API using Pyhton, it works just fine.

Why? Why does the web browser block it?

The Reason behind CORS:
Imagine you are logged into https://bank.com. The website’s frontend stores a cookie that acts as your authentication token. Every request you make to bank.com automatically inludes this cookie, allowing the server to identify you.

Now, suppose you open a malicious website in a new browser tab. That website might attempt to access bank.com using your authenticated cookie.
If bank.com has CORS restrictions, the web browser will block the request, keeping your money safe.
Otherwise, the malicious site could access your bank account, and you’d be in trouble.