Programming Notes ✍️ – Telegram
Programming Notes ✍️
12 subscribers
65 photos
1 file
22 links
Download Telegram
How to choose the right pattern

Rough mental checklist:

I have multiple identical units of work → worker pool (with a job channel).

I have multi-stage processing → pipeline + fan-out/fan-in.

I just need to safely share and mutate some data → mutex / RWMutex, maybe atomics.

I need to limit concurrency → semaphore via buffered channel or worker pool size.

I need cancellation/timeout → context.Context + select.

I’m overcomplicating things with channels → step back, consider a simple mutex.
A thread is a single sequence stream within a process. Threads are also called lightweight processes as they possess some of the properties of processes. Each thread belongs to exactly one process.
What STAR stands for
Situation - the situation you had to deal with
Task - the task you were given to do
Action - the action you took
Result - what happened as a result of your action and what you learned from the experience
# Demonstrating (mis)use of special methods
class SillyClass:
def getitem(self, key):
""" Determines behavior of self[key] """
return [True, False, True, False]

def pow(self, other):
""" Determines behavior of self ** other """
return "Python Like You Mean It"
For effective security logging and monitoring, consider the following types of logging:

File Access: Who has viewed or downloaded a specific file?
Authentication Attempts: Have any incorrect authentication attempts occurred?
Login Activity: Who has logged in recently?
Unexpected Events: Have authentication events happened at unexpected times or from unexpected locations?

These types of logging help in detecting and responding to security breaches promptly.
Server Side Request Forgery (SSRF) is a vulnerability that allows an attacker to coerce a server to send crafted requests to unintended destinations. When SSRF is present, attackers can send requests pretending to be the victim server, potentially accessing sensitive and administrative functions like internal API calls and database queries. To prevent SSRF, it's important to enforce an allowlist or blocklist for external resources, ensuring that only legitimate requests are processed.