Skip to content

Instantly share code, notes, and snippets.

Avatar

Fernando Porazzi fernandoporazzi

View GitHub Profile
View blockchain-main.go
package main
import (
"fmt"
"github.com/fernandoporazzi/blockchain-golang/blockchain"
)
func main() {
blockchain := blockchain.CreateBlockchain()
View blockchain-v2.go
func (b *Blockchain) CreateGenesisBlock() {
block := block.CreateBlock()
block.Index = 0
block.PreviousHash = "0000000000000000000000000000000000000000000000000000000000000000"
block.Data = "Genesis Block"
block.Difficulty = b.Difficulty
block.Mine()
View blockchain-v1.go
package blockchain
import (
"github.com/fernandoporazzi/blockchain-golang/block"
)
type Blockchain struct {
Blocks []block.Block
Index int
Difficulty int
View block-v2.go
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)
View block-v1.go
package block
import (
"time"
)
type Block struct {
Index int
PreviousHash string
Data string
View sorense-dice.go
package main
import (
"fmt"
"strings"
)
func CompareTwoStrings(stringOne, stringTwo string) float32 {
removeSpaces(&stringOne, &stringTwo)
View main.go
package main
import "fmt"
func main() {
urls := []string{"github.com",
"twitter.com",
"facebook.com",
"instagram.com"}
View main.php
<?php
$x = 1;
$y = 2;
$z = 100;
do {
if ($x % 4 == 0) {
echo "X é múltiplo de 4";
} else {
echo "xd";
View main.c
// Compiled
#include <stdio.h>
int main () {
int x = 1;
int y = 2
int z = 100;
do {
View response.json
{
"resultStatus":"SUCCESS",
"data":{
"region":null,
"phone":null,
"titleCode":null,
"locationTypeCode":null,
"cellPhone":null,
"phone2":null,
"remarks":null,