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 / recursos-nostr-em-portugues.md
Last active September 11, 2023 17:41
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"
"strings"
)
func CompareTwoStrings(stringOne, stringTwo string) float32 {
removeSpaces(&stringOne, &stringTwo)
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"
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
}
@fernandoporazzi
fernandoporazzi / isprime.js
Last active August 29, 2015 14:03
Detect if a given word is prime according to their letter positions in alphabet.
var alphabet = [
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
];
// get char position in array
function stringToNumber (string) {
var number = 0;