week report 2024.12

The priorities you think you have VS. The priorities your actions show you have.
Entertainment¶
Demon Destruction¶
What should I categorize this manga, Denpa SF?
After the storyline mentioned multi-universe, the ending really didn't matter at all. If you were asking, I would say the world-0 is a little bit more realistic.
Learning¶
Find Duplicates in 1~n array¶
If we can modify the original array, we can iterate the array, make every number[idx] to negative. And the next we meet a negative number, that's the one duplicated.
class Solution:
def solution(self, nums) -> int:
for n in nums:
idx = abs(n)
if nums[idx] < 0:
return idx
nums[idx] = -nums[idx]
return -1
If it's not allowed to in-place modification, use slow-fast pointer strategy.
class Solution:
def solution(self, nums) -> int:
slow, fast = nums[0], nums[nums[0]]
while slow != fast:
slow = nums[slow]
fast = nums[nums[fast]]
# reset to start point
fast = nums[0]
while slow != fast:
slow = nums[slow]
fast = nums[fast]
return slow
life¶
- a rainy week
- Yokohama is a better place to live comparing to Tokyo, I think
- And I really don't have a strong feeling towards Sakura
- Also, I think Shrimp is my favorite now
- Finally, I still have to contribute more time and energy to personal growth, to get out of this frustrating life condition.
Sharing¶
- It’s easier to get a smart person to do something hard than to get them to do something easy that doesn’t matter.
Docker Tricks¶
- multi-stage build
- optimize build cache utilization
- minimize final image size
- label build stages
- squashing image layers
- otpmizing image size
- simplifying image layers
- docker buildkit secrets
- minimize secret exposure
- scoped secrets
- version pinning
- leverage
.dockerignore - health checks in Dockerfiles
- docker cli output formatting
docker ps --format '{{.ID}}'docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
- optimizing cache use in builds
- docker events for monitoring
docker events --filter 'type=container'docker events --filter 'type=container' --filter 'event=start' --filter 'event=stop' --filter 'label=environment=prod'
- running containers in read-only mode
docker run --read-only --tmpfs /tmp -d myimage:latest- security-sensitive/stateless applications, to enforce immutability
- cleaning up with docker prune
1.
docker image/volume/network prune2.docker system prune -a --volumes - overriding entrypoint for debugging
1.
docker run --entrypoint /bin/sh -it myimage:latest - docker contexts for multi-environment management
# enable docker buildkit
export DOCKER_BUILDKIT=1
# command
docker build --secret id=mysecret,src=/path/to/secret/file.txt -t myapp:latest .
References¶
- https://anilist.co/manga/85316/
- https://overcast.blog/13-docker-tricks-you-didnt-know-47775a4f678f
- docker tricks seem really useful
- https://medium.com/@ricbedin/how-i-landed-4-staff-l6-software-engineering-offers-amazon-meta-stripe-and-braze-cfeed8d3e5a9
- suggestions on applying for FAAG