Skip to content

Instantly share code, notes, and snippets.

View anvodev's full-sized avatar

An Vo anvodev

View GitHub Profile
@anvodev
anvodev / hello.go
Created April 5, 2024 05:29
Serving HTTP requests using a Go binary file and Supervisor in Ubuntu
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
@anvodev
anvodev / simple_erc721_uri_storage.sol
Created May 3, 2023 00:47
Simple NFT that extend ERC721URIStorage to have the ability to link NFT token with off-chain metadata
// 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 {
<?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();
<?php
//EggCoffee.php
class EggCoffee implements CoffeeInterface
{
private $egg;
public function __construct(Egg $egg)
{
$this->egg = $egg;
<?php
//Egg.php
class Egg
{
public function taste()
{
echo 'It tastes eggyyy...!' . PHP_EOL;
}
}
<?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();
<?php
//SweeterCoffee.php
class SweeterCoffee implements CoffeeInterface
{
private $coffee;
public function __construct(CoffeeInterface $coffee)
{
$this->coffee = $coffee;
<?php
//coffee_shop_another_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 another day
$milk = new Milk();
<?php
//MilkCoffee.php
class MilkCoffee implements CoffeeInterface
{
private $milk;
public function __construct(Milk $milk)
{
$this->milk = $milk;
<?php
//Milk.php
class Milk
{
public function taste()
{
echo 'It tastes milkyyy...' . PHP_EOL;
}
}