Skip to content

Instantly share code, notes, and snippets.

View jreisinger's full-sized avatar
👋
hello friend

Jozef Reisinger jreisinger

👋
hello friend
View GitHub Profile
package main
import (
"fmt"
"github.com/oschwald/geoip2-golang"
"log"
"net"
"os"
)
package main
import (
"fmt"
"math/rand"
)
// An abstract type, i.e. an interface
type shuffler interface {
Len() int
package main
import (
"fmt"
)
type SummableSlice []int
func (s SummableSlice) sum() int {
sum := 0
package main
import (
"fmt"
"math/rand"
"sync/atomic"
"time"
)
var (
package main
import (
"fmt"
"math/rand"
"time"
)
func reader(ch chan int) {
t := time.NewTimer(10 * time.Second)
package main
import (
"fmt"
"time"
)
func printer(msg string, stopCh chan bool) {
for {
select {
// There's no "channel broadcast" in Go, i.e. you can't send something to multiple goroutines using the same channel. However you can close the channel and all goroutines will be notified.
package main
import (
"fmt"
"time"
)
func printer(msg string, goCh chan bool) {
package main
import (
"fmt"
"time"
)
// emit words onto the channel until the timer kicks in
func emit(wordChannel chan string) {
defer close(wordChannel)
package main
import "fmt"
// printArray prints type, elements' values, capacity and length of an array
func printArray(a [3]int) {
fmt.Printf("%T\t", a)
for _, v := range a {
fmt.Printf("%d ", v)
}
#!/bin/bash
echo "--> create VMs..."
for i in 1 2 3; do
docker-machine create -d virtualbox node-$i
done
echo "--> initialize swarm master..."
eval $(docker-machine env node-1)
docker swarm init \