Skip to content

Instantly share code, notes, and snippets.

View petrjahoda's full-sized avatar

Petr Jahoda petrjahoda

View GitHub Profile
@petrjahoda
petrjahoda / main.go
Last active June 10, 2021 07:47
updated loop
for i := 0; i < numberOfSimulationas; i++ {
fmt.Print("Monte Carlo Simulation No. ")
fmt.Printf("%d\n", i+1)
if randomBadDay == rand.Intn(numberOfTrades-1)+1 {
profitPercentage = 100 - profitPercentage
fmt.Print("B")
}
sum := 0.0
profitsCount := 0
lossesCount := 0
@petrjahoda
petrjahoda / main.go
Created August 14, 2021 07:20
1. The basics
package main
import "fmt"
type Car struct {
name string
}
type Truck struct {
name string
@petrjahoda
petrjahoda / main.go
Created August 14, 2021 07:25
2. Changing the name with a function, by passing the value
package main
import "fmt"
type Car struct {
name string
}
type Truck struct {
name string
@petrjahoda
petrjahoda / main.go
Created August 14, 2021 07:43
3. Changing the name with a function, by using a pointer
package main
import "fmt"
type Car struct {
name string
}
type Truck struct {
name string
@petrjahoda
petrjahoda / main.go
Created August 14, 2021 08:26
4. Changing the name with a method, passing a value
package main
import "fmt"
type Car struct {
name string
}
type Truck struct {
name string
@petrjahoda
petrjahoda / main.go
Created August 14, 2021 08:50
5. Changing the name with a method, passing a pointer
package main
import "fmt"
type Car struct {
name string
}
type Truck struct {
name string
@petrjahoda
petrjahoda / main.go
Created August 14, 2021 09:07
6. Changing the name with a method, passing a pointer and interface
package main
import "fmt"
type Car struct {
name string
}
type Truck struct {
name string
@petrjahoda
petrjahoda / main.go
Created August 20, 2021 09:31
WebSocket Server
package main
import (
"fmt"
"github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil"
"math/rand"
"net/http"
"strconv"
)
@petrjahoda
petrjahoda / main.go
Created August 20, 2021 09:34
WebSocket Client
package main
import (
"context"
"fmt"
"github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil"
"math/rand"
"os"
"strconv"
@petrjahoda
petrjahoda / main.go
Last active August 29, 2021 12:44
socket-server
package main
import (
"bufio"
"fmt"
"net"
"strconv"
"time"
)