en
Feedback
samdark blog

samdark blog

Open in Telegram

Notes taken by Alexander Makarov, lead of Yii framework and a long term IT engineering manager. Official Yii updates: https://www.yiiframework.com/ Consulting: https://asapirl.com/

Show more
The country is not specifiedTechnologies & Applications63 619
885
Subscribers
-124 hours
+17 days
+1430 days
Posts Archive
Trust people, talk to people I had no trust in people for many years. I'm still not sure what caused it but until relatively recently my defaults for people except family and friends were "do not trust, avoid". I've preferred online services and forms and machines to people. Partially because I understood better how machines operate and had no idea about people. That's similar for many IT people out there. In the past there were memes and stories about this side of our profession everywhere. Russia was super-comfortable in this regard: awesome services, delivery of virtually anything, e-appointments, e-govt, awesome detailed maps with all the businesses and their websites etc. I was able to live in this happy bubble for years. With time and my involvement in OpenSource I've expanded the bubble borders a lot and started to talk with many IT people and sometimes even asked for info/help. In 2022 I've moved to Armenia and it changed my defaults to "trust people until proven otherwise, talk to people whenever possible". In the country everything works through people. If you try to do things like in Russia, open a map and search for something, you see that there's basically nothing. Asking friends and even random people reveals that, on contrary, there's everything you could imagine, any of your problems could be solved, there are no dead-end situations etc. Overall, people are great by default. If you think overwise, try talking and you'll see the difference.

Fun representation of PHP world: https://proxify.io/worlds/php Almost accurate. Yii3 super-vampire needs to stand from the gr
Fun representation of PHP world: https://proxify.io/worlds/php Almost accurate. Yii3 super-vampire needs to stand from the grave :)

Yii3 Validator 1.0.0 Yii team just released first stable version of the validator package. That was one of the hardest to pla
Yii3 Validator 1.0.0 Yii team just released first stable version of the validator package. That was one of the hardest to plan and develop because to huge number of edge-cases.

Despite the fact that I don't agree on everything with the maintainer of core-js, his case is a good example of how unfair Op
Despite the fact that I don't agree on everything with the maintainer of core-js, his case is a good example of how unfair OpenSource could be to maintainers. https://github.com/zloirock/core-js/blob/master/docs/2023-02-14-so-whats-next.md

🎁 On Docker + WSL 2 performance I'm using Windows 11 daily on my PC and also using Docker to have a controllable development environment for PHP. WSL2 is fully compatible with Linux so more than suitable to run Docker but there's one quirk. Using Windows file system from WSL or using WSL file system from Windows is extremely slow. The only way to have a performance that is comparable to native Linux is to avoid these cross-OS Plan9 file shares: 1. Work in WSL file system. 2. Avoid /mnt/c and other Windows FS mounts. The same is true about IDE. Accessing files using WSL FS via \\wsl.localhost\Ubuntu or \\wsl$ makes IDE quite slow. Thankfully, there are remote development capabilities in both PhpStorm and VSCode. References - https://docs.docker.com/desktop/windows/wsl/ - https://learn.microsoft.com/en-us/windows/wsl/install - https://www.docker.com/blog/docker-desktop-wsl-2-best-practices/ - https://www.jetbrains.com/help/phpstorm/remote-development-starting-page.html - https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl

True :)
True :)

final vs not final A reddit thread emerged today raising the topic again: https://www.reddit.com/r/PHP/comments/10secwq/95_final_readonly_classes_what_is_your_superpower/ viktorprogger in comments is Yii3 core team member and what he wrote I fully agree with. — Hi! I'm not the OP, but we in r/yii3 make classes final by default. The idea is simple: you should not change class behavior, only extend it (O and L in SOLID). And this is achievable with composition instead of inheritance. If not, it's treated as a bug in the framework. Now let me answer your questions: Yes, all our services are final. Not all of them has interface, because some of them not meant to be replaced with another implementation. These are usually facades for a complicated set of classes. Yes, testing becomes more complicated, because you have to really create object for all the final classes. Anyway, all our released packages has ~100% tests coverage, ~100% mutation score via Infection, and Psalm set at level 1 without any errors.

Describe where ChatGPT is not applicable and should not be used. ChatGPT is a highly sophisticated AI language model, but it
Describe where ChatGPT is not applicable and should not be used. ChatGPT is a highly sophisticated AI language model, but it is not a replacement for human expertise in certain areas. It should not be used: 1. In situations where human judgement is required: ChatGPT does not have the ability to make ethical or moral decisions. 2. In life-critical decision making: ChatGPT is not capable of providing accurate and trustworthy information for life-critical decisions such as medical diagnosis or treatment. 3. In place of professional expertise: ChatGPT is not a substitute for the knowledge and experience of professionals in fields such as law, finance, and engineering. 4. In financial transactions: ChatGPT should not be used for financial transactions, as it does not have the ability to understand financial markets or the consequences of financial decisions. 5. In creating or managing legal documents: ChatGPT is not capable of creating legally binding documents or providing legal advice. It's important to use ChatGPT responsibly and within its limitations, as well as to validate any information obtained from it with other sources.

Keychron K5 SE Wireless Mechanical Keyboard Bought it as a birthday present myself to replace good old A4Tech KV-300H. 👍 Goo
Keychron K5 SE Wireless Mechanical Keyboard Bought it as a birthday present myself to replace good old A4Tech KV-300H. 👍 Good - Typing is awesome. I am using brown switches. Bought blue and red as well but haven't tried them yet. - It's full-size. - RGB light is nice despite most modes being distracting. - Orange ESC gives accent. - Fn keys are good. - Awesome set (keycaps, tools). - Works flawlessly via USB type C. - Good support. 👎 Bad - Bluetooth doesn't work with many cheaper receivers. - Battery doesn't last long. - Charging LED is way too bright. Solved it w/ black tape :) https://www.keychron.com/products/keychron-k5-se-ultra-slim-wireless-mechanical-keyboard?variant=40054333145177

😱 Fear-driven is not the way Fear is one of the worst motivation tools I can imagine. Some examples of fear-driven actions: - Writing cryptic code and avoiding documenting so that the company you work for can't replace you. - Not testing enough or not writing tests out of fear of missing a deadline. - Forcing yourself to impress your wife out of fear of losing her. - Working 22 hours a day because of fear of missing a deadline. - Not asking for a raise out of fear of getting fired. - etc. All of these are destructive actions, and this is true both for a person doing things out of fear and for the one using fear as a motivation. - Writing cryptic code and avoiding documenting → bus factor, long onboarding, inability to set up common standards. - Not testing enough or not writing tests → bugs, inability to ship on time, too much time spent on manual testing. - Forcing yourself to impress your wife → various personal and family problems, probably a divorce. - Working 22 hours a day → low performance, lots of bugs, burnout. - Not asking for a raise → leaving the company for a better salary, getting through onboarding and adaptation again. All of the above are either self-fulfilling prophecies when the result is what one was trying to avoid, or a much longer and inefficient path to the desired outcome. As a manager you should avoid using fear as much as possible. As a person you should always ask yourself two things: 1. Would failing what is feared really leads to imagined consequences? 2. Would the shortcut you're going to take work long-term?

Since it is Friday, how about some regular expressions fun? https://regexcrossword.com/
Since it is Friday, how about some regular expressions fun? https://regexcrossword.com/

📸 Mountains of Georgia
📸 Mountains of Georgia

😈 You can't just remove it from git git is great for storing source code. Lightweight, fast, cheap branching, full change history. Ideal for development. // Thanks, Linus! The problem with "full change history" is that git remembers everything including your secrets: API keys, passwords, tokens. Checking for such stored secrets is a must. Fortunately, there is a tool for this called "gitleaks": https://github.com/zricethezav/gitleaks You get the tool, run it with gitleaks detect -v and get a detailed list of secrets found including commit hashes, files etc. I highly recommend running it on your codebase. Please share what you found in the comments (without details, of course).

🎉 Dmitry Derepko, Yii3 core team member, just released a tool for generating files with tests cases based on class methods signatures. The name is "Test It!". It could give a very good start if you don't have enough time to write tests (that's when you usually need tests most). Check it out: https://github.com/xepozz/test-it

📕How PHP Environment Variables Actually work @ 2019-03-26 by Matt Allan A great overview on how PHP environment variables work. The blog went down so I've recovered it via https://archive.org/web/ https://gist.github.com/samdark/01279afbce4871bd02b556bbb7ca4790#reading-environment-variables

📙 Distributed Systems 4th edition (2023) by Maarten van Steen and Andrew S. Tanenbaum — a great book and the digital edition is currently free. https://www.distributed-systems.net/index.php/books/ds4/

I work on Windows, Mac and Linux switching between them constantly. It is very convenient when you have similar keyboard layo
I work on Windows, Mac and Linux switching between them constantly. It is very convenient when you have similar keyboard layout, locale switching, hotkeys and shell. ⭐️ Keyboard layout Custom keyboard layout by Ilya Birman works on Windows, Linux and MacOS in a similar way. English: https://ilyabirman.net/typography-layout/ Russian: https://ilyabirman.ru/typography-layout/ ⭐️ Caps lock to switch keyboard layout 📌 Linux Works by default. 📌 Windows 1. Download https://haali.net/winutils/lswitch.exe by Mike Matsnev 2. Open regedit.msc 3. Go to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run 4. Add "String value". Name is "lswitch". Value is c:\path_to\lswitch.exe" 20 5. Reboot 📌 MacOS 1. System Preferences → Language & Region → Keyboard Preferences 2. "Use the Caps Lock Key to Switch ..." ⭐️ Shell 📌 A good shell - On Linux — bash. - On MacOS — zsh. - On Windows — bash is installed with git: https://git-scm.com/download/win 📌 Starship https://starship.rs/

This is the old reading from 2012-2016 but still qute enjoyable. Highly recommended. An illustrated collection of (sometimes
This is the old reading from 2012-2016 but still qute enjoyable. Highly recommended. An illustrated collection of (sometimes violent) fables concerning the Art and Philosophy of software development, written in the spirit of Zen kōans http://www.thecodelesscode.com/contents p.s. this is one of my favorite ones: http://www.thecodelesscode.com/case/117

Stumbled upon https://php-di.org/doc/attributes.html#inject and had a flashback from late 2000 when I've developed with J2EE
Stumbled upon https://php-di.org/doc/attributes.html#inject and had a flashback from late 2000 when I've developed with J2EE and Spring. That was 2007 — 2008 and all the code was filled with annotations pointing about what dependency to inject where. Using attributes in PHP for the same purpose, as used in PHP-DI ties your code to specific container implementation while the whole idea of dependency inversion principle is that your classes should not specify what is injected. The problem in Java world was big enough so in 2009, a set of injection annotations was defined and standardized as JSR-330 https://jcp.org/en/jsr/detail?id=330. That allowed container interoperability but did not solve the problem of violating dependency inversion. PHP seems to fall into the same trap, only 13 years later.