| Item | Detail |
|---|---|
| Hosting | Viettel (Vietnam) - cannot migrate (regulation) |
| Protocol | TCP only (no UDP) |
| Game Server Port | 3001 |
| Networking | Custom raw TCP sockets (System.Net.Sockets) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //SweeterCoffee.php | |
| class SweeterCoffee implements CoffeeInterface | |
| { | |
| private $coffee; | |
| public function __construct(CoffeeInterface $coffee) | |
| { | |
| $this->coffee = $coffee; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //coffee_shop_rainy_day_context.php | |
| //to load Class & Interface file when we need them | |
| spl_autoload_register(function ($class_name) { | |
| include $class_name . '.php'; | |
| }); | |
| //at the coffee shop in a rainy day | |
| $egg = new Egg(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //Egg.php | |
| class Egg | |
| { | |
| public function taste() | |
| { | |
| echo 'It tastes eggyyy...!' . PHP_EOL; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //EggCoffee.php | |
| class EggCoffee implements CoffeeInterface | |
| { | |
| private $egg; | |
| public function __construct(Egg $egg) | |
| { | |
| $this->egg = $egg; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //home_context.php | |
| //to load Class & Interface file when we need them | |
| spl_autoload_register(function ($class_name) { | |
| include $class_name . '.php'; | |
| }); | |
| //at home | |
| $consumer = new AtHomeConsumer(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: UNLICENSED | |
| pragma solidity ^0.8.4; | |
| import '@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol'; | |
| contract MyNFT is ERC721URIStorage { | |
| constructor() ERC721("MyNFT", "NFT") { | |
| } | |
| function mint(address to, uint256 tokenId, string memory uri) public { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "net/http" | |
| "os" | |
| ) | |
| func main() { | |
| port := os.Getenv("PORT") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IMAGE_NAME = telegrammessenger/proxy:latest | |
| CONTAINER_NAME = mtproto-proxy | |
| PORT = 443 | |
| SECRET = secret # ← Replace this or override via `make run SECRET=...` | |
| run: | |
| docker run -d \ | |
| --name $(CONTAINER_NAME) \ | |
| -p $(PORT):443 \ | |
| -p 8888:8888 \ |
Vấn đề: Bạn đang dùng sequelize.sync({ alter: true }) để tự động thay đổi database schema mỗi khi server khởi động.
Tại sao lại sai? Hãy tưởng tượng database là một cái tủ hồ sơ. alter: true giống như mỗi lần mở cửa hàng, bạn tự động sắp xếp lại toàn bộ tủ — có thể vô tình làm mất dữ liệu. Trong production (server thật có người dùng thật), điều này cực kỳ nguy hiểm vì có thể xóa cột, mất data.
OlderNewer