Philocode – Telegram
PHP __toString() vs Go Stringer
👍4
مزایده آنلاین دومین 😋
Go/Gin/MySQL/Vue.js/Tailwind
4😢1
یه API هست که هر ثانیه فقط یه ریکوست از هر آی‌پی قبول می‌کنه. یعنی دومین ریکوست رو بفرستید، بلاک می‌شید.

ایده‌ام برای حل این چالش این بود که long-polling داشته باشیم (تا جواب نباشه، ریکوست معطل می‌مونه): به این صورت که من و شما توی یه ثانیه دوتا ریکوست می‌فرستیم و درخواست اطلاعات می‌کنیم:
Me: abcd
You: wxyz

این دوتا رو توی صف می‌ریزیم و یه تایمر هم هر سه ثانیه میاد و دیتای توی صف رو جمع‌شده توی یه ریکوست برای اون API می‌فرسته و نتیجه رو توی یه slice (یه چیزی شبیه آرایه) می‌ریزه که هر کدوممون اطلاعات خودمون رو ازش برداریم.

چالش رو حل می‌کنه، اما پیاده‌کردن همین long-polling خودش یه چالش بزرگ‌تره. 😁
🔥2
جالبه:
timeout 2 sleep 20
Philocode
جالبه: timeout 2 sleep 20
time sleep 2

real  0m2.004s
user 0m0.001s
sys 0m0.003s
جالب بود! 😎🥶
👍4
Philocode
Photo
How Docker generates random container names?

Docker will assign a randomly generated name to each container, if you don't provide a name while creating a container from an image. Currently I have a "peaceful_archimedes" and a "determined_hellman" on my machine!

1. The package "namesgenerator" is responsible for doing this:
https://lnkd.in/emJPDHpa
2. As you can see, the generated name consists of an adjective (left), and an underscore, and a name (right). The adjective and the name would be chosen from two arrays randomly.
3. The package "is officially frozen - no new additions will be accepted".
4. "At some future time, this may be replaced with something that sparks less controversy, but for now it will remain as-is."
5. Someone made a pull request about two years ago to remove Valentina Tereshkova from the names array, but he failed:
https://lnkd.in/eXscbCK5
6. "Steve Wozniak is not boring", I heartily laughed at this jode (joke-code, my invention), added by Solomon Hykes:
https://lnkd.in/evUuNa4i

Thanks to Soroush Moosapour for mentioning this package, so that I had the pleasure of reading the code.