Skip to content

Instantly share code, notes, and snippets.

View drgomesp's full-sized avatar
🏠
Working from home

Daniel Ribeiro drgomesp

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am drgomesp on github.
  • I am drgomesp (https://keybase.io/drgomesp) on keybase.
  • I have a public key ASAprAbtdXdJ2XBSY6QHS6Ei7HJ7NL54JMTxeO88Qfuo0wo

To claim this, I am signing this object:

@drgomesp
drgomesp / beyond-the-basics-of-go-http-handlers.md
Last active January 8, 2021 16:39
beyond-the-basics-of-go-http-handlers.md

Beyond the Basics of Go - HTTP Handlers

http.Handler and http.HandlerFunc

The Go standard library defines two main components for dealing with incoming HTTP requests: the http.Handler type and the http.HandlerFunc type. While http.Handler is an actual interface,

type Handler interface {
	ServeHTTP(ResponseWriter, *Request)
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJhY2NvdW50cyI6W3sidXNlcmlkIjoxMzQ1MzQ1NDMsInJvb3RpZCI6MzQ1MzQ1NDMyLCJzZXJ2ZXJpZCI6MzQ1MzQ1NDMzLCJicmFuZCI6IkJSIn0seyJ1c2VyaWQiOjEzNDUzNDU0Mywicm9vdGlkIjozNDUzNDU0MzIsInNlcnZlcmlkIjozNDUzNDU0MzMsImJyYW5kIjoiQlIifSx7InVzZXJpZCI6MTM0NTM0NTQzLCJyb290aWQiOjM0NTM0NTQzMiwic2VydmVyaWQiOjM0NTM0NTQzMywiYnJhbmQiOiJCUiJ9LHsidXNlcmlkIjoxMzQ1MzQ1NDMsInJvb3RpZCI6MzQ1MzQ1NDMyLCJzZXJ2ZXJpZCI6MzQ1MzQ1NDMzLCJicmFuZCI6IkJSIn0seyJ1c2VyaWQiOjEzNDUzNDU0Mywicm9vdGlkIjozNDUzNDU0MzIsInNlcnZlcmlkIjozNDUzNDU0MzMsImJyYW5kIjoiQlIifSx7InVzZXJpZCI6MTM0NTM0NTQzLCJyb290aWQiOjM0NTM0NTQzMiwic2VydmVyaWQiOjM0NTM0NTQzMywiYnJhbmQiOiJCUiJ9LHsidXNlcmlkIjoxMzQ1MzQ1NDMsInJvb3RpZCI6MzQ1MzQ1NDMyLCJzZXJ2ZXJpZCI6MzQ1MzQ1NDMzLCJicmFuZCI6IkJSIn0seyJ1c2VyaWQiOjEzNDUzNDU0Mywicm9vdGlkIjozNDUzNDU0MzIsInNlcnZlcmlkIjozNDUzNDU0MzMsImJyYW5kIjoiQlIifSx7InVzZXJpZCI6MTM0NTM0NTQzLCJyb290aWQiOjM0NTM0NTQzMiwic2VydmVyaWQiOjM0NTM0NTQzMywiYnJhbmQiOiJCUiJ9LHsidXNlcml
its me! drgomesp

Hello!

I've been trying to come up with a nice design for the component architecture of a GameBoy emulator I'm working on. I have been facing a few challenges in regards to having clear dependency boundaries and what owns what. Particularly, I'm writing the emulator in Rust, which kind of forces me to think about the design of the components before hand, due to the ownership and mutability model.

Here are a few questions that I have unanswered:

Does it make sense to have a Motherboard/Board component that will hold a reference to all hardware components in the system, including the CPU, Memory, etc?

Where should the reference to the bootrom be stored, ideally? Should the CPU know about it, or when need be, just read from a given address from a different component (Bus, or something like that)?

@drgomesp
drgomesp / promises.go
Created November 12, 2017 06:57
Example of a very basic promises implementation in Go
package main
import (
"errors"
"log"
"sync"
"time"
)
// Promise ...
package main
import (
"fmt"
"runtime"
"github.com/go-gl/gl/v4.1-core/gl"
"github.com/go-gl/glfw/v3.2/glfw"
)
package opengl
type VAO struct {
}
type VBO struct {
}
using System;
using System.Drawing;
using System.IO;
namespace Tibia.Util
{
public class SpriteReader
{
public static Image GetSpriteImage(Objects.Client client, int spriteId)
{
-request
failed MSpanList_Insert 0x763b10 0x21177457e2ec 0x0
fatal error: MSpanList_Insert

runtime stack:
runtime.MSpanList_Insert(0x69ddb8, 0x763b10)
	/usr/local/Cellar/go/1.4.1/libexec/src/runtime/mheap.c:692 +0x8f
runtime.MHeap_Alloc(0x69be00, 0x1, 0x10000000013, 0xcf29)
	/usr/local/Cellar/go/1.4.1/libexec/src/runtime/mheap.c:240 +0x66