Skip to content

Instantly share code, notes, and snippets.

View fernandoporazzi's full-sized avatar

Fernando Porazzi fernandoporazzi

  • Bitvavo
  • Amsterdam
View GitHub Profile
@fernandoporazzi
fernandoporazzi / main.c
Created May 9, 2025 14:05
Open ports scanner
#include <stdio.h>
#include <sys/socket.h>
#include <errno.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <time.h>
@fernandoporazzi
fernandoporazzi / recursos-nostr-em-portugues.md
Last active May 5, 2025 17:51
Recursos Nostr em Português

TL;DR: nostr1 é um protocolo que tem o poder de substituir ferramentas como Twitter, Telegram e etc.


O que é nostr?

Nostr é algo novo e confuso, mas ao mesmo tempo é algo muito legal. Nostr é o protocolo aberto mais simples que é capaz de criar uma rede social global que é resistente a censuras de uma vez por todas.

Footnotes

  1. nostr = Notes and Other Stuff Transmitted by Relays

package main
import (
"fmt"
"github.com/fernandoporazzi/blockchain-golang/blockchain"
)
func main() {
blockchain := blockchain.CreateBlockchain()
func (b *Blockchain) CreateGenesisBlock() {
block := block.CreateBlock()
block.Index = 0
block.PreviousHash = "0000000000000000000000000000000000000000000000000000000000000000"
block.Data = "Genesis Block"
block.Difficulty = b.Difficulty
block.Mine()
package blockchain
import (
"github.com/fernandoporazzi/blockchain-golang/block"
)
type Blockchain struct {
Blocks []block.Block
Index int
Difficulty int
func (b *Block) GenerateHash() {
index := strconv.Itoa(b.Index)
nonce := strconv.Itoa(b.Nonce)
b.Hash = fmt.Sprintf("%x", sha256.Sum256([]byte(index+b.PreviousHash+b.Data+b.Timestamp.String()+nonce)))
}
func (b *Block) Mine() {
prefix := getPrefix(b.Difficulty)
package block
import (
"time"
)
type Block struct {
Index int
PreviousHash string
Data string
package main
import (
"fmt"
"strings"
)
func CompareTwoStrings(stringOne, stringTwo string) float32 {
removeSpaces(&stringOne, &stringTwo)
package main
import "fmt"
func main() {
urls := []string{"github.com",
"twitter.com",
"facebook.com",
"instagram.com"}
package main
import "fmt"
// Cria estrutura
type item struct {
string
w, v int
}